From 1158fdc89f344fe1b4a3aca15e19d75cb8c78f85 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 24 Mar 2021 11:00:13 +0100 Subject: Whitespace fix --- src/idobasicmenuitem.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/idobasicmenuitem.h b/src/idobasicmenuitem.h index 38ae830..e43b937 100644 --- a/src/idobasicmenuitem.h +++ b/src/idobasicmenuitem.h @@ -4,16 +4,16 @@ * Authors: * Charles Kerr * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along + * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ -- cgit v1.2.3 From f95ddece8e8c05c926ab9ff319f221e36af909c8 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 24 Mar 2021 11:33:12 +0100 Subject: src/idoappointmentmenuitem.c: Contruct the basic menu item using the pixbuf property --- src/idoappointmentmenuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/idoappointmentmenuitem.c b/src/idoappointmentmenuitem.c index 5659644..8bec421 100644 --- a/src/idoappointmentmenuitem.c +++ b/src/idoappointmentmenuitem.c @@ -104,7 +104,7 @@ ido_appointment_menu_item_new_from_model (GMenuItem * menu_item, if (g_menu_item_get_attribute (menu_item, "x-ayatana-color", "s", &str)) { - names[n] = "icon"; + names[n] = "pixbuf"; g_value_init (&values[n], G_TYPE_OBJECT); g_value_take_object (&values[n], create_color_icon_pixbuf (str)); g_free(str); -- cgit v1.2.3 From aa242a51551120c5f6a5f4483e4f96728afcb8ea Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 24 Mar 2021 11:35:36 +0100 Subject: src/basicmenuitem.h: Add the ido_basic_menu_item_set_pixbuf function --- src/idobasicmenuitem.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/idobasicmenuitem.h b/src/idobasicmenuitem.h index e43b937..2ea1b52 100644 --- a/src/idobasicmenuitem.h +++ b/src/idobasicmenuitem.h @@ -53,6 +53,9 @@ GtkWidget * ido_basic_menu_item_new (void); void ido_basic_menu_item_set_icon (IdoBasicMenuItem * self, GIcon * icon); +void ido_basic_menu_item_set_pixbuf (IdoBasicMenuItem * self, + GdkPixbuf * pPixbuf); + void ido_basic_menu_item_set_icon_from_file (IdoBasicMenuItem * self, const char * filename); -- cgit v1.2.3 From 386eaabc3b2132bfba68551d61e2d9a0316526b1 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 24 Mar 2021 11:47:12 +0100 Subject: src/basicmenuitem.c: Add GdkPixbuf source support for the icon --- src/idobasicmenuitem.c | 69 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/idobasicmenuitem.c b/src/idobasicmenuitem.c index 080151c..109ea2e 100644 --- a/src/idobasicmenuitem.c +++ b/src/idobasicmenuitem.c @@ -26,6 +26,7 @@ enum { PROP_0, PROP_ICON, + PROP_PIXBUF, PROP_TEXT, PROP_SECONDARY_TEXT, PROP_LAST @@ -35,6 +36,7 @@ static GParamSpec *properties[PROP_LAST]; typedef struct { GIcon * icon; + GdkPixbuf *pPixbuf; char * text; char * secondary_text; @@ -64,6 +66,10 @@ my_get_property (GObject * o, g_value_set_object (value, p->icon); break; + case PROP_PIXBUF: + g_value_set_object(value, p->pPixbuf); + break; + case PROP_TEXT: g_value_set_string (value, p->text); break; @@ -92,6 +98,10 @@ my_set_property (GObject * o, ido_basic_menu_item_set_icon (self, g_value_get_object (value)); break; + case PROP_PIXBUF: + ido_basic_menu_item_set_pixbuf(self, g_value_get_object(value)); + break; + case PROP_TEXT: ido_basic_menu_item_set_text (self, g_value_get_string (value)); break; @@ -113,6 +123,7 @@ my_dispose (GObject * object) IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self); g_clear_object (&p->icon); + g_clear_object (&p->pPixbuf); G_OBJECT_CLASS (ido_basic_menu_item_parent_class)->dispose (object); } @@ -136,31 +147,39 @@ ido_basic_menu_item_update_image (IdoBasicMenuItem *self) gtk_image_clear (GTK_IMAGE (p->image)); - if (p->icon == NULL) + if (p->icon == NULL && p->pPixbuf == NULL) { gtk_widget_set_visible (p->image, FALSE); } else { - GtkIconInfo *info; - const gchar *filename; + if (p->pPixbuf) + { + gtk_image_set_from_pixbuf(GTK_IMAGE(p->image), p->pPixbuf); + gtk_widget_set_visible(p->image, TRUE); + } + else if (p->icon) + { + GtkIconInfo *info; + const gchar *filename; - info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), p->icon, 16, 0); - filename = gtk_icon_info_get_filename (info); + info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), p->icon, 16, 0); + filename = gtk_icon_info_get_filename (info); - if (filename) - { - GdkPixbuf *pixbuf; + if (filename) + { + GdkPixbuf *pixbuf; - pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, -1, 16, TRUE, NULL); - gtk_image_set_from_pixbuf (GTK_IMAGE (p->image), pixbuf); + pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, -1, 16, TRUE, NULL); + gtk_image_set_from_pixbuf (GTK_IMAGE (p->image), pixbuf); - g_object_unref (pixbuf); - } + g_object_unref (pixbuf); + } - gtk_widget_set_visible (p->image, filename != NULL); + gtk_widget_set_visible (p->image, filename != NULL); - g_object_unref (info); + g_object_unref (info); + } } } @@ -201,6 +220,12 @@ ido_basic_menu_item_class_init (IdoBasicMenuItemClass *klass) G_TYPE_OBJECT, prop_flags); + properties[PROP_PIXBUF] = g_param_spec_object ("pixbuf", + "Pixbuf", + "The menuitem's GdkPixbuf", + G_TYPE_OBJECT, + prop_flags); + properties[PROP_TEXT] = g_param_spec_string ("text", "Text", "The menuitem's text", @@ -289,6 +314,22 @@ ido_basic_menu_item_set_icon (IdoBasicMenuItem * self, GIcon * icon) } } +void ido_basic_menu_item_set_pixbuf(IdoBasicMenuItem *self, GdkPixbuf *pPixbuf) +{ + IdoBasicMenuItemPrivate *pPrivate = ido_basic_menu_item_get_instance_private(self); + + if (pPrivate->pPixbuf != pPixbuf) + { + if (pPrivate->pPixbuf) + { + g_object_unref(pPrivate->pPixbuf); + } + + pPrivate->pPixbuf = pPixbuf ? g_object_ref(pPixbuf) : NULL; + ido_basic_menu_item_update_image(self); + } +} + void ido_basic_menu_item_set_icon_from_file (IdoBasicMenuItem * self, const char * filename) { -- cgit v1.2.3 From 241bd377a1d0c4e3b4f66f1cf4ff63d59fae1286 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 24 Mar 2021 11:50:02 +0100 Subject: Add us to the copyright headers --- src/idoappointmentmenuitem.c | 2 ++ src/idobasicmenuitem.c | 2 ++ src/idobasicmenuitem.h | 2 ++ 3 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/idoappointmentmenuitem.c b/src/idoappointmentmenuitem.c index 8bec421..7ab593e 100644 --- a/src/idoappointmentmenuitem.c +++ b/src/idoappointmentmenuitem.c @@ -1,9 +1,11 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 AyatanaIndicators * * Authors: * Charles Kerr * Ted Gould + * Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published diff --git a/src/idobasicmenuitem.c b/src/idobasicmenuitem.c index 109ea2e..41f69db 100644 --- a/src/idobasicmenuitem.c +++ b/src/idobasicmenuitem.c @@ -1,8 +1,10 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 AyatanaIndicators * * Authors: * Charles Kerr + * Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published diff --git a/src/idobasicmenuitem.h b/src/idobasicmenuitem.h index 2ea1b52..cd15d57 100644 --- a/src/idobasicmenuitem.h +++ b/src/idobasicmenuitem.h @@ -1,8 +1,10 @@ /** * Copyright 2013 Canonical Ltd. + * Copyright 2021 AyatanaIndicators * * Authors: * Charles Kerr + * Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published -- cgit v1.2.3