summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac8
-rw-r--r--src/file-share-properties.c62
2 files changed, 68 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 03e8954..fd7fb30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,7 +81,6 @@ case "$with_gtk" in
3.0) GTK_API_VERSION=3.0
GTK_REQUIRED_VERSION=3.0.0
CANBERRA_API_VERSION=3
- UNIQUE_API_VERSION=3.0
;;
esac
@@ -91,7 +90,12 @@ PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.15.2 gio-2.0 >= 2.26 gdk-x11-$GTK_AP
AC_SUBST(USER_SHARE_CFLAGS)
AC_SUBST(USER_SHARE_LIBS)
-PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gio-2.0 >= 2.25.0 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION unique-$UNIQUE_API_VERSION)
+if test "$GTK_REQUIRED_VERSION" = "3.0.0"; then
+ PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gio-2.0 >= 2.25.0 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION)
+else
+ PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gio-2.0 >= 2.25.0 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION unique-$UNIQUE_API_VERSION)
+fi
+
AC_SUBST(USER_SHARE_CONFIG_CFLAGS)
AC_SUBST(USER_SHARE_CONFIG_LIBS)
diff --git a/src/file-share-properties.c b/src/file-share-properties.c
index 27669f6..b42a1bc 100644
--- a/src/file-share-properties.c
+++ b/src/file-share-properties.c
@@ -29,7 +29,9 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
+#if !GTK_CHECK_VERSION (3, 0, 0)
#include <unique/uniqueapp.h>
+#endif
#include "user_share-private.h"
@@ -451,6 +453,10 @@ help_button_clicked (GtkButton *button, GtkWidget *window)
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GtkWidget *
+create_window (void)
+#else
static UniqueResponse
message_received_cb (UniqueApp *app,
int command,
@@ -465,6 +471,7 @@ message_received_cb (UniqueApp *app,
int
main (int argc, char *argv[])
+#endif
{
GError *error = NULL;
GSettings *settings;
@@ -483,6 +490,7 @@ main (int argc, char *argv[])
GtkListStore *store;
GtkCellRenderer *cell;
GtkTreeIter iter;
+#if !GTK_CHECK_VERSION (3, 0, 0)
UniqueApp *app;
bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
@@ -497,6 +505,7 @@ main (int argc, char *argv[])
unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
return 0;
}
+#endif
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, DATADIR"file-share-properties.ui", &error);
@@ -509,14 +518,20 @@ main (int argc, char *argv[])
gtk_widget_destroy (dialog);
g_error_free (error);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ return NULL;
+#else
return 1;
+#endif
}
window = GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog"));
+#if !GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (app, "message-received",
G_CALLBACK (message_received_cb), window);
+#endif
settings = g_settings_new (GSETTINGS_SCHEMA);
@@ -606,8 +621,13 @@ main (int argc, char *argv[])
"toggled", G_CALLBACK (notify_received_obexpush_check_toggled), NULL);
#endif /* HAVE_BLUETOOTH */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect_swapped (GTK_WIDGET (gtk_builder_get_object (builder, "close_button")),
+ "clicked", G_CALLBACK (gtk_widget_destroy), window);
+#else
g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "close_button")),
"clicked", G_CALLBACK (gtk_main_quit), NULL);
+#endif
g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "help_button")),
"clicked", G_CALLBACK (help_button_clicked),
gtk_builder_get_object (builder, "user_share_dialog"));
@@ -641,9 +661,51 @@ main (int argc, char *argv[])
update_ui ();
+#if GTK_CHECK_VERSION (3, 0, 0)
+ return window;
+}
+
+static void
+activate (GtkApplication *app)
+{
+ GList *list;
+ GtkWidget *window;
+
+ list = gtk_application_get_windows (app);
+
+ if (list) {
+ gtk_window_present (GTK_WINDOW (list->data));
+ } else {
+ window = create_window ();
+ gtk_window_set_application (GTK_WINDOW (window), app);
+ gtk_widget_show (window);
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkApplication *app;
+ gint status;
+
+ bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ app = gtk_application_new ("org.mate.user-share.properties",
+ G_APPLICATION_FLAGS_NONE);
+ g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+
+ status = g_application_run (G_APPLICATION (app), argc, argv);
+
+ g_object_unref (app);
+
+ return status;
+#else
gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog")));
gtk_main ();
return 0;
+#endif
}