From e886446f5c14c899b155632f67927130127da4ed Mon Sep 17 00:00:00 2001 From: Neil Jagdish Patel Date: Tue, 3 Feb 2009 21:29:52 +0100 Subject: Enable support for a "transparent" panel applet, which reacts to the gnome- panel theme changes --- src/applet-main.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 7 deletions(-) diff --git a/src/applet-main.c b/src/applet-main.c index 6ce1a96..3688084 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 * ***********/ @@ -58,17 +64,31 @@ load_module (const gchar * name, GtkWidget * menu) 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); - - int i; - GtkWidget * menubar = gtk_menu_bar_new(); - gtk_widget_set_name (menubar, "indicator-applet-menubar"); + gtk_rc_parse_string ( + "style \"panel-menubar-style\"\n" + "{\n" + " GtkMenuBar::shadow-type = none\n" + " GtkMenuBar::internal-padding = 0\n" + "}\n" + "widget \"*indicator-applet-menubar*\" style : highest \"panel-menubar-style\""); + + /* Build menubar */ + menubar = gtk_menu_bar_new(); + gtk_widget_set_name(GTK_WIDGET (applet), "indicator-applet-menubar");//leave 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 +106,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; + } +} + -- cgit v1.2.3 From 3002304e9f7230b65f535bd593e000f66fac022b Mon Sep 17 00:00:00 2001 From: Neil Jagdish Patel Date: Wed, 4 Feb 2009 12:44:34 +0100 Subject: Fix coding style --- src/applet-main.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/applet-main.c b/src/applet-main.c index 3688084..a4e60d9 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -69,8 +69,8 @@ applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data) 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); + 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(), @@ -108,8 +108,8 @@ applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data) } /* Background of applet */ - g_signal_connect (applet, "change-background", - G_CALLBACK (cw_panel_background_changed), menubar); + g_signal_connect(applet, "change-background", + G_CALLBACK(cw_panel_background_changed), menubar); gtk_widget_show(GTK_WIDGET(applet)); @@ -127,30 +127,30 @@ cw_panel_background_changed (PanelApplet *applet, GtkStyle *style; /* reset style */ - gtk_widget_set_style (GTK_WIDGET (applet), NULL); - gtk_widget_set_style (menubar, NULL); + 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); + 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); + 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); + style = gtk_style_copy(GTK_WIDGET (applet)->style); if (style->bg_pixmap[GTK_STATE_NORMAL]) - g_object_unref (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); + gtk_widget_set_style(GTK_WIDGET (applet), style); + gtk_widget_set_style(GTK_WIDGET (menubar), style); + g_object_unref(style); break; } } -- cgit v1.2.3 From 124eadccbb522b2694f9d29c0706e3cdadc5a2b4 Mon Sep 17 00:00:00 2001 From: Neil Jagdish Patel Date: Wed, 4 Feb 2009 12:45:50 +0100 Subject: indicator-applet (0.1~ppa22) intrepid; urgency=low * Add support for a transparent panel applet -- Neil J. Patel Wed, 04 Feb 2009 12:44:56 +0100 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 712ea42..d90661e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +indicator-applet (0.1~ppa22) intrepid; urgency=low + + * Add support for a transparent panel applet + + -- Neil J. Patel Wed, 04 Feb 2009 12:44:56 +0100 + indicator-applet (0.1~ppa21) intrepid; urgency=low * Adding in package fixes from seb128 -- cgit v1.2.3 From b5314b86ec063d329e4204bc9f524b618ae4ab52 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Feb 2009 13:55:18 +0100 Subject: Making it so that there is no more boarder on the menu bar --- src/applet-main.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/applet-main.c b/src/applet-main.c index a4e60d9..e1f1f03 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -61,6 +61,18 @@ load_module (const gchar * name, GtkWidget * menu) return TRUE; } +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) { @@ -76,16 +88,22 @@ applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data) gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), ICONS_DIR); gtk_rc_parse_string ( - "style \"panel-menubar-style\"\n" - "{\n" - " GtkMenuBar::shadow-type = none\n" - " GtkMenuBar::internal-padding = 0\n" - "}\n" - "widget \"*indicator-applet-menubar*\" style : highest \"panel-menubar-style\""); + "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_name(GTK_WIDGET (applet), "indicator-applet-menubar");//leave + 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); + gtk_container_add(GTK_CONTAINER(applet), menubar); gtk_widget_show(menubar); -- cgit v1.2.3