Changeset b71e79590601d436af5201f690ba38fcf2f5126b
- Timestamp:
- 06/12/08 01:23:53 (4 years ago)
- Author:
- Lincoln de Sousa <lincoln@…>
- Children:
- 48e43cb692421e90bb2294a6dc6d91df7633560c
- Parents:
- b68bc8adac4e5424fb75808d26c2e75e34a5e70b
- git-committer:
- Lincoln de Sousa <lincoln@…> (06/12/08 01:23:53)
- Message:
-
changing the way of naming tabs, adding a context menu
to each tab with rename and close features (close is broken)
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5d1bd30
|
rb71e795
|
|
| | 1 | 2008-06-11 Lincoln de Sousa <lincoln@minaslivre.org> |
| | 2 | |
| | 3 | * data/guake.glade: Adding the tab-menu widget. |
| | 4 | |
| | 5 | * src/guake.py: Code cleanup and comments added. |
| | 6 | |
| | 7 | * src/guake.py (Guake): Adding a context menu to each tab with |
| | 8 | rename and close options (close is broken for a while =). |
| | 9 | |
| 1 | 10 | 2008-06-11 Lincoln de Sousa <lincoln@minaslivre.org> |
| 2 | 11 | |
-
|
r5d1bd30
|
rb71e795
|
|
| 160 | 160 | <widget class="GtkImage" id="menu-item-image1"> |
| 161 | 161 | <property name="stock">gtk-close</property> |
| 162 | | <property name="icon-size">1</property> |
| | 162 | <property name="icon_size">1</property> |
| 163 | 163 | </widget> |
| 164 | 164 | </child> |
| … |
… |
|
| 175 | 175 | </child> |
| 176 | 176 | </widget> |
| | 177 | <widget class="GtkMenu" id="tab-menu"> |
| | 178 | <property name="visible">True</property> |
| | 179 | <child> |
| | 180 | <widget class="GtkImageMenuItem" id="rename"> |
| | 181 | <property name="visible">True</property> |
| | 182 | <property name="label" translatable="yes">Rename</property> |
| | 183 | <property name="use_underline">True</property> |
| | 184 | <signal name="activate" handler="on_rename_activate"/> |
| | 185 | <child internal-child="image"> |
| | 186 | <widget class="GtkImage" id="menu-item-image3"> |
| | 187 | <property name="visible">True</property> |
| | 188 | <property name="stock">gtk-edit</property> |
| | 189 | <property name="icon_size">1</property> |
| | 190 | </widget> |
| | 191 | </child> |
| | 192 | </widget> |
| | 193 | </child> |
| | 194 | <child> |
| | 195 | <widget class="GtkImageMenuItem" id="close"> |
| | 196 | <property name="visible">True</property> |
| | 197 | <property name="label" translatable="yes">Close</property> |
| | 198 | <property name="use_underline">True</property> |
| | 199 | <signal name="activate" handler="on_close_activate"/> |
| | 200 | <child internal-child="image"> |
| | 201 | <widget class="GtkImage" id="menu-item-image2"> |
| | 202 | <property name="visible">True</property> |
| | 203 | <property name="stock">gtk-close</property> |
| | 204 | <property name="icon_size">1</property> |
| | 205 | </widget> |
| | 206 | </child> |
| | 207 | </widget> |
| | 208 | </child> |
| | 209 | </widget> |
| 177 | 210 | </glade-interface> |
-
|
rb68bc8a
|
rb71e795
|
|
| 434 | 434 | self.pid_list = [] |
| 435 | 435 | |
| | 436 | # It's intended to know which tab was selected to |
| | 437 | # close/rename. This attribute will be set in |
| | 438 | # self.show_tab_menu |
| | 439 | self.selected_tab = None |
| | 440 | |
| | 441 | # holds the number of created tabs. This counter will not be |
| | 442 | # reset to avoid problems of repeated tab names. |
| | 443 | self.tab_counter = 0 |
| | 444 | |
| 436 | 445 | # holds visibility/fullscreen status =) |
| 437 | 446 | self.visible = False |
| … |
… |
|
| 478 | 487 | if event.button == 3: |
| 479 | 488 | context_menu.popup(None, None, None, 3, gtk.get_current_event_time()) |
| | 489 | |
| | 490 | def show_tab_menu(self, target, event): |
| | 491 | if event.button == 3: |
| | 492 | self.selected_tab = target |
| | 493 | menu = self.get_widget('tab-menu') |
| | 494 | menu.popup(None, None, None, 3, event.get_time()) |
| | 495 | self.set_terminal_focus() |
| 480 | 496 | |
| 481 | 497 | # -- methods exclusivelly called by dbus interface -- |
| … |
… |
|
| 691 | 707 | def on_terminal_exited(self, term, widget): |
| 692 | 708 | self.delete_tab(self.notebook.page_num(widget)) |
| 693 | | |
| | 709 | |
| | 710 | def on_rename_activate(self, *args): |
| | 711 | entry = gtk.Entry() |
| | 712 | entry.set_text(self.selected_tab.get_label()) |
| | 713 | |
| | 714 | vbox = gtk.VBox() |
| | 715 | vbox.pack_start(entry) |
| | 716 | vbox.set_border_width(6) |
| | 717 | vbox.show_all() |
| | 718 | |
| | 719 | dialog = gtk.Dialog("Rename tab", |
| | 720 | self.window, |
| | 721 | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, |
| | 722 | (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, |
| | 723 | gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) |
| | 724 | |
| | 725 | dialog.set_size_request(300, -1) |
| | 726 | dialog.vbox.pack_start(vbox) |
| | 727 | dialog.set_border_width(4) |
| | 728 | dialog.set_has_separator(False) |
| | 729 | dialog.set_default_response(gtk.RESPONSE_ACCEPT) |
| | 730 | |
| | 731 | response = dialog.run() |
| | 732 | dialog.destroy() |
| | 733 | |
| | 734 | if response == gtk.RESPONSE_ACCEPT: |
| | 735 | self.selected_tab.set_label(entry.get_text()) |
| | 736 | |
| | 737 | self.set_terminal_focus() |
| | 738 | |
| | 739 | def on_close_activate(self, *args): |
| | 740 | self.on_context_close_tab_activate() |
| | 741 | |
| 694 | 742 | # -- Context menu callbacks -- |
| 695 | 743 | |
| … |
… |
|
| 734 | 782 | parent = tabs and tabs[0] or None |
| 735 | 783 | |
| 736 | | bnt = gtk.RadioButton(group=parent, |
| 737 | | label=_('Terminal %s') % (last_added+1)) |
| | 784 | self.tab_counter += 1 |
| | 785 | |
| | 786 | label = _('Terminal %s') % self.tab_counter |
| | 787 | bnt = gtk.RadioButton(group=parent, label=label) |
| | 788 | |
| | 789 | bnt.set_tooltip_text(self.term_list[last_added].get_window_title()) |
| | 790 | bnt.set_property('can-focus', False) |
| | 791 | bnt.set_property('draw-indicator', False) |
| | 792 | |
| | 793 | bnt.connect('button-press-event', self.show_tab_menu) |
| 738 | 794 | bnt.connect('clicked', lambda *x: |
| 739 | | self.notebook.set_current_page (len(tabs))) |
| 740 | | bnt.set_property('draw-indicator', False) |
| | 795 | self.notebook.set_current_page (last_added)) |
| 741 | 796 | bnt.show() |
| 742 | 797 | |