~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/widgets/actionbar.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Michael Vogt, Gary Lasker, Nekhelesh Ramananthan, Sebastian Heinlein, Kiwinote
  • Date: 2012-04-10 19:21:21 UTC
  • Revision ID: package-import@ubuntu.com-20120410192121-7eo1shw2hquh8dcu
Tags: 5.1.14.2
[ Michael Vogt ]
* lp:~mvo/software-center/config-tweak:
  - cleanup concerning always having a 'general' section in the cfg file
* lp:~mvo/software-center/pygi-properties-fixes:
  - properly initialize the properties in CellRendererAppView as required
    for pygi, fixes crash on network events (LP: #965937)
* lp:~mvo/software-center/lp977889:
  - fix the disappearing list view sort combobox (LP: #977889)

[ Gary Lasker ]
* lp:~gary-lasker/software-center/recommends-more-button-lp971567:
  - correctly render 'more' button in recommendations panel (LP: #971567)
* lp:~gary-lasker/software-center/show-technical-items-lp955030:
  - make 'show n technical items' appear clickable again (LP: #955030)
* lp:~gary-lasker/software-center/fix-crash-lp969737:
  - fix an intermittent crash that can occur when saving the vertical 
    position of the installed pane treeview on a cache refresh 
    (LP: #969737)
* lp:~gary-lasker/software-center/fix-crash-lp970157:
  - Small fix for a crash that can happen during the installed view 
    treeview initialization (LP: #970157)
* lp:~gary-lasker/software-center/fix-crash-lp968988:
  - Fix crash bug LP: #968988 by making sure that there is always
    a tree_view.selected_row_renderer 
* lp:~gary-lasker/software-center/remember-sort-preference-lp966878:
  - Fix for bug LP: #966878 to not reset the user's sorting preference 
    if they have set one

[ Nekhelesh Ramananthan ]
* lp:~nik90/software-center/add_keywords_new:
  - added keywords to the desktop file for better search criteria
    (LP: #977175)

[ Sebastian Heinlein ]
* lp:~glatzor/software-center/fix-977020:
  - fix software-center error dialogs for errors other than 
    ERROR_INVALID_PACKAGE_FILE and ERROR_UNAUTHENTICATED_PACKAGE 
    (LP: #977020)
  - Allow to repair an incomplete installation (partially fixes 
    LP: #659438)

[ Kiwinote ]
* lp:~kiwinote/software-center/lp951557:
  - don't duplicate text on paste (LP: #951557)

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        super(ActionBar, self).__init__(spacing=self.PADDING)
51
51
        self._btns = Gtk.HBox(spacing=self.PADDING)
52
52
        self._btns.set_border_width(self.PADDING)
53
 
        self._label = Gtk.HBox()
54
 
        self._label.set_border_width(self.PADDING)
 
53
        self._label_hbox = Gtk.HBox()
 
54
        self._label_hbox.set_border_width(self.PADDING)
55
55
        # So that all buttons children right align
56
56
        self._btn_bin = Gtk.Alignment.new(1.0, 0.0, 1.0, 1.0)
57
57
        self._btn_bin.set_padding(0, 0, 0, 10)
58
58
        self._btn_bin.add(self._btns)
59
59
        # Buttons go on the right, labels on the left (in LTR mode)
60
 
        super(ActionBar, self).pack_start(self._label, False, False, 10)
 
60
        super(ActionBar, self).pack_start(self._label_hbox, False, False, 10)
61
61
        super(ActionBar, self).pack_end(self._btn_bin, False, True, 0)
62
62
 
63
63
        # Don't show_all() by default.
64
64
        self.set_no_show_all(True)
65
 
        self._label.show_all()
 
65
        self._label_hbox.show_all()
66
66
        self._btn_bin.show_all()
67
67
        self._visible = False
68
68
 
107
107
                # buttons are removed
108
108
                self.set_size_request(-1, self.get_allocation().height)
109
109
                self._btns.remove(child)
110
 
                if len(children) == 1 and not len(self._label):
 
110
                if len(children) == 1 and not len(self._label_hbox):
111
111
                    # always animate with buttons
112
112
                    self._hide(animate=True)
113
113
                return
128
128
        LOG.debug("got sections '%s'" % sections)
129
129
        self._label_text = text
130
130
 
131
 
        # Unfortunately, gtk has no native method for embedding a link
132
 
        # in a Gtk.Label with non-link elements. To represent the label,
133
 
        # this method makes an eventbox for each link and non-link
134
 
        # section. If the section corresponds to a link, it hooks hover,
135
 
        # unhover, and click behavior to the box.
136
 
        while len(self._label) > len(sections):
137
 
            last = self._label.get_children()[-1]
138
 
            self._label.remove(last)
139
 
        while len(self._label) < len(sections):
140
 
            box = Gtk.EventBox()
141
 
            self._label.pack_start(box, True, True, 0)
142
 
            # Sections alternate between link and non-link types, so
143
 
            # hook up link methods to even sections.
144
 
            if not len(self._label) % 2:
145
 
                box.connect("button-press-event",
146
 
                            self._callback(link_result, link_result_args))
147
 
                box.connect("enter-notify-event", self._hover_link)
148
 
                box.connect("leave-notify-event", self._unhover_link)
 
131
        for i, text_for_label in enumerate(sections):
 
132
            action_bar_item = Gtk.Label(text_for_label)
 
133
            # every second item in the bar is a clickable link,
 
134
            # this is because the text.split("_") earlier (all links
 
135
            # are put into "_foo_"
 
136
            # FIXME: actually remove the "_" and use proper <a href>"
 
137
            #        in the label, but this requires a string change
 
138
            #        so we need to do it after 12.04
 
139
            if not i % 2:
 
140
                markup = text_for_label
 
141
                action_bar_item.set_markup(markup)
 
142
            else:
 
143
                markup = '<a href="">%s</a>' % text_for_label
 
144
                action_bar_item.set_markup(markup)
 
145
                action_bar_item.connect("activate-link",
 
146
                    self._callback(link_result, link_result_args))
 
147
            self._label_hbox.pack_start(action_bar_item, True, True, 0)
149
148
 
150
 
        # Finally, place the text segments in their respective event
151
 
        # boxes. Use pango to underline link segments.
152
 
        for i, box in enumerate(self._label):
153
 
            label = Gtk.Label()
154
 
            markup = sections[i]
155
 
            if i % 2:
156
 
                markup = "<u>%s</u>" % markup
157
 
            label.set_markup(markup)
158
 
            if box.get_child():
159
 
                box.remove(box.get_child())
160
 
            box.add(label)
161
 
            box.show_all()
 
149
        self._label_hbox.show_all()
162
150
        self._show(animate=False)
163
151
 
164
152
    def unset_label(self):
169
157
        self._label_text = ""
170
158
 
171
159
        # Destroy all event boxes holding text segments.
172
 
        while len(self._label):
173
 
            last = self._label.get_children()[-1]
174
 
            self._label.remove(last)
 
160
        while len(self._label_hbox):
 
161
            last = self._label_hbox.get_children()[-1]
 
162
            self._label_hbox.remove(last)
175
163
 
176
164
        window = self.get_window()
177
165
        if window:
355
343
 
356
344
    def perform_lbl():
357
345
        print("Clicked label link")
 
346
        return True
358
347
 
359
348
    def add_func(*args):
360
349
        global btns
368
357
            btns -= 1
369
358
 
370
359
    def set_func(*args):
371
 
        bar.set_label("This label _has a link", perform_lbl)
 
360
        # example with multiple links
 
361
        bar.set_label("This label _has a link_ and _another one_", perform_lbl)
372
362
 
373
363
    def unset_func(*args):
374
364
        bar.unset_label()