aboutsummaryrefslogtreecommitdiff
path: root/src/applet-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/applet-main.c')
-rw-r--r--src/applet-main.c95
1 files changed, 89 insertions, 6 deletions
diff --git a/src/applet-main.c b/src/applet-main.c
index 6ce1a96..e1f1f03 100644
--- a/src/applet-main.c
+++ b/src/applet-main.c
@@ -7,6 +7,12 @@
static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
+static void cw_panel_background_changed (PanelApplet *applet,
+ PanelAppletBackgroundType type,
+ GdkColor *colour,
+ GdkPixmap *pixmap,
+ GtkWidget *menubar);
+
/*************
* main
* ***********/
@@ -56,19 +62,51 @@ load_module (const gchar * name, GtkWidget * menu)
}
static gboolean
+menubar_on_expose (GtkWidget * widget,
+ GdkEventExpose *event,
+ GtkWidget * menubar)
+{
+ if (GTK_WIDGET_HAS_FOCUS(menubar))
+ gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(menubar),
+ NULL, widget, "menubar-applet", 0, 0, -1, -1);
+
+ return FALSE;
+}
+
+static gboolean
applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)
{
+ GtkWidget *menubar;
+ gint i;
+ gint indicators_loaded = 0;
+
+ /* Set panel options */
+ gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
+ panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);
+
+ /* Init some theme/icon stuff */
gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
ICONS_DIR);
+ gtk_rc_parse_string (
+ "style \"indicator-applet-style\"\n"
+ "{\n"
+ " GtkMenuBar::shadow-type = none\n"
+ " GtkMenuBar::internal-padding = 0\n"
+ " GtkWidget::focus-line-width = 0\n"
+ " GtkWidget::focus-padding = 0\n"
+ "}\n"
+ "widget \"*.indicator-applet-menubar\" style \"indicator-applet-style\"");
+
+ /* Build menubar */
+ menubar = gtk_menu_bar_new();
+ GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS);
+ gtk_widget_set_name(GTK_WIDGET (menubar), "indicator-applet-menubar");
+ g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar);
+ gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
- int i;
- GtkWidget * menubar = gtk_menu_bar_new();
- gtk_widget_set_name (menubar, "indicator-applet-menubar");
gtk_container_add(GTK_CONTAINER(applet), menubar);
gtk_widget_show(menubar);
- int indicators_loaded = 0;
-
/* load 'em */
if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
@@ -86,7 +124,52 @@ applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
gtk_widget_show(item);
}
-
+
+ /* Background of applet */
+ g_signal_connect(applet, "change-background",
+ G_CALLBACK(cw_panel_background_changed), menubar);
+
gtk_widget_show(GTK_WIDGET(applet));
+
return TRUE;
}
+
+static void
+cw_panel_background_changed (PanelApplet *applet,
+ PanelAppletBackgroundType type,
+ GdkColor *colour,
+ GdkPixmap *pixmap,
+ GtkWidget *menubar)
+{
+ GtkRcStyle *rc_style;
+ GtkStyle *style;
+
+ /* reset style */
+ gtk_widget_set_style(GTK_WIDGET (applet), NULL);
+ gtk_widget_set_style(menubar, NULL);
+ rc_style = gtk_rc_style_new ();
+ gtk_widget_modify_style(GTK_WIDGET (applet), rc_style);
+ gtk_widget_modify_style(menubar, rc_style);
+ gtk_rc_style_unref(rc_style);
+
+ switch (type)
+ {
+ case PANEL_NO_BACKGROUND:
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ gtk_widget_modify_bg(GTK_WIDGET (applet), GTK_STATE_NORMAL, colour);
+ gtk_widget_modify_bg(menubar, GTK_STATE_NORMAL, colour);
+ break;
+
+ case PANEL_PIXMAP_BACKGROUND:
+ style = gtk_style_copy(GTK_WIDGET (applet)->style);
+ if (style->bg_pixmap[GTK_STATE_NORMAL])
+ g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);
+ style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap);
+ gtk_widget_set_style(GTK_WIDGET (applet), style);
+ gtk_widget_set_style(GTK_WIDGET (menubar), style);
+ g_object_unref(style);
+ break;
+ }
+}
+