summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-07-12 13:19:43 +0000
committerJason Woodward2019-07-21 15:28:02 -0400
commit87207ed63f08b55952202d9187c4852f17dcec5a (patch)
treeab69a77682d5a7e8783a5302da2471b36885de46
parentcdb85eafa5c0b5ff08fda052657c891e60155f53 (diff)
downloadslapt-update-service-87207ed63f08b55952202d9187c4852f17dcec5a.tar.gz
updated glib, libnotify, and gtk support
- guard deprecated g_type_init - remove deprecated g_type_class_add_private - update notify_notification_new call for new arg list - prefer gtk+3.0, make gtk2 optional
-rw-r--r--configure.ac23
-rw-r--r--src/client.c10
-rw-r--r--src/server.c4
-rw-r--r--src/slaptService.c9
4 files changed, 37 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index 0561954..8cf922c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,9 +44,30 @@ AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(DBUS, [dbus-1 dbus-glib-1])
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
-PKG_CHECK_MODULES(GTK, [gtk+-2.0 gdk-pixbuf-2.0])
+
+gtk2_modules="gtk+-2.0 >= 2.24.0"
+gtk3_modules="gtk+-3.0 >= 3.4.0"
+AM_CONDITIONAL(GTK3, true)
+AM_CONDITIONAL(GTK2, false)
+AC_ARG_ENABLE(gtk3,
+ [ --enable-gtk3 Build with GTK3 support],
+ [enable_gtk3=$enableval], [enable_gtk3=yes])
+AC_ARG_ENABLE(gtk2,
+ [ --enable-gtk2 Build with GTK2 support],
+ [enable_gtk2=$enableval], [enable_gtk2=no])
+if test x"$enable_gtk2" = x"yes"; then
+PKG_CHECK_MODULES(GTK, [gtk+-3.0 gdk-pixbuf-2.0])
+ PKG_CHECK_MODULES(GTK, [$gtk2_modules])
+ AM_CONDITIONAL(GTK3, false)
+ AM_CONDITIONAL(GTK2, true)
+else
+ PKG_CHECK_MODULES(GTK, [$gtk3_modules])
+ AM_CONDITIONAL(GTK3, true)
+ AM_CONDITIONAL(GTK2, false)
+fi
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
+
AC_ARG_WITH(
[notification],
AC_HELP_STRING([--with-notification], [use notification (default is no)]),
diff --git a/src/client.c b/src/client.c
index 2acd100..79567ff 100644
--- a/src/client.c
+++ b/src/client.c
@@ -105,7 +105,11 @@ static void notify_callback(NotifyNotification *handle, const char *action, void
GMainLoop *loop = (GMainLoop *)user_data;
if (strcmp(action, NOTIFICATION_SHOW_UPDATES) == 0) {
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_hide(GTK_WIDGET(sun->tray_icon));
+#else
gtk_widget_hide_all(GTK_WIDGET(sun->tray_icon));
+#endif
run_gslapt("upgrade");
}
@@ -128,7 +132,7 @@ gboolean show_notification(gpointer data)
n = notify_notification_new(
_("New updates available"),
_("Click on the update icon to see the available updates"),
- "info", NULL);
+ "info");
GError *error = NULL;
if (notify_notification_show(n, &error) != TRUE) {
@@ -238,7 +242,11 @@ int main(int argc, char *argv[])
sun->updates_pixbuf = gdk_pixbuf_new_from_file(SUN_UPDATE_ICON, NULL);
sun->running_pixbuf = gdk_pixbuf_new_from_file(SUN_RUNNING_ICON, NULL);
gtk_status_icon_set_from_pixbuf(sun->tray_icon, sun->updates_pixbuf);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_status_icon_set_tooltip_text(sun->tray_icon, _("Updates available"));
+#else
gtk_status_icon_set_tooltip(sun->tray_icon, _("Updates available"));
+#endif
gtk_status_icon_set_visible(sun->tray_icon, FALSE);
g_signal_connect(G_OBJECT(sun->tray_icon), "activate", G_CALLBACK(tray_clicked), &sun);
diff --git a/src/server.c b/src/server.c
index 190a76c..7131c67 100644
--- a/src/server.c
+++ b/src/server.c
@@ -34,7 +34,9 @@ int main(void)
int saved_stdout = dup(1);
FILE *newstdout = NULL;
- g_type_init();
+#if !GLIB_CHECK_VERSION(2,35,0)
+ g_type_init ();
+#endif
#ifdef SLAPT_HAS_GPGME
gpgme_check_version(NULL);
#endif
diff --git a/src/slaptService.c b/src/slaptService.c
index 4b208c7..2ee834a 100644
--- a/src/slaptService.c
+++ b/src/slaptService.c
@@ -19,13 +19,12 @@
#include "slaptService.h"
#include "server-bindings.h"
#include "common.h"
-#define SLAPT_SERVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), SLAPT_TYPE_SERVICE, SlaptServicePrivate))
struct _SlaptServicePrivate {
int count; /* nothing here yet */
};
-G_DEFINE_TYPE(SlaptService, slapt_service, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_CODE(SlaptService, slapt_service, G_TYPE_OBJECT, G_ADD_PRIVATE(SlaptService))
static gboolean slapt_service_real_check_for_updates(SlaptService *self, guint *count, GError **error)
{
@@ -134,8 +133,6 @@ static void slapt_service_class_init(SlaptServiceClass *class)
{
GError *error = NULL;
- g_type_class_add_private(class, sizeof(SlaptServicePrivate));
-
class->check_for_updates = NULL;
class->refresh_cache = NULL;
@@ -147,12 +144,12 @@ static void slapt_service_init(SlaptService *self)
SlaptServiceClass *class = SLAPT_SERVICE_GET_CLASS(self);
int request_ret;
- SlaptServicePrivate *priv;
+ SlaptServicePrivate *priv = slapt_service_get_instance_private(self);
self->check_for_updates = slapt_service_real_check_for_updates;
self->refresh_cache = slapt_service_real_refresh_cache;
- self->priv = priv = SLAPT_SERVICE_GET_PRIVATE(self);
+ self->priv = priv;
priv->count = 0;
}