~xubuntu-dev/ubiquity/lp1437180_feh

« back to all changes in this revision

Viewing changes to src/panel/panel.c

  • Committer: Colin Watson
  • Date: 2012-04-30 23:38:41 UTC
  • mfrom: (5402 trunk)
  • mto: This revision was merged to the branch mainline in revision 5403.
  • Revision ID: cjwatson@canonical.com-20120430233841-xb0qsk46lnhski7m
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#define ENTRY_DATA_NAME "indicator-custom-entry-data"
35
35
 
 
36
 
 
37
static gchar * indicator_order[] = {
 
38
  "indicator-session-devices",
 
39
  "indicator-sound",
 
40
  "nm-applet",
 
41
  "bluetooth-manager",
 
42
  "ubiquity",
 
43
  "keyboard",
 
44
  NULL
 
45
};
 
46
 
36
47
enum {
37
48
        STRUT_LEFT = 0,
38
49
        STRUT_RIGHT = 1,
94
105
  XChangeProperty (display, window, net_wm_strut_partial,
95
106
                   XA_CARDINAL, 32, PropModeReplace,
96
107
                   (guchar *) &struts, 12);
97
 
  gdk_error_trap_pop ();
 
108
  gdk_error_trap_pop_ignored ();
98
109
}
99
110
 
100
111
/* Stolen from indicator-loader.c in unity. */
104
115
    g_debug("Signal: Entry Added");
105
116
 
106
117
    GtkWidget * menuitem = gtk_menu_item_new();
107
 
    GtkWidget * hbox = gtk_hbox_new(FALSE, 3);
 
118
    GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
108
119
 
109
120
    if (entry->image != NULL) {
110
121
        gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->image), FALSE, FALSE, 0);
111
122
    }
112
 
    if (entry->label != NULL) {
113
 
        gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->label), FALSE, FALSE, 0);
114
 
    }
115
123
    gtk_container_add(GTK_CONTAINER(menuitem), hbox);
116
124
    gtk_widget_show(hbox);
117
125
 
119
127
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
120
128
    }
121
129
 
122
 
    gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem);
 
130
    if (entry->name_hint != NULL) {
 
131
        int i;
 
132
        int found = 0;
 
133
        for (i = 0; indicator_order[i] != NULL; i++) {
 
134
            if (g_strcmp0(entry->name_hint, indicator_order[i]) == 0) {
 
135
                gtk_menu_shell_insert(GTK_MENU_SHELL(user_data), menuitem, i);
 
136
                found = 1;
 
137
                break;
 
138
            }
 
139
        }
 
140
        if (found == 0) {
 
141
            gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem);
 
142
        }
 
143
    }
 
144
    else {
 
145
        gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem);
 
146
    }
 
147
 
123
148
    gtk_widget_show(menuitem);
124
149
 
125
150
    g_object_set_data(G_OBJECT(menuitem), ENTRY_DATA_NAME, entry);
165
190
    /* Build the object for the module */
166
191
    IndicatorObject * io = indicator_object_new_from_file(name);
167
192
 
168
 
    /* Connect to it's signals */
 
193
    /* Connect to its signals */
169
194
    g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED,   G_CALLBACK(entry_added),    menu);
170
195
    g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed),  menu);
171
196
    /* Work on the entries */
200
225
}
201
226
 
202
227
static const char* indicators[] = {
203
 
        "/usr/lib/indicators3/6/libsession.so",
204
 
        // Bluetooth
205
 
        "/usr/lib/indicators3/6/libapplication.so",
206
 
        "/usr/lib/indicators3/6/libsoundmenu.so",
 
228
        "/usr/lib/indicators3/7/libsession.so",
 
229
        "/usr/lib/indicators3/7/libapplication.so",
 
230
        "/usr/lib/indicators3/7/libsoundmenu.so",
207
231
        NULL
208
232
};
209
233
 
224
248
        if (!pixbuf) {
225
249
                pixbuf = gdk_pixbuf_new_from_file("/usr/share/lxpanel/images/lubuntu-background.png", NULL);
226
250
        }
 
251
        if (!pixbuf) {
 
252
                pixbuf = gdk_pixbuf_new_from_file("/usr/share/ubiquity/pixmaps/panel.png", NULL);
 
253
        }
227
254
        if (pixbuf) {
228
255
                gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
229
256
                cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
230
257
                cairo_paint(cr);
231
 
                gdk_pixbuf_unref(pixbuf);
 
258
                g_object_unref(pixbuf);
232
259
        } else {
233
260
                g_warning("Could not find background image.");
234
261
        }
245
272
int
246
273
main(int argc, char* argv[]) {
247
274
        GtkWidget *win;
 
275
        GtkCssProvider *cssprovider;
 
276
 
248
277
        /* Disable global menus */
249
278
        g_unsetenv ("UBUNTU_MENUPROXY");
250
279
        gtk_init(&argc, &argv);
251
280
        win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
252
281
        g_signal_connect(win, "realize", G_CALLBACK(on_realize), NULL);
253
282
 
254
 
        gtk_css_provider_load_from_data(gtk_css_provider_get_default(),
 
283
        cssprovider = gtk_css_provider_new ();
 
284
        gtk_css_provider_load_from_data(cssprovider,
255
285
                        "GtkMenuBar {\n"
256
 
                        "-GtkMenuBar-internal-padding: 0;\n"
257
 
                        "-GtkMenuBar-shadow-type: none;\n"
258
 
                        "}\nGtkWidget {\n"
259
 
                        "-GtkWidget-focus-line-width: 0;\n"
260
 
                        "-GtkWidget-focus-padding: 0;\n"
261
 
                        "}", -1, NULL);
 
286
                        "    -GtkMenuBar-internal-padding: 0;\n"
 
287
                        "    -GtkMenuBar-shadow-type: none;\n"
 
288
                        "}\n"
 
289
                        "GtkWidget {\n"
 
290
                        "    -GtkWidget-focus-line-width: 0;\n"
 
291
                        "    -GtkWidget-focus-padding: 0;\n"
 
292
                        "}\n"
 
293
                        ".menuitem {\n"
 
294
                        "    padding: 0px 0px 0px 0px;\n"
 
295
                        "}\n", -1, NULL);
 
296
 
 
297
        gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
 
298
                GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
262
299
 
263
300
        GtkWidget* menubar = gtk_menu_bar_new();
264
301
        gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), GTK_PACK_DIRECTION_RTL);
268
305
                        g_error("Unable to load module");
269
306
                }
270
307
        }
271
 
        GtkWidget* hbox = gtk_hbox_new(FALSE, 3);
 
308
        GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
272
309
        gtk_container_add(GTK_CONTAINER(win), hbox);
273
310
        gtk_box_pack_end(GTK_BOX(hbox), menubar, FALSE, FALSE, 0);
274
311
        g_signal_connect_after(menubar, "draw", G_CALLBACK(on_draw), NULL);