commit generic ProgressDialog class to assist us in general for those stuff; now for logs migration

This commit is contained in:
Nikos Kouremenos 2005-12-02 16:18:04 +00:00
parent 8983b50f4c
commit ea8cefaac1
2 changed files with 177 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import gtk
import gtk.glade import gtk.glade
import gobject import gobject
import os import os
import Queue
import gtkgui_helpers import gtkgui_helpers
import vcard import vcard
@ -1270,3 +1271,51 @@ class InvitationReceivedDialog:
room, server = gajim.get_room_name_and_server_from_room_jid(room_jid) room, server = gajim.get_room_name_and_server_from_room_jid(room_jid)
JoinGroupchatWindow(account, server = server, room = room) JoinGroupchatWindow(account, server = server, room = room)
class ProgressDialog:
def __init__(self, title, during_text, messages_queue):
'''during text is what to show during the procedure,
messages_queue has the message to show
in the textview'''
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'progress_dialog', APP)
dialog = xml.get_widget('progress_dialog')
self.label = xml.get_widget('label')
self.label.set_markup('<big>' + during_text + '</big>')
self.progressbar = xml.get_widget('progressbar')
self.textview_buffer = xml.get_widget('textview').get_buffer()
dialog.set_title(title_text)
dialog.show_all()
xml.signal_autoconnect(self)
self.update_progressbar_timeout_id = gobject.timeout_add(100,
self.update_progressbar)
self.read_from_queue_id = gobject.timeout_add(1000,
self.read_from_queue_and_update_textview, messages_queue)
def update_progressbar(self):
self.progressbar.pulse()
return True # loop forever
def read_from_queue_and_update_textview(self, messages_queue):
try:
message = messages_queue.get_nowait()
print message
except Queue.Empty:
pass
else:
end_iter = self.textview_buffer.get_end_iter()
self.textview_buffer.insert(end_iter, message)
return True # loop for ever
def on_progress_dialog_delete_event(self, widget, event):
return True # WM's X button or Escape key should not destroy the window
def done(self, done_text):
'''whatever we were doing is done (either we problems or not),
make close button sensitive and show the done_text in label'''
self.xml.get_widget('close_button').set_sensitive(True)
self.label.set_markup('<big>' + done_text + '</big')
gobject.source_remove(self.update_progressbar_timeout_id)
gobject.source_remove(self.read_from_queue_id)

View File

@ -18925,4 +18925,132 @@ Maybe I'll refactor later</property>
</child> </child>
</widget> </widget>
<widget class="GtkDialog" id="progress_dialog">
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="has_separator">True</property>
<signal name="delete_event" handler="on_progress_dialog_delete_event" last_modification_time="Fri, 02 Dec 2005 15:52:45 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area11">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow">
<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>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.10000000149</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>