diff options
author | Jason Conti <jason.conti@gmail.com> | 2011-08-19 13:32:25 -0400 |
---|---|---|
committer | Jason Conti <jason.conti@gmail.com> | 2011-08-19 13:32:25 -0400 |
commit | 59896497977040f03aaa0b2c293c265ed2e0c4e7 (patch) | |
tree | 4008e7001eb4835bdebc008162031df761a7434f /src | |
parent | c5ac5ce87d42d4456da3c82da1aed0ddece36129 (diff) | |
download | ayatana-indicator-notifications-59896497977040f03aaa0b2c293c265ed2e0c4e7.tar.gz ayatana-indicator-notifications-59896497977040f03aaa0b2c293c265ed2e0c4e7.tar.bz2 ayatana-indicator-notifications-59896497977040f03aaa0b2c293c265ed2e0c4e7.zip |
* Add a WITH_GTK (2, 3) definition to handle some of the minor differences0.1.3
between gtk2 and 3
* Replace gtk_hbox_new with gtk_box_new in the gtk3 version
* GtkLabel has a new (and much nicer) wrapping mechanism
- use gtk_label_set_max_width_chars in gtk3 version
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/indicator-notifications.c | 29 | ||||
-rw-r--r-- | src/notifications-service.c | 5 |
3 files changed, 28 insertions, 9 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 486770f..708b030 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,5 @@ -AM_CPPFLAGS = -DICONS_DIR='"$(INDICATORICONSDIR)"' +AM_CPPFLAGS = -DICONS_DIR='"$(INDICATORICONSDIR)"' \ + -DWITH_GTK='$(GTK_VERSION)' libexec_PROGRAMS = indicator-notifications-service diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c index eb7fe03..237c4d0 100644 --- a/src/indicator-notifications.c +++ b/src/indicator-notifications.c @@ -40,8 +40,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-service-manager.h> /* DBusMenu */ +#if WITH_GTK == 3 +#include <libdbusmenu-gtk3/menu.h> +#include <libdbusmenu-gtk3/menuitem.h> +#else #include <libdbusmenu-gtk/menu.h> #include <libdbusmenu-gtk/menuitem.h> +#endif #include "dbus-shared.h" #include "settings-shared.h" @@ -172,7 +177,10 @@ indicator_notifications_init(IndicatorNotifications *self) DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu); - dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), NOTIFICATION_MENUITEM_TYPE, new_notification_menuitem, self, NULL); + dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), + NOTIFICATION_MENUITEM_TYPE, + new_notification_menuitem, + self, NULL); self->priv->service_proxy_cancel = g_cancellable_new(); @@ -189,9 +197,6 @@ indicator_notifications_init(IndicatorNotifications *self) return; } -/* Callback from trying to create the proxy for the serivce, this - could include starting the service. Sometime it'll fail and - we'll try to start that dang service again! */ static void service_proxy_cb(GObject *object, GAsyncResult *res, gpointer user_data) { @@ -215,8 +220,6 @@ service_proxy_cb(GObject *object, GAsyncResult *res, gpointer user_data) return; } - /* Okay, we're good to grab the proxy at this point, we're - sure that it's ours. */ priv->service_proxy = proxy; g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); @@ -272,7 +275,6 @@ indicator_notifications_finalize(GObject *object) return; } -/* Receives all signals from the service, routed to the appropriate functions */ static void receive_signal(GDBusProxy *proxy, gchar *sender_name, gchar *signal_name, GVariant *parameters, gpointer user_data) @@ -315,15 +317,26 @@ new_notification_menuitem(DbusmenuMenuitem *new_item, DbusmenuMenuitem *parent, g_free(body); g_free(timestamp_string); +#if WITH_GTK == 3 + GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); +#else GtkWidget *hbox = gtk_hbox_new(FALSE, 0); +#endif GtkWidget *label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_label_set_markup(GTK_LABEL(label), markup); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); + +#if WITH_GTK == 3 + gtk_label_set_max_width_chars(GTK_LABEL(label), 42); +#else gtk_widget_set_size_request(label, 300, -1); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); +#endif + + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); gtk_widget_show(label); g_free(markup); diff --git a/src/notifications-service.c b/src/notifications-service.c index a5a4ef2..d3c7da2 100644 --- a/src/notifications-service.c +++ b/src/notifications-service.c @@ -26,7 +26,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib/gi18n.h> #include <gio/gio.h> +#if WITH_GTK == 3 +#include <libdbusmenu-gtk3/menuitem.h> +#else #include <libdbusmenu-gtk/menuitem.h> +#endif + #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/client.h> #include <libdbusmenu-glib/menuitem.h> |