Author: asterix Date: 2008-04-18 21:15:03 +0200 (Fri, 18 Apr 2008) New Revision: 9493
Added: trunk/data/glade/input_text_dialog.glade Modified: trunk/src/dialogs.py trunk/src/groupchat_control.py Log: use a textview to change subject of a room. Fixes #3858
Added: trunk/data/glade/input_text_dialog.glade =================================================================== --- trunk/data/glade/input_text_dialog.glade (rev 0) +++ trunk/data/glade/input_text_dialog.glade 2008-04-18 19:15:03 UTC (rev 9493) @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> +<!--*- mode: xml -*--> +<glade-interface> + <widget class="GtkDialog" id="input_dialog"> + <property name="border_width">6</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="has_separator">False</property> + <signal name="destroy" handler="on_input_dialog_destroy"/> + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox10"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkVBox" id="vbox76"> + <property name="visible">True</property> + <property name="border_width">6</property> + <property name="spacing">6</property> + <child> + <widget class="GtkHBox" id="hbox2960"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkImage" id="image507"> + <property name="visible">True</property> + <property name="stock">gtk-dialog-question</property> + <property name="icon_size">6</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <child> + <widget class="GtkTextView" id="input_textview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </widget> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area9"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <child> + <widget class="GtkButton" id="cancelbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="response_id">-6</property> + </widget> + </child> + <child> + <widget class="GtkButton" id="okbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="response_id">-5</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + </widget> + </child> + </widget> +</glade-interface>
Modified: trunk/src/dialogs.py =================================================================== --- trunk/src/dialogs.py 2008-04-18 18:35:53 UTC (rev 9492) +++ trunk/src/dialogs.py 2008-04-18 19:15:03 UTC (rev 9493) @@ -1434,22 +1434,16 @@ label.set_use_underline(True) self.add_action_widget(b, 200)
-class InputDialog: +class CommonInputDialog: '''Class for Input dialog''' - def __init__(self, title, label_str, input_str = None, is_modal = True, - ok_handler = None, cancel_handler = None): + def __init__(self, title, label_str, is_modal, ok_handler, cancel_handler): # if modal is True you also need to call get_response() # and ok_handler won't be used - self.xml = gtkgui_helpers.get_glade('input_dialog.glade') self.dialog = self.xml.get_widget('input_dialog') label = self.xml.get_widget('label') - self.input_entry = self.xml.get_widget('input_entry') self.dialog.set_title(title) label.set_markup(label_str) self.cancel_handler = cancel_handler - if input_str: - self.input_entry.set_text(input_str) - self.input_entry.select_region(0, -1) # select all
self.is_modal = is_modal if not is_modal and ok_handler is not None: @@ -1466,7 +1460,7 @@ self.cancel_handler()
def on_okbutton_clicked(self, widget): - user_input = self.input_entry.get_text().decode('utf-8') + user_input = self.get_text() self.cancel_handler = None self.dialog.destroy() if isinstance(self.ok_handler, tuple): @@ -1483,6 +1477,38 @@ self.dialog.destroy() return response
+class InputDialog(CommonInputDialog): + '''Class for Input dialog''' + def __init__(self, title, label_str, input_str = None, is_modal = True, + ok_handler = None, cancel_handler = None): + self.xml = gtkgui_helpers.get_glade('input_dialog.glade') + CommonInputDialog.__init__(self, title, label_str, is_modal, ok_handler, + cancel_handler) + self.input_entry = self.xml.get_widget('input_entry') + if input_str: + self.input_entry.set_text(input_str) + self.input_entry.select_region(0, -1) # select all + + def get_text(self): + return self.input_entry.get_text().decode('utf-8') + +class InputTextDialog(CommonInputDialog): + '''Class for Input dialog''' + def __init__(self, title, label_str, input_str = None, is_modal = True, + ok_handler = None, cancel_handler = None): + self.xml = gtkgui_helpers.get_glade('input_text_dialog.glade') + CommonInputDialog.__init__(self, title, label_str, is_modal, ok_handler, + cancel_handler) + self.input_buffer = self.xml.get_widget('input_textview').get_buffer() + if input_str: + self.input_buffer.set_text(input_str) + start_iter, end_iter = self.input_buffer.get_bounds() + self.input_buffer.select_range(start_iter, end_iter) # select all + + def get_text(self): + start_iter, end_iter = self.input_buffer.get_bounds() + return self.input_buffer.get_text(start_iter, end_iter).decode('utf-8') + class DubbleInputDialog: '''Class for Dubble Input dialog''' def __init__(self, title, label_str1, label_str2, input_str1 = None,
Modified: trunk/src/groupchat_control.py =================================================================== --- trunk/src/groupchat_control.py 2008-04-18 18:35:53 UTC (rev 9492) +++ trunk/src/groupchat_control.py 2008-04-18 19:15:03 UTC (rev 9493) @@ -1675,13 +1675,15 @@ return nb
def _on_change_subject_menuitem_activate(self, widget): - instance = dialogs.InputDialog(_('Changing Subject'), + instance = dialogs.InputTextDialog(_('Changing Subject'), _('Please specify the new subject:'), self.subject) response = instance.get_response() if response == gtk.RESPONSE_OK: # Note, we don't update self.subject since we don't know whether it # will work yet - subject = instance.input_entry.get_text().decode('utf-8') + start_iter, end_iter = instance.input_buffer.get_bounds() + subject = instance.input_buffer.get_text(start_iter, end_iter).decode( + 'utf-8') gajim.connections[self.account].send_gc_subject(self.room_jid, subject)
def _on_change_nick_menuitem_activate(self, widget):