~walkerlee/totem/pre-interview

« back to all changes in this revision

Viewing changes to src/totem.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-26 00:07:51 UTC
  • mfrom: (1.6.1) (24.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130526000751-kv8ap3x1di4qq8j2
Tags: 3.8.2-0ubuntu1
* Sync with Debian. Remaining changes: 
* debian/control.in:
  - Drop build-depends on libepc-ui-dev and libgrilo-0.2-dev (in universe)
  - Drop libxtst-dev build-depends so that the (redundant) fake key presses
    for inhibiting the screensaver are disabled (LP: #1007438)
  - Build-depend on libzeitgeist-dev
  - Suggest rather than recommend gstreamer components in universe
  - Add totem-plugins-extra
  - Add XB-Npp-Description and XB-Npp-Filename header to the 
    totem-mozilla package to improve ubufox/ubuntu plugin db integration 
  - Refer to Firefox in totem-mozilla description instead of Iceweasel
  - Don't have totem-mozilla recommend any particular browser
  - Drop obsolete python library dependencies since iplayer is no longer
    included
* debian/totem-common.install, debian/source_totem.py:
  - Install Ubuntu apport debugging hook
* debian/totem-plugins-extra.install:
  - Universe plugins split out of totem-plugins (currently only gromit)
* debian/totem-plugins.install:    
  - Skip the plugins split to -extra and add the zeitgeist plugin
* debian/rules:
  - Build with --fail-missing, to ensure we install everything. 
    + Ignore libtotem.{,l}a since we delibrately don't install these.
  - Re-enable hardening, make sure both PIE and BINDNOW are used
    by setting hardening=+all. (LP: #1039604)
* debian/patches/91_quicklist_entries.patch:
  - Add static quicklist
* debian/patches/92_gst-plugins-good.patch:
  - Build without unnecessary gstreamer1.0-bad dependency
* debian/patches/93_grilo_optional.patch:
  - Allow building without grilo while grilo MIR is still pending
* debian/patches/correct_desktop_mimetypes.patch:
  - Don't list the mimetypes after the unity lists
* debian/patches/revert_shell_menu.patch: 
  - revert the use of a shell menu until indicator-appmenu can handle
    the mixed shell/traditional menus itself
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <glib-object.h>
33
33
#include <glib/gi18n.h>
34
34
#include <gtk/gtk.h>
 
35
#include <locale.h>
35
36
#include <string.h>
36
37
 
37
38
#ifdef GDK_WINDOWING_X11
38
39
/* X11 headers */
39
 
#include <gdk/gdkx.h>
40
40
#include <X11/Xlib.h>
41
41
#endif
42
42
 
53
53
 
54
54
static gboolean startup_called = FALSE;
55
55
 
56
 
static void
57
 
long_action (void)
58
 
{
59
 
        while (gtk_events_pending ())
60
 
                gtk_main_iteration ();
61
 
}
62
 
 
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. */
65
58
static void
80
73
static void
81
74
app_init (Totem *totem, char **argv)
82
75
{
 
76
        GtkSettings *gtk_settings;
83
77
        char *sidebar_pageid;
84
78
 
85
 
        /* Settings */
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.");
 
81
 
 
82
        gtk_settings = gtk_settings_get_default ();
 
83
        g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
87
84
 
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);
95
92
 
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);
97
95
 
98
96
        /* Menubar */
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);
 
118
 
121
119
        sidebar_pageid = totem_setup_window (totem);
122
120
 
123
 
        /* Show ! gtk_main_iteration trickery to show all the widgets
124
 
         * we have so far */
 
121
        /* Show ! */
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));
128
 
                long_action ();
129
125
        } else {
130
126
                gtk_widget_realize (totem->win);
131
127
        }
144
140
        }
145
141
 
146
142
        /* The prefs after the video widget is connected */
 
143
        totem->prefs_xml = totem_interface_load ("preferences.ui", TRUE, NULL, totem);
 
144
 
147
145
        totem_setup_preferences (totem);
148
146
 
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);
173
171
 
174
 
        gtk_window_set_application (GTK_WINDOW (totem->win), totem->app);
 
172
        gtk_window_set_application (GTK_WINDOW (totem->win), GTK_APPLICATION (totem));
175
173
}
176
174
 
177
175
static void
190
188
                  Totem                    *totem)
191
189
{
192
190
        GOptionContext *context;
193
 
        GOptionGroup *baconoptiongroup;
194
 
        GError *error = NULL;
195
191
        int argc;
196
192
        char **argv;
197
193
 
201
197
        memset (&optionstate, 0, sizeof (optionstate));
202
198
 
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);
209
 
                return 1;
210
 
        }
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);
214
 
 
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);
224
204
                return 1;
225
205
        }
226
206
        g_option_context_free (context);
227
207
 
 
208
        totem_options_process_early (totem, &optionstate);
 
209
 
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);
232
214
 
 
215
                gdk_notify_startup_complete ();
 
216
 
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;
237
 
        } else {
238
 
                gtk_window_present_with_time (GTK_WINDOW (totem->win), GDK_CURRENT_TIME);
239
221
        }
240
222
 
241
223
        /* Now do something with it */
249
231
main (int argc, char **argv)
250
232
{
251
233
        Totem *totem;
252
 
        GtkSettings *gtk_settings;
253
234
 
 
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)
260
242
        {
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);
264
246
        }
265
247
#endif
266
248
 
267
 
#if !GLIB_CHECK_VERSION (2, 31, 0)
268
 
        g_thread_init (NULL);
269
 
#endif
270
249
        g_type_init ();
271
 
        gtk_init (&argc, &argv);
272
250
 
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);
276
255
 
277
 
        gtk_settings = gtk_settings_get_default ();
278
 
        g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
279
 
 
280
256
 
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,
 
261
                              NULL);
 
262
        totem->settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
283
263
 
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);
289
268
 
290
 
        g_application_run (G_APPLICATION (totem->app), argc, argv);
 
269
        g_application_run (G_APPLICATION (totem), argc, argv);
291
270
 
292
271
        return 0;
293
272
}