shell: Make it build and work against new GApplication
This commit is contained in:
parent
59e2bc5c63
commit
93ee44fe43
3 changed files with 54 additions and 57 deletions
|
@ -28,57 +28,16 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
application_prepare_action_cb (GApplication *application,
|
application_command_line_cb (GApplication *application,
|
||||||
GVariant *arguments,
|
GApplicationCommandLine *command_line,
|
||||||
GVariant *platform_data,
|
|
||||||
GnomeControlCenter *shell)
|
GnomeControlCenter *shell)
|
||||||
{
|
{
|
||||||
const gchar **argv;
|
int argc;
|
||||||
gsize length;
|
char **argv;
|
||||||
|
|
||||||
gnome_control_center_present (shell);
|
|
||||||
|
|
||||||
argv = g_variant_get_bytestring_array (arguments, &length);
|
|
||||||
|
|
||||||
if (length == 2)
|
|
||||||
{
|
|
||||||
GError *err = NULL;
|
|
||||||
const gchar *id = argv[1];
|
|
||||||
|
|
||||||
if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, &err))
|
|
||||||
{
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
g_warning ("Could not load setting panel \"%s\": %s", id,
|
|
||||||
err->message);
|
|
||||||
g_error_free (err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
GnomeControlCenter *shell;
|
|
||||||
GtkApplication *application;
|
|
||||||
|
|
||||||
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
||||||
textdomain (GETTEXT_PACKAGE);
|
|
||||||
|
|
||||||
|
|
||||||
g_thread_init (NULL);
|
|
||||||
gtk_init (&argc, &argv);
|
|
||||||
|
|
||||||
shell = gnome_control_center_new ();
|
|
||||||
|
|
||||||
/* enforce single instance of this application */
|
|
||||||
application = gtk_application_new ("org.gnome.ControlCenter", &argc, &argv);
|
|
||||||
g_signal_connect (application, "prepare-activation",
|
|
||||||
G_CALLBACK (application_prepare_action_cb), shell);
|
|
||||||
|
|
||||||
|
g_application_command_line_get_argc_argv (command_line, &argc, &argv);
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
gchar *start_id;
|
gchar *start_id;
|
||||||
|
@ -97,11 +56,44 @@ main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_strfreev (argv);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_application_run (application);
|
static void
|
||||||
|
application_startup_cb (GApplication *application,
|
||||||
|
GnomeControlCenter *shell)
|
||||||
|
{
|
||||||
|
gnome_control_center_show (shell, GTK_APPLICATION (application));
|
||||||
|
gnome_control_center_present (shell);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
GnomeControlCenter *shell;
|
||||||
|
GtkApplication *application;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
|
|
||||||
|
g_thread_init (NULL);
|
||||||
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
|
shell = gnome_control_center_new ();
|
||||||
|
|
||||||
|
/* enforce single instance of this application */
|
||||||
|
application = gtk_application_new ("org.gnome.ControlCenter", G_APPLICATION_HANDLES_COMMAND_LINE);
|
||||||
|
g_signal_connect (application, "startup",
|
||||||
|
G_CALLBACK (application_startup_cb), shell);
|
||||||
|
g_signal_connect (application, "command-line",
|
||||||
|
G_CALLBACK (application_command_line_cb), shell);
|
||||||
|
|
||||||
|
status = g_application_run (G_APPLICATION (application), argc, argv);
|
||||||
|
|
||||||
g_object_unref (shell);
|
|
||||||
g_object_unref (application);
|
g_object_unref (application);
|
||||||
|
|
||||||
return 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -874,7 +874,6 @@ gnome_control_center_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (object)->priv;
|
GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (object)->priv;
|
||||||
|
|
||||||
|
|
||||||
if (priv->filter_string)
|
if (priv->filter_string)
|
||||||
{
|
{
|
||||||
g_free (priv->filter_string);
|
g_free (priv->filter_string);
|
||||||
|
@ -950,8 +949,7 @@ gnome_control_center_init (GnomeControlCenter *self)
|
||||||
|
|
||||||
/* connect various signals */
|
/* connect various signals */
|
||||||
priv->window = W (priv->builder, "main-window");
|
priv->window = W (priv->builder, "main-window");
|
||||||
g_signal_connect (priv->window, "delete-event", G_CALLBACK (gtk_main_quit),
|
g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self);
|
||||||
NULL);
|
|
||||||
|
|
||||||
priv->notebook = W (priv->builder, "notebook");
|
priv->notebook = W (priv->builder, "notebook");
|
||||||
|
|
||||||
|
@ -981,9 +979,6 @@ gnome_control_center_init (GnomeControlCenter *self)
|
||||||
/* setup search functionality */
|
/* setup search functionality */
|
||||||
setup_search (self);
|
setup_search (self);
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_show_all (priv->window);
|
|
||||||
|
|
||||||
/* store default window title and name */
|
/* store default window title and name */
|
||||||
priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
|
priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
|
||||||
priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));
|
priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));
|
||||||
|
@ -1000,3 +995,11 @@ gnome_control_center_present (GnomeControlCenter *center)
|
||||||
{
|
{
|
||||||
gtk_window_present (GTK_WINDOW (center->priv->window));
|
gtk_window_present (GTK_WINDOW (center->priv->window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gnome_control_center_show (GnomeControlCenter *center,
|
||||||
|
GtkApplication *app)
|
||||||
|
{
|
||||||
|
gtk_window_set_application (GTK_WINDOW (center->priv->window), app);
|
||||||
|
gtk_widget_show_all (center->priv->window);
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ GnomeControlCenter *gnome_control_center_new (void);
|
||||||
|
|
||||||
void gnome_control_center_present (GnomeControlCenter *center);
|
void gnome_control_center_present (GnomeControlCenter *center);
|
||||||
|
|
||||||
|
void gnome_control_center_show (GnomeControlCenter *center, GtkApplication *app);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _GNOME_CONTROL_CENTER_H */
|
#endif /* _GNOME_CONTROL_CENTER_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue