Merge lp:~quickly-committers/quickly/nautilus-bar-updates into lp:quickly

Proposed by Michael Terry
Status: Needs review
Proposed branch: lp:~quickly-committers/quickly/nautilus-bar-updates
Merge into: lp:quickly
Diff against target: 160 lines (+30/-37)
1 file modified
ubuntudevbar.py (+30/-37)
To merge this branch: bzr merge lp:~quickly-committers/quickly/nautilus-bar-updates
Reviewer Review Type Date Requested Status
Quickly Developers Pending
Review via email: mp+67070@code.launchpad.net

Description of the change

This is an update to the ubuntudevbar.py nautilus extension we have. It updates it to work with nautilus 3.0 (and thus uses gtk3, pygi, and the latest nautilus-python from oneiric).

The bar is still kinda crappy. It takes up lots of space, seems to slow down nautilus's first launch, and some buttons don't seem to work right (like edit) despite me making sure that we are running the command behind the scenes.

This will get the extension back to where it once was (in a runnable state), but I suspect that we should stop shipping it in the Ubuntu packaging until yet more work is done on it.

Note that this is relatively easy to test:
1) Install python-nautilus from oneiric
2) Drop ubuntudevbar.py into ~/.local/share/nautilus-python/extensions/
3) Install the quickly icon from data/icons/48x48/apps/ into /usr/share/icons/hicolor/48x48/apps and regenerate the icon cache (I generally just reinstall some app like so: "sudo apt-get install deja-dup --reinstall" because I can never remember the command)

To post a comment you must log in.

Unmerged revisions

623. By Michael Terry

make nautilus bar mostly work

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'data/icons/48x48'
2=== added directory 'data/icons/48x48/apps'
3=== renamed file 'data/icons/quickly48x48.png' => 'data/icons/48x48/apps/quickly.png'
4=== modified file 'ubuntudevbar.py'
5--- ubuntudevbar.py 2010-12-02 16:03:30 +0000
6+++ ubuntudevbar.py 2011-07-06 18:13:31 +0000
7@@ -1,10 +1,8 @@
8 #!/usr/bin/python
9 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
10
11-import nautilus
12-import pygtk
13-import gtk
14-import vte
15+import gobject
16+from gi.repository import GLib, Gtk, Nautilus, Vte # pylint: disable=E0611
17
18 try:
19 from quickly import api as quicklyapi
20@@ -16,11 +14,9 @@
21 command_order = ('create', 'edit', 'design', 'save', 'package', 'share', 'release', 'tutorial')
22 command_without_output = ('edit', 'design', 'save', 'tutorial')
23
24-class DevBar(nautilus.LocationWidgetProvider):
25- pass
26+class DevBar(gobject.GObject, Nautilus.LocationWidgetProvider):
27 def __init__(self):
28 self.bars = {}
29- pass
30
31 def get_widget(self, uri, window):
32 """Draw Ubuntu dev widgets depending on context
33@@ -56,7 +52,7 @@
34 if command.name not in command_order:
35 sorted_commands.append(command)
36
37- bar.add_image("/usr/share/quickly/icons/quickly48x48.png", current_template)
38+ bar.add_image("quickly", current_template)
39 commands_already_listed = []
40 for command in sorted_commands:
41 if command.name in commands_already_listed:
42@@ -73,7 +69,7 @@
43 return bar
44
45
46-class UbuntuDevBar(gtk.HBox):
47+class UbuntuDevBar(Gtk.HBox):
48 '''Container to all buttons in nautilus.'''
49
50 def __init__(self, *args, **kwargs):
51@@ -87,62 +83,58 @@
52
53 def add_image(self, image_name, subtitle=None):
54 """Add an image to the bar and a subtitle below if one."""
55- self._logo = gtk.VBox(homogeneous=False, spacing=0)
56- self._image = gtk.Image()
57- self._logo.pack_start(self._image, expand=True, fill=True, padding=0)
58- pixbuf = gtk.gdk.pixbuf_new_from_file(image_name)
59- if pixbuf:
60- scaled_pixbuf = pixbuf.scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR)
61- self._image.set_from_pixbuf(scaled_pixbuf)
62- self._image.show()
63+ self._logo = Gtk.VBox(homogeneous=False, spacing=0)
64+ self._image = Gtk.Image.new_from_icon_name(image_name, Gtk.IconSize.DIALOG)
65+ self._logo.pack_start(self._image, True, True, 0)
66+ self._image.show()
67 if subtitle:
68- self._subtitle = gtk.Label(subtitle)
69- self._logo.pack_start(self._subtitle, expand=True, fill=True, padding=0)
70+ self._subtitle = Gtk.Label(subtitle)
71+ self._logo.pack_start(self._subtitle, True, True, 0)
72 self._subtitle.show()
73- self.pack_start(self._logo, expand=False, fill=False, padding=0)
74+ self.pack_start(self._logo, False, False, 0)
75 self._logo.show()
76
77 def add_button(self, signal, label, command_line, path, icon=None):
78 """Adds a new new button to the bar widget."""
79- button = gtk.Button()
80+ button = Gtk.Button()
81 button.connect("clicked", signal, command_line, path)
82 button.set_label(label)
83 if icon:
84- image = gtk.Image()
85+ image = Gtk.Image()
86 image.set_from_file(icon)
87 settings = button.get_settings()
88 settings.set_property("gtk-button-images", True)
89 button.set_image(image)
90 button.show()
91- vbox = gtk.VBox(homogeneous=False, spacing=0)
92- vbox.pack_start(button, expand=True, fill=False, padding=0)
93+ vbox = Gtk.VBox(homogeneous=False, spacing=0)
94+ vbox.pack_start(button, True, False, 0)
95 vbox.show()
96 self._buttons.append(button)
97- self.pack_start(vbox, expand=False, fill=False, padding=0)
98+ self.pack_start(vbox, False, False, 0)
99
100 def add_button_with_selection(self, signal, label, selection, command_line,
101 path, icon=None):
102 """Adds a new button with a multiple selection widget"""
103- combobox = gtk.combo_box_new_text()
104+ combobox = Gtk.ComboBoxText()
105 for item in selection:
106 combobox.append_text(item)
107 combobox.show()
108- button = gtk.Button()
109+ button = Gtk.Button()
110 button.set_label(label)
111 button.connect("clicked", signal, command_line, path, combobox)
112 if icon:
113- image = gtk.Image()
114+ image = Gtk.Image()
115 image.set_from_file(icon)
116 settings = button.get_settings()
117 settings.set_property("gtk-button-images", True)
118 button.set_image(image)
119 button.show()
120- vbox = gtk.VBox(homogeneous=False, spacing=0)
121- vbox.pack_start(combobox, expand=True, fill=False, padding=0)
122- vbox.pack_start(button, expand=True, fill=False, padding=0)
123+ vbox = Gtk.VBox(homogeneous=False, spacing=0)
124+ vbox.pack_start(combobox, True, False, 0)
125+ vbox.pack_start(button, True, False, 0)
126 self._buttons_with_selection.append((combobox,button))
127 vbox.show()
128- self.pack_start(vbox, expand=False, fill=False, padding=0)
129+ self.pack_start(vbox, False, False, 0)
130
131 def click_on_quickly_button(self, widget, *argscommand):
132 """Quickly buttons can have a template associated"""
133@@ -158,13 +150,14 @@
134 except IndexError:
135 pass
136 command = self.add_additional_actions(command)
137- v = vte.Terminal()
138- v.fork_command(command[0], argv=command, directory=argscommand[1])
139- window = gtk.Window()
140+ v = Vte.Terminal()
141+ v.fork_command_full(Vte.PtyFlags.DEFAULT, argscommand[1], command,
142+ None, GLib.SpawnFlags.SEARCH_PATH, None, None)
143+ window = Gtk.Window()
144 window.add(v)
145 if command[1] not in command_without_output:
146 window.show_all()
147- gtk.main()
148+ Gtk.main()
149
150 def add_additional_actions(self, command):
151 """Some commands needs additional args, filter them here"""
152@@ -172,7 +165,7 @@
153 # TODO: Add missing prompts module
154 #if command[1] == "create":
155 # response, val = prompts.string("Project Name","Please enter a project name")
156- # if response == gtk.RESPONSE_OK:
157+ # if response == Gtk.ResponseType.OK:
158 # command.append(val)
159
160 return command

Subscribers

People subscribed via source and target branches