hythmbox-2.98/shell/main.c

No issues found

  1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2  *
  3  *  Copyright (C) 2002 Jorn Baayen
  4  *  Copyright (C) 2003,2004 Colin Walters <walters@gnome.org>
  5  *
  6  *  This program is free software; you can redistribute it and/or modify
  7  *  it under the terms of the GNU General Public License as published by
  8  *  the Free Software Foundation; either version 2, or (at your option)
  9  *  any later version.
 10  *
 11  *  The Rhythmbox authors hereby grant permission for non-GPL compatible
 12  *  GStreamer plugins to be used and distributed together with GStreamer
 13  *  and Rhythmbox. This permission is above and beyond the permissions granted
 14  *  by the GPL license by which Rhythmbox is covered. If you modify this code
 15  *  you may extend this exception to your version of the code, but you are not
 16  *  obligated to do so. If you do not wish to do so, delete this exception
 17  *  statement from your version.
 18  *
 19  *  This program is distributed in the hope that it will be useful,
 20  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 21  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 22  *  GNU General Public License for more details.
 23  *
 24  *  You should have received a copy of the GNU General Public License
 25  *  along with this program; if not, write to the Free Software
 26  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 27  *
 28  */
 29 
 30 #include <config.h>
 31 
 32 #include <locale.h>
 33 
 34 #include <glib/gi18n.h>
 35 #include <gtk/gtk.h>
 36 
 37 #ifdef GDK_WINDOWING_X11
 38 /* X11 headers */
 39 #include <X11/Xlib.h>
 40 #endif
 41 
 42 #include <girepository.h>
 43 
 44 #include "rb-shell.h"
 45 #include "rb-util.h"
 46 #include "eggdesktopfile.h"
 47 #include "eggsmclient.h"
 48 #include "rb-debug.h"
 49 
 50 int
 51 main (int argc, char **argv)
 52 {
 53 	RBShell *shell;
 54 	gboolean autostarted;
 55 	char *desktop_file_path;
 56 	int new_argc;
 57 	char **new_argv;
 58 
 59 #ifdef GDK_WINDOWING_X11
 60 	if (XInitThreads () == 0) {
 61 		g_critical ("Initialising threading support failed.");
 62 		return 1;
 63 	}
 64 #endif
 65 
 66 	/* disable multidevice so clutter-gtk events work.
 67 	 * this needs to be done before gtk_open, so the visualizer
 68 	 * plugin can't do it.
 69 	 */
 70 	gdk_disable_multidevice ();
 71 	g_type_init ();
 72 	g_random_set_seed (time (0));
 73 
 74 	autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL);
 75 
 76 #ifdef USE_UNINSTALLED_DIRS
 77 	desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL);
 78 
 79 	g_setenv ("GSETTINGS_SCHEMA_DIR", SHARE_UNINSTALLED_BUILDDIR, TRUE);
 80 #else
 81 	desktop_file_path = g_build_filename (DATADIR, "applications", "rhythmbox.desktop", NULL);
 82 #endif
 83 	egg_set_desktop_file (desktop_file_path);
 84 	g_free (desktop_file_path);
 85 
 86 	setlocale (LC_ALL, NULL);
 87 
 88 #ifdef ENABLE_NLS
 89 	/* initialize i18n */
 90 	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 91 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 92 
 93 	textdomain (GETTEXT_PACKAGE);
 94 #endif
 95 
 96 #if defined(USE_UNINSTALLED_DIRS)
 97 	g_irepository_prepend_search_path (SHARE_UNINSTALLED_BUILDDIR "/../bindings/gi");
 98 #endif
 99 
100 	/* TODO: kill this function */
101 	rb_threads_init ();
102 	if (glib_check_version (2, 31, 1) != NULL) {
103 		gdk_threads_enter ();
104 	}
105 
106 	new_argc = argc;
107 	new_argv = argv;
108 	shell = rb_shell_new (autostarted, &argc, &argv);
109 
110 	g_application_run (G_APPLICATION (shell), new_argc, new_argv);
111 
112 	g_object_unref (shell);
113 
114 	if (glib_check_version (2, 31, 1) != NULL) {
115 		gdk_threads_leave ();
116 	}
117 
118 	exit (0);
119 }