You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

95 lines
2.9 KiB

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
  2. *
  3. * Copyright (C) 2008 Red Hat, Inc.
  4. * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. */
  21. #include "config.h"
  22. #include <glib.h>
  23. #include <glib/gi18n.h>
  24. #include <glib-object.h>
  25. #include <gtk/gtk.h>
  26. #include <libintl.h>
  27. #include <unique/uniqueapp.h>
  28. #include <libmatemixer/matemixer.h>
  29. #include "gvc-applet.h"
  30. static gboolean show_version = FALSE;
  31. static gboolean debug = FALSE;
  32. int
  33. main (int argc, char **argv)
  34. {
  35. GError *error = NULL;
  36. GvcApplet *applet;
  37. UniqueApp *app;
  38. GOptionEntry entries[] = {
  39. { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
  40. { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug"), NULL },
  41. { NULL }
  42. };
  43. bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
  44. bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  45. textdomain (GETTEXT_PACKAGE);
  46. gtk_init_with_args (&argc, &argv,
  47. _(" — MATE Volume Control Applet"),
  48. entries, GETTEXT_PACKAGE,
  49. &error);
  50. if (error != NULL) {
  51. g_warning ("%s", error->message);
  52. return 1;
  53. }
  54. if (show_version == TRUE) {
  55. g_print ("%s %s\n", argv[0], VERSION);
  56. return 0;
  57. }
  58. if (debug == TRUE) {
  59. g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
  60. }
  61. app = unique_app_new (GVC_APPLET_DBUS_NAME, NULL);
  62. if (unique_app_is_running (app) == TRUE) {
  63. g_warning ("Applet is already running, exiting");
  64. return 0;
  65. }
  66. if (mate_mixer_init () == FALSE) {
  67. g_warning ("libmatemixer initialization failed, exiting");
  68. return 1;
  69. }
  70. gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
  71. ICON_DATA_DIR);
  72. applet = gvc_applet_new ();
  73. gvc_applet_start (applet);
  74. gtk_main ();
  75. g_object_unref (applet);
  76. g_object_unref (app);
  77. return 0;
  78. }