[meld] Remove most old statusbar usage and progress display code



commit 1aceac7a83f1e6c5ba168e24c10461adf9f29d89
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Sep 8 07:04:43 2013 +1000

    Remove most old statusbar usage and progress display code
    
    This removes the perms and time displays from folder comparisons, since
    we have actual columns for those now. The progress display is removed
    in favour of using a spinner in the toolbar.

 meld/dirdiff.py      |   38 --------------------------------
 meld/meldwindow.py   |   25 +++++++++++++++++----
 meld/ui/statusbar.py |   58 +------------------------------------------------
 3 files changed, 22 insertions(+), 99 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 485422d..4119421 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -348,14 +348,6 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         self.on_treeview_focus_out_event(None, None)
         self.focus_pane = None
 
-        lastchanged_label = Gtk.Label()
-        lastchanged_label.set_size_request(100, -1)
-        lastchanged_label.show()
-        permissions_label = Gtk.Label()
-        permissions_label.set_size_request(100, -1)
-        permissions_label.show()
-        self.status_info_labels = [lastchanged_label, permissions_label]
-
         # One column-dict for each treeview, for changing visibility and order
         self.columns_dict = [{}, {}, {}]
         for i in range(3):
@@ -1072,36 +1064,6 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
             self.emit("next-diff-changed", *have_next_diffs)
         self.current_path = cursor_path
 
-        paths = self._get_selected_paths(pane)
-        if len(paths) > 0:
-            def rwx(mode):
-                return "".join( [ ((mode& (1<<i)) and "xwr"[i%3] or "-") for i in range(8,-1,-1) ] )
-            def nice(deltat):
-                times = (
-                    (60, lambda n: ngettext("%i second","%i seconds",n)),
-                    (60, lambda n: ngettext("%i minute","%i minutes",n)),
-                    (24, lambda n: ngettext("%i hour","%i hours",n)),
-                    ( 7, lambda n: ngettext("%i day","%i days",n)),
-                    ( 4, lambda n: ngettext("%i week","%i weeks",n)),
-                    (12, lambda n: ngettext("%i month","%i months",n)),
-                    (100,lambda n: ngettext("%i year","%i years",n)) )
-                for units, msg in times:
-                    if abs(int(deltat)) < 5 * units:
-                        return msg(int(deltat)) % int(deltat)
-                    deltat /= units
-            fname = self.model.value_path( self.model.get_iter(paths[0]), pane )
-            try:
-                stat = os.stat(fname)
-            # TypeError for if fname is None
-            except (OSError, TypeError):
-                self.status_info_labels[0].set_text("")
-                self.status_info_labels[1].set_markup("")
-            else:
-                mode_text = "<tt>%s</tt>" % rwx(stat.st_mode)
-                last_changed_text = str(nice(time.time() - stat.st_mtime))
-                self.status_info_labels[0].set_text(last_changed_text)
-                self.status_info_labels[1].set_markup(mode_text)
-
     def on_treeview_key_press_event(self, view, event):
         pane = self.treeview.index(view)
         tree = None
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index f4fc146..2877d1c 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -196,8 +196,21 @@ class MeldWindow(gnomeglade.Component):
 
         self.appvbox.pack_start(self.menubar, False, True, 0)
         self.toolbar_holder.pack_start(self.toolbar, True, True, 0)
+
+        # Double toolbars to work around UIManager integration issues
         self.secondary_toolbar = Gtk.Toolbar()
-        self.toolbar_holder.pack_end(self.secondary_toolbar, True, True, 0)
+        self.secondary_toolbar.get_style_context().add_class(
+            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
+        self.toolbar_holder.pack_end(self.secondary_toolbar, False, True, 0)
+
+        toolbutton = Gtk.ToolItem()
+        self.spinner = Gtk.Spinner()
+        toolbutton.add(self.spinner)
+        self.secondary_toolbar.insert(toolbutton, -1)
+        # Set a minimum size because the spinner requests nothing
+        self.secondary_toolbar.set_size_request(30, -1)
+        self.secondary_toolbar.show_all()
+
         self._menu_context = self.statusbar.get_context_id("Tooltips")
         self.widget.drag_dest_set(
             Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT |
@@ -270,19 +283,21 @@ class MeldWindow(gnomeglade.Component):
     def on_idle(self):
         ret = self.scheduler.iteration()
         if ret and isinstance(ret, string_types):
-            self.statusbar.set_task_status(ret)
+            self.spinner.set_tooltip_text(ret)
 
         pending = self.scheduler.tasks_pending()
         if not pending:
-            self.statusbar.stop_pulse()
-            self.statusbar.set_task_status("")
+            self.spinner.stop()
+            self.spinner.hide()
+            self.spinner.set_tooltip_text("")
             self.idle_hooked = None
             self.actiongroup.get_action("Stop").set_sensitive(False)
         return pending
 
     def on_scheduler_runnable(self, sched):
         if not self.idle_hooked:
-            self.statusbar.start_pulse()
+            self.spinner.show()
+            self.spinner.start()
             self.actiongroup.get_action("Stop").set_sensitive(True)
             self.idle_hooked = GObject.idle_add(self.on_idle)
 
diff --git a/meld/ui/statusbar.py b/meld/ui/statusbar.py
index 9a8691c..b4c742d 100644
--- a/meld/ui/statusbar.py
+++ b/meld/ui/statusbar.py
@@ -24,12 +24,6 @@ Gtk.rc_parse_string(
         GtkStatusbar::shadow-type = GTK_SHADOW_NONE
     }
     class "MeldStatusBar" style "meld-statusbar-style"
-
-    style "meld-progressbar-style" {
-        GtkProgressBar::yspacing = 0
-        GtkProgressBar::min-horizontal-bar-height = 14
-    }
-    widget "*.MeldStatusBar.*.GtkProgressBar" style "meld-progressbar-style"
     """)
 
 
@@ -40,38 +34,10 @@ class MeldStatusBar(Gtk.Statusbar):
         GObject.GObject.__init__(self)
         self.props.spacing = 6
 
-        if hasattr(self, "get_message_area"):
-            # FIXME: added in 2.20, but not in the corresponding pyGtk. Use this if available
-            hbox = self.get_message_area()
-            label = hbox.get_children()[0]
-        else:
-            frame = self.get_children()[0]
-            self.set_child_packing(frame, False, False, 0, Gtk.PACK_START)
-            child = frame.get_child()
-            # Internal GTK widgetry changed when get_message_area was added.
-            if not isinstance(child, Gtk.HBox):
-                hbox = Gtk.HBox(False, 4)
-                child.reparent(hbox)
-                frame.add(hbox)
-                hbox.show()
-                label = child
-            else:
-                hbox = child
-                label = hbox.get_children()[0]
+        hbox = self.get_message_area()
+        label = hbox.get_children()[0]
         hbox.props.spacing = 6
         label.props.ellipsize = Pango.EllipsizeMode.NONE
-
-        self.progress = Gtk.ProgressBar()
-        self.progress.props.pulse_step = 0.02
-        self.progress.props.ellipsize = Pango.EllipsizeMode.END
-        self.progress.set_size_request(200, -1)
-        progress_font = self.get_style_context().get_font(
-            Gtk.StateFlags.NORMAL)
-        progress_font.set_size(progress_font.get_size() - 2 * Pango.SCALE)
-        self.progress.modify_font(progress_font)
-        hbox.pack_start(self.progress, False, True, 0)
-        self.progress.show()
-
         hbox.remove(label)
         hbox.pack_start(label, True, True, 0)
 
@@ -82,26 +48,6 @@ class MeldStatusBar(Gtk.Statusbar):
         self.pack_start(alignment, True, True, 0)
         alignment.show()
 
-        self.timeout_source = None
-
-    def start_pulse(self):
-        self.progress.show()
-        if self.timeout_source is None:
-            def pulse():
-                self.progress.pulse()
-                return True
-            self.timeout_source = GObject.timeout_add(50, pulse)
-
-    def stop_pulse(self):
-        if self.timeout_source is not None:
-            GObject.source_remove(self.timeout_source)
-            self.timeout_source = None
-        self.progress.set_fraction(0)
-        self.progress.hide()
-
-    def set_task_status(self, status):
-        self.progress.set_text(status)
-
     def set_info_box(self, widgets):
         for child in self.info_box.get_children():
             self.info_box.remove(child)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]