Merge lp:~ubunt-u-markbenjamin/indicator-applet/reorient into lp:indicator-applet/0.4

Proposed by MarkieB
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ubunt-u-markbenjamin/indicator-applet/reorient
Merge into: lp:indicator-applet/0.4
Diff against target: 270 lines (+115/-24)
1 file modified
src/applet-main.c (+115/-24)
To merge this branch: bzr merge lp:~ubunt-u-markbenjamin/indicator-applet/reorient
Reviewer Review Type Date Requested Status
Sense Egbert Hofstede (community) Approve
Indicator Applet Developers review of newbie ubuntu developer :) Pending
Review via email: mp+23524@code.launchpad.net

Description of the change

branch to address bugs #498182, #412111 to allow vertical orientation of indicator-applet-* applets;

so far no actual rotation of labels, simply vertical stacking of icons/widgets

patch introduces 2 relatively innocuous static globals [of Enums] to handle state during a session, would need additional code to allow persistence across sessions;

may need I18n;

features 'automatic' reorientation when the containing panel is moved, as well as 'override' in a new properties mini-window; current implementation is that 'automatic' reorientation causes a 90°* rotation however the override is set, override simply allows an 'offset' from the 'normal' rotation

* in fact there are 2 orientations, ltr, ttb; thinking that as we're talking images not words, ltr is equally acceptable in an rtl environment

further revisions should include
implementation of properties generally / persistence; see for instance #439775. #425552, #88963
actual rotation of labels [notably name] as happens for the main menu https://bugs.launchpad.net/ubuntu/+source/indicator-session/+bug/498182/comments/2

As I'm new here, I dare say some of my coding style merits some review; I'll be looking into the I18n aspect as it's unclear precisely how that works here

To post a comment you must log in.
354. By MarkieB

variable multi-component orientation - needs desktop session restart to have effect though

355. By MarkieB

now multi-component orientation changes in a similar manner to the orientation of the various widgets contained in the applet, no need for panel restart

356. By MarkieB

add rotation of labels

357. By MarkieB

add I18n of labels in [tentative] prefs mini-window

Revision history for this message
MarkieB (ubunt-u-markbenjamin) wrote :
358. By MarkieB

label rotation according to preferences - as well as location

Revision history for this message
Kevin Turner (keturn) wrote :

Nice! This patch is sufficient to make the indicator applet functional on my vertical panel, I don't have the "Why don't I have a 'Log Out' button anymore?" experience with this.

I'd leave out the properties dialog for this branch. A user-configurable horizontal/vertical widget doesn't seem necessary if the applet correctly understands its orientation. (If you do leave it in, you've got an unused radio_group variable in properties_cb.)

Note that I'm not a maintainer, I'm just another user who with a vertical panel who would hate to see Lucid ship with this "hey where'd the volume panel widget go" bug.

359. By MarkieB

without properties in current iteration

360. By MarkieB

more elegant handling of data connections when reorienting

361. By MarkieB

more elegant handling of data connections when reorienting - no need for the enum

362. By MarkieB

suppress spurious 'conflict' in header includes arising from merger 352.1.2

Revision history for this message
MarkieB (ubunt-u-markbenjamin) wrote :

> I'd leave out the properties dialog for this branch. A user-configurable
> horizontal/vertical widget doesn't seem necessary if the applet correctly
> understands its orientation. (If you do leave it in, you've got an unused
> radio_group variable in properties_cb.)

Done :-)

> Note that I'm not a maintainer, I'm just another user who with a vertical
> panel who would hate to see Lucid ship with this "hey where'd the volume panel
> widget go" bug.

Even the 'how do I switch the computer off' bug that was how I noticed it :-)

thanks for the comments

Best

Mark

363. By MarkieB

resolve compiler warning changes

Revision history for this message
Sense Egbert Hofstede (sense) wrote :

After running './auotgen.sh' this branch fails when you try to run 'debuild' on my system. I'm using the Debian folder from lp:~ubuntu-desktop/indicator-application/ubuntu Should I change something to the packaging, or did this branch break the build?

This is the error I'm getting at the end of the 'debuild' output:

DEB_MAKE_CHECK_TARGET unset, not running checks
make -C build-python2.6/bindings/python
make: *** build-python2.6/bindings/python: File or folder doesn't exist. Stopped.
make: *** [build-stamp-python2.6] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
debuild: fatal error at line 1340:
dpkg-buildpackage -rfakeroot -D -us -uc failed

Revision history for this message
Ted Gould (ted) wrote :

MarkieB,

Looking through the code it looks like it's going in the right
direction. If you could merge trunk into your branch that should clean
up the conflict that I think is effecting Sense. I'd be nice to get a
clean diff to examine as well.

  --Ted

Revision history for this message
MarkieB (ubunt-u-markbenjamin) wrote :

Hi Ted,

I think I see the trouble; that I have derived the branch from / proposed merging to lp:indicator-applet, not from lp:~ubuntu-desktop/indicator-application/ubuntu ?

As there is no debian folder in the source tree I have, debuild reminds me of that :-) while the result of

$ bzr merge
Merging from remembered parent location http://bazaar.launchpad.net/~indicator-applet-developers/indicator-applet/applet/
Nothing to do.

Revision history for this message
MarkieB (ubunt-u-markbenjamin) wrote :

Most of all, it looks to me as though Sense's difficulty is that he's derived the debian folder from indicator-application/ubuntu, not indicator-applet/ubuntu, hence the python folder reference [inter alia]

$ get-build-deps indicator-application
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  cli-common-dev gtk-sharp2-gapi libffi-dev libglib2.0-cil-dev libgluezilla libgtk2.0-cil-dev
  libjson-glib-dev libmono-accessibility1.0-cil libmono-accessibility2.0-cil libmono-bytefx0.7.6.1-cil
  libmono-bytefx0.7.6.2-cil libmono-c5-1.0-cil libmono-cairo1.0-cil libmono-cecil-private-cil
  libmono-cil-dev libmono-corlib1.0-cil libmono-cscompmgd7.0-cil libmono-cscompmgd8.0-cil
  libmono-data-tds1.0-cil libmono-data1.0-cil libmono-data2.0-cil libmono-db2-1.0-cil libmono-dev
  libmono-getoptions1.0-cil libmono-getoptions2.0-cil libmono-i18n-west1.0-cil libmono-i18n1.0-cil
  libmono-i18n2.0-cil libmono-ldap1.0-cil libmono-ldap2.0-cil libmono-management2.0-cil
  libmono-messaging-rabbitmq2.0-cil libmono-messaging2.0-cil libmono-microsoft-build2.0-cil
  libmono-microsoft7.0-cil libmono-microsoft8.0-cil libmono-npgsql1.0-cil libmono-npgsql2.0-cil
  libmono-oracle1.0-cil libmono-oracle2.0-cil libmono-peapi1.0-cil libmono-peapi2.0-cil
  libmono-posix1.0-cil libmono-rabbitmq2.0-cil libmono-relaxng1.0-cil libmono-relaxng2.0-cil
  libmono-security1.0-cil libmono-sharpzip0.6-cil libmono-sharpzip0.84-cil libmono-sharpzip2.6-cil
  libmono-simd2.0-cil libmono-sqlite1.0-cil libmono-system-data1.0-cil libmono-system-ldap1.0-cil
  libmono-system-ldap2.0-cil libmono-system-messaging1.0-cil libmono-system-messaging2.0-cil
  libmono-system-runtime1.0-cil libmono-system-web-mvc1.0-cil libmono-system-web1.0-cil
  libmono-system1.0-cil libmono-wcf3.0-cil libmono-webbrowser0.5-cil libmono-winforms1.0-cil
  libmono-winforms2.0-cil libmono0 libmono1.0-cil libnunit-cil-dev libxml-dom-perl libxml-perl
  libxml-regexp-perl mono-2.0-devel mono-csharp-shell mono-devel mono-gmcs mono-utils python-all
  python-all-dev python-gobject-dev python-gtk2-dev python-gtk2-doc
0 upgraded, 81 newly installed, 0 to remove and 5 not upgraded.
Need to get 17.5MB of archives.
After this operation, 66.6MB of additional disk space will be used.

Revision history for this message
MarkieB (ubunt-u-markbenjamin) wrote :

@Sense, for a branch that should debuild [although it seems the changes to save compiler warnings / keybinder improvements are not yet implemented in that branch's parent]

try https://code.launchpad.net/~ubunt-u-markbenjamin/indicator-applet/reorient-ubuntu

you may need to change signing keys etcetera for debuild to complete successfully

@Ted, My thinking would be that the changes be merged into the master branch then normally the master branch would be merged [including the compiler warning changes] to the ubuntu package branch?

Revision history for this message
Sense Egbert Hofstede (sense) wrote :

Apologises for my mistake. The reason for debuild failing was very simple: I had copied the debian folder from 'indicator-application', whereas your branch is 'indicator-applet'.

I've now been able to test it and I can say it works perfectly. I'm reviewing this as 'Approved' to indicate my approval, but please don't think I have anything to say about this, I'm not a member of the development team. ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/applet-main.c'
2--- src/applet-main.c 2010-04-16 19:56:30 +0000
3+++ src/applet-main.c 2010-04-19 02:24:24 +0000
4@@ -38,6 +38,9 @@
5 NULL
6 };
7
8+static GtkPackDirection packdirection;
9+static PanelAppletOrient orient;
10+
11 #define MENU_DATA_INDICATOR_OBJECT "indicator-object"
12 #define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
13
14@@ -45,7 +48,6 @@
15
16 static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
17
18-
19 static void cw_panel_background_changed (PanelApplet *applet,
20 PanelAppletBackgroundType type,
21 GdkColor *colour,
22@@ -178,23 +180,37 @@
23 }
24
25 static void
26-entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menu)
27+entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
28 {
29 g_debug("Signal: Entry Added");
30
31 GtkWidget * menuitem = gtk_menu_item_new();
32- GtkWidget * hbox = gtk_hbox_new(FALSE, 3);
33+ GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
34+ gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3);
35
36- g_object_set_data (G_OBJECT (menuitem), "indicator", io);
37+ g_object_set_data (G_OBJECT (menuitem), "indicator", io);
38+ g_object_set_data (G_OBJECT (menuitem), "box", box);
39
40 if (entry->image != NULL) {
41- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->image), FALSE, FALSE, 0);
42+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 0);
43 }
44 if (entry->label != NULL) {
45- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->label), FALSE, FALSE, 0);
46+ switch(packdirection) {
47+ case GTK_PACK_DIRECTION_LTR:
48+ gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
49+ break;
50+ case GTK_PACK_DIRECTION_TTB:
51+ gtk_label_set_angle(GTK_LABEL(entry->label),
52+ (orient == PANEL_APPLET_ORIENT_LEFT) ?
53+ 270.0 : 90.0);
54+ break;
55+ default:
56+ break;
57+ }
58+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 0);
59 }
60- gtk_container_add(GTK_CONTAINER(menuitem), hbox);
61- gtk_widget_show(hbox);
62+ gtk_container_add(GTK_CONTAINER(menuitem), box);
63+ gtk_widget_show(box);
64
65 if (entry->menu != NULL) {
66 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
67@@ -206,9 +222,9 @@
68 position.menupos = 0;
69 position.found = FALSE;
70
71- gtk_container_foreach(GTK_CONTAINER(menu), place_in_menu, &position);
72+ gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
73
74- gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, position.menupos);
75+ gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
76 gtk_widget_show(menuitem);
77
78 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry);
79@@ -264,13 +280,13 @@
80 entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
81 gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
82 {
83- GtkWidget * menu = GTK_WIDGET(user_data);
84+ GtkWidget * menubar = GTK_WIDGET(user_data);
85
86 gpointer array[2];
87 array[0] = entry;
88 array[1] = NULL;
89
90- gtk_container_foreach(GTK_CONTAINER(user_data), entry_moved_find_cb, array);
91+ gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
92 if (array[1] == NULL) {
93 g_warning("Moving an entry that isn't in our menus.");
94 return;
95@@ -278,7 +294,7 @@
96
97 GtkWidget * mi = GTK_WIDGET(array[1]);
98 g_object_ref(G_OBJECT(mi));
99- gtk_container_remove(GTK_CONTAINER(user_data), mi);
100+ gtk_container_remove(GTK_CONTAINER(menubar), mi);
101
102 incoming_position_t position;
103 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
104@@ -286,16 +302,16 @@
105 position.menupos = 0;
106 position.found = FALSE;
107
108- gtk_container_foreach(GTK_CONTAINER(menu), place_in_menu, &position);
109+ gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
110
111- gtk_menu_shell_insert(GTK_MENU_SHELL(menu), mi, position.menupos);
112+ gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
113 g_object_unref(G_OBJECT(mi));
114
115 return;
116 }
117
118 static gboolean
119-load_module (const gchar * name, GtkWidget * menu)
120+load_module (const gchar * name, GtkWidget * menubar)
121 {
122 g_debug("Looking at Module: %s", name);
123 g_return_val_if_fail(name != NULL, FALSE);
124@@ -314,10 +330,10 @@
125 /* Attach the 'name' to the object */
126 g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name)));
127
128- /* Connect to it's signals */
129- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menu);
130- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menu);
131- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menu);
132+ /* Connect to its signals */
133+ g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);
134+ g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar);
135+ g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar);
136
137 /* Work on the entries */
138 GList * entries = indicator_object_get_entries(io);
139@@ -325,7 +341,7 @@
140
141 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
142 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
143- entry_added(io, entrydata, menu);
144+ entry_added(io, entrydata, menubar);
145 }
146
147 g_list_free(entries);
148@@ -445,6 +461,72 @@
149 return;
150 }
151
152+static gboolean
153+swap_orient_cb (GtkWidget *item, gpointer data)
154+{
155+ GtkWidget *from = (GtkWidget *) data;
156+ GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");
157+ g_object_ref(G_OBJECT(item));
158+ gtk_container_remove(GTK_CONTAINER(from), item);
159+ if (GTK_IS_LABEL(item)) {
160+ switch(packdirection) {
161+ case GTK_PACK_DIRECTION_LTR:
162+ gtk_label_set_angle(GTK_LABEL(item), 0.0);
163+ break;
164+ case GTK_PACK_DIRECTION_TTB:
165+ gtk_label_set_angle(GTK_LABEL(item),
166+ (orient == PANEL_APPLET_ORIENT_LEFT) ?
167+ 270.0 : 90.0);
168+ break;
169+ default:
170+ break;
171+ }
172+ }
173+ gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);
174+ return TRUE;
175+}
176+
177+static gboolean
178+reorient_box_cb (GtkWidget *menuitem, gpointer data)
179+{
180+ GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), "box");
181+ GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
182+ gtk_hbox_new(FALSE, 0) : gtk_vbox_new(FALSE, 0);
183+ g_object_set_data(G_OBJECT(from), "to", to);
184+ gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,
185+ from);
186+ gtk_container_remove(GTK_CONTAINER(menuitem), from);
187+ gtk_container_add(GTK_CONTAINER(menuitem), to);
188+ g_object_set_data(G_OBJECT(menuitem), "box", to);
189+ gtk_widget_show_all(menuitem);
190+ return TRUE;
191+}
192+
193+static gboolean
194+panelapplet_reorient_cb (GtkWidget *applet, PanelAppletOrient neworient,
195+ gpointer data)
196+{
197+ GtkWidget *menubar = (GtkWidget *)data;
198+ if ((((neworient == PANEL_APPLET_ORIENT_UP) ||
199+ (neworient == PANEL_APPLET_ORIENT_DOWN)) &&
200+ ((orient == PANEL_APPLET_ORIENT_LEFT) ||
201+ (orient == PANEL_APPLET_ORIENT_RIGHT))) ||
202+ (((neworient == PANEL_APPLET_ORIENT_LEFT) ||
203+ (neworient == PANEL_APPLET_ORIENT_RIGHT)) &&
204+ ((orient == PANEL_APPLET_ORIENT_UP) ||
205+ (orient == PANEL_APPLET_ORIENT_DOWN)))) {
206+ packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
207+ GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
208+ gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
209+ packdirection);
210+ orient = neworient;
211+ gtk_container_foreach(GTK_CONTAINER(menubar),
212+ (GtkCallback)reorient_box_cb, NULL);
213+ }
214+ orient = neworient;
215+ return FALSE;
216+}
217+
218 #ifdef N_
219 #undef N_
220 #endif
221@@ -519,9 +601,9 @@
222 "<menuitem name=\"About Item\" verb=\"IndicatorAppletAbout\" _label=\"" N_("_About") "\" pixtype=\"stock\" pixname=\"gtk-about\"/>"
223 "</popup>";
224
225+ static gboolean first_time = FALSE;
226 GtkWidget *menubar;
227 gint indicators_loaded = 0;
228- static gboolean first_time = FALSE;
229
230 #ifdef INDICATOR_APPLET_SESSION
231 /* check if we are running stracciatella session */
232@@ -552,7 +634,8 @@
233 /* Set panel options */
234 gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
235 panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);
236- panel_applet_setup_menu(applet, menu_xml, menu_verbs, NULL);
237+ menubar = gtk_menu_bar_new();
238+ panel_applet_setup_menu(applet, menu_xml, menu_verbs, menubar);
239 #ifdef INDICATOR_APPLET
240 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
241 "indicator-applet");
242@@ -599,12 +682,19 @@
243 gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
244
245 /* Build menubar */
246- menubar = gtk_menu_bar_new();
247+ orient = (panel_applet_get_orient(applet));
248+ packdirection = ((orient == PANEL_APPLET_ORIENT_UP) ||
249+ (orient == PANEL_APPLET_ORIENT_DOWN)) ?
250+ GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
251+ gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
252+ packdirection);
253 GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS);
254 gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
255 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
256 g_signal_connect(menubar, "scroll-event", G_CALLBACK (menubar_scroll), NULL);
257 g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar);
258+ g_signal_connect(applet, "change-orient",
259+ G_CALLBACK(panelapplet_reorient_cb), menubar);
260 gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
261
262 /* Add in filter func */
263@@ -654,6 +744,7 @@
264 gtk_widget_show(GTK_WIDGET(applet));
265
266 return TRUE;
267+
268 }
269
270 static void

Subscribers

People subscribed via source and target branches

to status/vote changes: