]> git.0d.be Git - empathy.git/blob - src/empathy-debugger.c
Move should_create_salut_account to local-xmpp-assistant-widget
[empathy.git] / src / empathy-debugger.c
1 /*
2  * Copyright (C) 2005-2007 Imendio AB
3  * Copyright (C) 2007-2010 Collabora Ltd.
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <config.h>
21
22 #include <gtk/gtk.h>
23 #include <glib/gi18n.h>
24
25 #include <libempathy/empathy-utils.h>
26 #include <libempathy-gtk/empathy-ui-utils.h>
27
28 #include "empathy-debug-window.h"
29
30 #define EMPATHY_DEBUGGER_DBUS_NAME "org.gnome.Empathy.Debugger"
31
32 static GtkWidget *window = NULL;
33 static gchar *service = NULL;
34
35 static void
36 activate_cb (GApplication *app)
37 {
38   if (window == NULL)
39     {
40       window = empathy_debug_window_new (NULL);
41
42       gtk_application_add_window (GTK_APPLICATION (app),
43           GTK_WINDOW (window));
44     }
45   else
46     {
47       gtk_window_present (GTK_WINDOW (window));
48     }
49
50   if (service != NULL)
51     empathy_debug_window_show (EMPATHY_DEBUG_WINDOW (window),
52         service);
53 }
54
55 static gint
56 command_line_cb (GApplication *application,
57     GApplicationCommandLine *command_line,
58     gpointer user_data)
59 {
60   GError *error = NULL;
61   gchar **argv;
62   gint argc;
63   gint retval = 0;
64
65   GOptionContext *optcontext;
66   GOptionEntry options[] = {
67       { "show-service", 's',
68         0, G_OPTION_ARG_STRING, &service,
69         N_("Show a particular service"),
70         NULL },
71       { NULL }
72   };
73
74   optcontext = g_option_context_new (N_("- Empathy Debugger"));
75   g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
76   g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);
77
78   argv = g_application_command_line_get_arguments (command_line, &argc);
79
80   if (!g_option_context_parse (optcontext, &argc, &argv, &error))
81     {
82       g_print ("%s\nRun '%s --help' to see a full list of available command "
83           "line options.\n",
84           error->message, argv[0]);
85
86       retval = 1;
87     }
88
89   g_option_context_free (optcontext);
90   g_strfreev (argv);
91
92   g_application_activate (application);
93
94   return retval;
95 }
96
97 int
98 main (int argc,
99     char **argv)
100 {
101   GtkApplication *app;
102   gint retval;
103
104   g_thread_init (NULL);
105   gtk_init (&argc, &argv);
106   empathy_gtk_init ();
107
108   app = gtk_application_new (EMPATHY_DEBUGGER_DBUS_NAME,
109       G_APPLICATION_HANDLES_COMMAND_LINE);
110   g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);
111   g_signal_connect (app, "command-line", G_CALLBACK (command_line_cb), NULL);
112
113   g_set_application_name (_("Empathy Debugger"));
114
115   /* Make empathy and empathy-debugger appear as the same app in gnome-shell */
116   gdk_set_program_class ("Empathy");
117   gtk_window_set_default_icon_name ("empathy");
118   textdomain (GETTEXT_PACKAGE);
119
120   retval = g_application_run (G_APPLICATION (app), argc, argv);
121
122   g_object_unref (app);
123
124   return retval;
125 }