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

Subscribers

People subscribed via source and target branches