Back to index

bamf  0.2.120
main.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010-2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Jason Smith <jason.smith@canonical.com>
00017  *              Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com>
00018  *
00019  */
00020 
00021 #include "config.h"
00022 #include "bamf-daemon.h"
00023 #include "bamf-legacy-screen.h"
00024 
00025 #include "main.h"
00026 
00027 int
00028 main (int argc, char **argv)
00029 {
00030   BamfDaemon *daemon;
00031   GOptionContext *options;
00032   GError *error = NULL;
00033   char *state_file = NULL;
00034 
00035   gtk_init (&argc, &argv);
00036   glibtop_init ();
00037 
00038   options = g_option_context_new ("");
00039   g_option_context_set_help_enabled (options, TRUE);
00040   g_option_context_set_summary (options, "It's one, and so are we...");
00041 
00042   GOptionEntry entries[] =
00043   {
00044     {"load-file", 'l', 0, G_OPTION_ARG_STRING, &state_file, "Load bamf state from file instead of the system", NULL },
00045     {NULL}
00046   };
00047 
00048   g_option_context_add_main_entries (options, entries, NULL);
00049   g_option_context_add_group (options, gtk_get_option_group (FALSE));
00050   g_option_context_parse (options, &argc, &argv, &error);
00051 
00052   if (error)
00053     {
00054       g_print ("%s, error: %s\n", g_option_context_get_help (options, TRUE, NULL), error->message);
00055       g_clear_error (&error);
00056       exit (1);
00057     }
00058 
00059   if (state_file)
00060     {
00061       bamf_legacy_screen_set_state_file (bamf_legacy_screen_get_default (), state_file);
00062     }
00063 
00064   daemon = bamf_daemon_get_default ();
00065   bamf_daemon_start (daemon);
00066 
00067   g_object_unref (daemon);
00068 
00069   return 0;
00070 }