Fix broken markup in Finnish user docs translation
[nijm-empathy.git] / src / empathy-debugger.c
blob340b14ca49a6063ab85a4ac696d676afcc750b2a
1 /*
2 * Copyright (C) 2005-2007 Imendio AB
3 * Copyright (C) 2007-2010 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "config.h"
22 #include <glib/gi18n.h>
24 #include "empathy-bus-names.h"
25 #include "empathy-debug-window.h"
26 #include "empathy-ui-utils.h"
28 static GtkWidget *window = NULL;
29 static gchar *service = NULL;
31 static void
32 app_activate (GApplication *app)
34 if (window == NULL)
36 window = empathy_debug_window_new (NULL);
38 gtk_application_add_window (GTK_APPLICATION (app),
39 GTK_WINDOW (window));
41 else
43 gtk_window_present (GTK_WINDOW (window));
46 if (!tp_str_empty (service))
47 empathy_debug_window_show (EMPATHY_DEBUG_WINDOW (window),
48 service);
51 static void
52 on_show_service_cb (GAction *action,
53 GVariant *parameter,
54 gpointer data)
56 g_free (service);
57 service = g_variant_dup_string (parameter, NULL);
60 static gboolean
61 local_cmdline (GApplication *app,
62 gchar ***arguments,
63 gint *exit_status)
65 GError *error = NULL;
66 GSimpleAction *action;
67 gchar **argv;
68 gint argc = 0;
69 gint i;
70 gboolean retval = TRUE;
72 GOptionContext *optcontext;
73 GOptionEntry options[] = {
74 { "show-service", 's',
75 0, G_OPTION_ARG_STRING, &service,
76 N_("Show a particular service"),
77 NULL },
78 { NULL }
81 optcontext = g_option_context_new (N_("— Empathy Debugger"));
82 g_option_context_add_group (optcontext, gtk_get_option_group (FALSE));
83 g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);
84 g_option_context_set_translation_domain (optcontext, GETTEXT_PACKAGE);
86 action = g_simple_action_new ("show-service", G_VARIANT_TYPE_STRING);
87 g_signal_connect (action, "activate", G_CALLBACK (on_show_service_cb), app);
88 g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (action));
89 g_object_unref (action);
91 argv = *arguments;
92 for (i = 0; argv[i] != NULL; i++)
93 argc++;
95 if (!g_option_context_parse (optcontext, &argc, &argv, &error))
97 g_print ("%s\nRun '%s --help' to see a full list of available command "
98 "line options.\n",
99 error->message, argv[0]);
101 g_clear_error (&error);
102 *exit_status = EXIT_FAILURE;
104 else
106 if (g_application_register (app, NULL, &error))
108 GVariant *parameter = g_variant_new_string (service ? service : "");
109 g_action_group_activate_action (G_ACTION_GROUP (app), "show-service", parameter);
111 g_application_activate (app);
113 else
115 g_warning ("Impossible to register empathy-debugger: %s", error->message);
116 g_clear_error (&error);
117 *exit_status = EXIT_FAILURE;
121 g_option_context_free (optcontext);
123 return retval;
127 main (int argc,
128 char **argv)
130 GtkApplication *app;
131 GApplicationClass *app_class;
132 gint retval;
134 textdomain (GETTEXT_PACKAGE);
136 app = gtk_application_new (EMPATHY_DEBUGGER_BUS_NAME, G_APPLICATION_FLAGS_NONE);
137 app_class = G_APPLICATION_CLASS (G_OBJECT_GET_CLASS (app));
138 app_class->local_command_line = local_cmdline;
139 app_class->activate = app_activate;
141 g_set_application_name (_("Empathy Debugger"));
143 /* Make empathy and empathy-debugger appear as the same app in gnome-shell */
144 g_set_prgname ("empathy");
145 gtk_window_set_default_icon_name ("empathy");
147 retval = g_application_run (G_APPLICATION (app), argc, argv);
149 g_object_unref (app);
151 return retval;