54
54
static gboolean startup_called = FALSE;
59
while (gtk_events_pending ())
60
gtk_main_iteration ();
63
56
/* Debug log message handler: discards debug messages unless Totem is run with TOTEM_DEBUG=1.
64
57
* If we're building in the source tree, enable debug messages by default. */
81
74
app_init (Totem *totem, char **argv)
76
GtkSettings *gtk_settings;
83
77
char *sidebar_pageid;
86
totem->settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
79
if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
80
g_warning ("gtk-clutter failed to initialise, expect problems from here on.");
82
gtk_settings = gtk_settings_get_default ();
83
g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
88
85
/* Debug log handling */
89
86
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, (GLogFunc) debug_handler, totem->settings);
94
91
totem_action_exit (NULL);
96
93
totem->win = GTK_WIDGET (gtk_builder_get_object (totem->xml, "totem_main_window"));
94
gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (totem->win), TRUE);
99
97
totem_ui_manager_setup (totem);
116
114
totem_session_setup (totem, argv);
117
115
totem_setup_file_monitoring (totem);
118
116
totem_setup_file_filters ();
119
totem_setup_play_disc (totem);
120
117
totem_callback_connect (totem);
121
119
sidebar_pageid = totem_setup_window (totem);
123
/* Show ! gtk_main_iteration trickery to show all the widgets
125
122
if (optionstate.fullscreen == FALSE) {
126
123
gtk_widget_show (totem->win);
127
124
totem_gdk_window_set_waiting_cursor (gtk_widget_get_window (totem->win));
130
126
gtk_widget_realize (totem->win);
146
142
/* The prefs after the video widget is connected */
143
totem->prefs_xml = totem_interface_load ("preferences.ui", TRUE, NULL, totem);
147
145
totem_setup_preferences (totem);
149
147
totem_setup_recent (totem);
171
169
if (optionstate.fullscreen == FALSE)
172
170
gdk_window_set_cursor (gtk_widget_get_window (totem->win), NULL);
174
gtk_window_set_application (GTK_WINDOW (totem->win), totem->app);
172
gtk_window_set_application (GTK_WINDOW (totem->win), GTK_APPLICATION (totem));
201
197
memset (&optionstate, 0, sizeof (optionstate));
203
199
/* Options parsing */
204
context = g_option_context_new (N_("- Play movies and songs"));
205
baconoptiongroup = bacon_video_widget_get_option_group();
206
if (baconoptiongroup == NULL) {
207
g_warning ("Clutter or GTK+ failed to initialise properly");
208
g_option_context_free (context);
211
g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
212
g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
213
g_option_context_add_group (context, baconoptiongroup);
215
g_option_context_add_group (context, gtk_get_option_group (TRUE));
216
/* Only add session options to the server process */
217
if (startup_called != FALSE)
218
totem_session_add_options (context);
219
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
220
g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
221
error->message, argv[0]);
222
g_error_free (error);
200
context = totem_options_get_context ();
201
g_option_context_set_help_enabled (context, FALSE);
202
if (g_option_context_parse (context, &argc, &argv, NULL) == FALSE) {
223
203
g_option_context_free (context);
226
206
g_option_context_free (context);
208
totem_options_process_early (totem, &optionstate);
228
210
/* Don't create another window if we're remote.
229
211
* We can't use g_application_get_is_remote() because it's not registered yet */
230
212
if (startup_called != FALSE) {
231
213
app_init (totem, argv);
215
gdk_notify_startup_complete ();
233
217
/* Don't add files again through totem_options_process_for_server() */
234
218
g_strfreev (optionstate.filenames);
235
219
optionstate.filenames = NULL;
236
220
startup_called = FALSE;
238
gtk_window_present_with_time (GTK_WINDOW (totem->win), GDK_CURRENT_TIME);
241
223
/* Now do something with it */
249
231
main (int argc, char **argv)
252
GtkSettings *gtk_settings;
235
setlocale (LC_ALL, "");
254
236
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
255
237
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
256
238
textdomain (GETTEXT_PACKAGE);
259
241
if (XInitThreads () == 0)
261
243
gtk_init (&argc, &argv);
262
g_set_application_name (_("Totem Movie Player"));
244
g_set_application_name (_("Videos"));
263
245
totem_action_error_and_exit (_("Could not initialize the thread-safe libraries."), _("Verify your system installation. Totem will now exit."), NULL);
267
#if !GLIB_CHECK_VERSION (2, 31, 0)
268
g_thread_init (NULL);
271
gtk_init (&argc, &argv);
273
g_set_application_name (_("Totem Movie Player"));
251
g_set_prgname ("totem");
252
g_set_application_name (_("Videos"));
274
253
gtk_window_set_default_icon_name ("totem");
275
254
g_setenv("PULSE_PROP_media.role", "video", TRUE);
277
gtk_settings = gtk_settings_get_default ();
278
g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
281
257
/* Build the main Totem object */
282
totem = g_object_new (TOTEM_TYPE_OBJECT, NULL);
258
totem = g_object_new (TOTEM_TYPE_OBJECT,
259
"application-id", "org.gnome.Totem",
260
"flags", G_APPLICATION_HANDLES_COMMAND_LINE,
262
totem->settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
284
totem->app = gtk_application_new ("org.gnome.Totem", G_APPLICATION_HANDLES_COMMAND_LINE);
285
g_signal_connect (G_OBJECT (totem->app), "startup",
264
g_signal_connect (G_OBJECT (totem), "startup",
286
265
G_CALLBACK (app_startup), totem);
287
g_signal_connect (G_OBJECT (totem->app), "command-line",
266
g_signal_connect (G_OBJECT (totem), "command-line",
288
267
G_CALLBACK (app_command_line), totem);
290
g_application_run (G_APPLICATION (totem->app), argc, argv);
269
g_application_run (G_APPLICATION (totem), argc, argv);