summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorlukefromdc <[email protected]>2016-10-01 02:40:11 -0400
committermonsta <[email protected]>2016-10-19 13:28:59 +0300
commit80d37475904c9e58b8a291bcd6d49867dbf23506 (patch)
treefca1d0da4c73ee24a8156f9e03f99596dac24088 /shell
parent2ef871dfb77e9ecf9b269561c81cee8c2169d197 (diff)
downloadmate-control-center-80d37475904c9e58b8a291bcd6d49867dbf23506.tar.bz2
mate-control-center-80d37475904c9e58b8a291bcd6d49867dbf23506.tar.xz
GTK3: port libunique->GtkApplication
All GTK3 builds for now, this can go 3-way to permit gtk3/libunique builds if there is any reason for a distro to have issues with using GtkApplication, or for a point/buildfix release
Diffstat (limited to 'shell')
-rw-r--r--shell/control-center.c73
-rw-r--r--shell/matecc.desktop.in.in2
2 files changed, 64 insertions, 11 deletions
diff --git a/shell/control-center.c b/shell/control-center.c
index 2f1454b2..d0f8f8cb 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -23,8 +23,9 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
+#if !GTK_CHECK_VERSION(3,0,0)
#include <unique/unique.h>
-
+#endif
#include <libslab/slab.h>
void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data);
@@ -93,7 +94,9 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data)
AppShellData* app_data = (AppShellData*) data;
MateDesktopItem* item = (MateDesktopItem*) g_object_get_data(G_OBJECT(tile), APP_ACTION_KEY);
GSettings *settings;
-
+#if GTK_CHECK_VERSION(3,0,0)
+ GApplication *app;
+#endif
if (event->type == TILE_EVENT_ACTIVATED_DOUBLE_CLICK)
{
return;
@@ -107,7 +110,12 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data)
{
if (app_data->exit_on_close)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ app=g_application_get_default();
+ g_application_quit(app);
+#else
gtk_main_quit();
+#endif
}
else
{
@@ -118,6 +126,40 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data)
g_object_unref(settings);
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void
+activate (GtkApplication *app)
+{
+ GList *list;
+ GSList* actions;
+ gboolean hidden = FALSE;
+
+ list = gtk_application_get_windows (app);
+
+ AppShellData* app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE, 0);
+
+ generate_categories(app_data);
+
+ actions = get_actions_list();
+ layout_shell(app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions, handle_static_action_clicked);
+
+ if (list)
+ {
+ gtk_window_present (GTK_WINDOW (list->data));
+ }
+ else
+ {
+ create_main_window(app_data, "MyControlCenter", _("Control Center"), "preferences-desktop", 975, 600, hidden);
+ gtk_application_add_window (app, GTK_WINDOW(app_data->main_app));
+ }
+}
+
+static void
+quit (GApplication *app)
+{
+ g_application_quit(app);
+}
+#else
static UniqueResponse message_received_cb(UniqueApp* app, UniqueCommand command, UniqueMessageData* message, guint time, gpointer user_data)
{
UniqueResponse res;
@@ -148,24 +190,30 @@ static UniqueResponse message_received_cb(UniqueApp* app, UniqueCommand command,
return res;
}
-
+#endif
int main(int argc, char* argv[])
{
gboolean hidden = FALSE;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkApplication *app;
+ gint retval;
+ app = gtk_application_new ("org.mate.mate-control-center.shell", 0);
+#else
UniqueApp* unique_app;
AppShellData* app_data;
GSList* actions;
+#endif
GError* error;
GOptionEntry options[] = {
{"hide", 0, 0, G_OPTION_ARG_NONE, &hidden, N_("Hide on start (useful to preload the shell)"), NULL},
{NULL}
};
- #ifdef ENABLE_NLS
- bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
- #endif
+#ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+#endif
error = NULL;
@@ -175,7 +223,12 @@ int main(int argc, char* argv[])
g_error_free(error);
return 1;
}
-
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+ g_signal_connect (app, "window-removed", G_CALLBACK (quit), NULL);
+ retval = g_application_run (G_APPLICATION (app), argc, argv);
+ return retval;
+#else
unique_app = unique_app_new("org.mate.mate-control-center.shell", NULL);
if (unique_app_is_running(unique_app))
@@ -205,8 +258,8 @@ int main(int argc, char* argv[])
g_signal_connect(unique_app, "message-received", G_CALLBACK(message_received_cb), app_data);
gtk_main();
-
g_object_unref(unique_app);
return 0;
+#endif
}
diff --git a/shell/matecc.desktop.in.in b/shell/matecc.desktop.in.in
index 50480c63..ca3298e9 100644
--- a/shell/matecc.desktop.in.in
+++ b/shell/matecc.desktop.in.in
@@ -5,7 +5,7 @@ Icon=preferences-desktop
Exec=mate-control-center
Terminal=false
Type=Application
-StartupNotify=true
+StartupNotify=false
Categories=GTK;Settings;
Keywords=MATE;control;center;configuration;tool;destop;preferences;
OnlyShowIn=MATE;