~walkerlee/totem/pre-interview

« back to all changes in this revision

Viewing changes to .pc/revert_shell_menu.patch/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:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
/* 
 
3
 * Copyright (C) 2001-2007 Bastien Nocera <hadess@hadess.net>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 
18
 *
 
19
 * The Totem project hereby grant permission for non-gpl compatible GStreamer
 
20
 * plugins to be used and distributed together with GStreamer and Totem. This
 
21
 * permission are above and beyond the permissions granted by the GPL license
 
22
 * Totem is covered by.
 
23
 *
 
24
 * Monday 7th February 2005: Christian Schaller: Add exception clause.
 
25
 * See license_change file for details.
 
26
 *
 
27
 */
 
28
 
 
29
#include "config.h"
 
30
 
 
31
#include <glib.h>
 
32
#include <glib-object.h>
 
33
#include <glib/gi18n.h>
 
34
#include <gtk/gtk.h>
 
35
#include <locale.h>
 
36
#include <string.h>
 
37
 
 
38
#ifdef GDK_WINDOWING_X11
 
39
/* X11 headers */
 
40
#include <X11/Xlib.h>
 
41
#endif
 
42
 
 
43
#include "totem.h"
 
44
#include "totem-private.h"
 
45
#include "totem-interface.h"
 
46
#include "totem-options.h"
 
47
#include "totem-menu.h"
 
48
#include "totem-session.h"
 
49
#include "totem-uri.h"
 
50
#include "totem-preferences.h"
 
51
#include "totem-sidebar.h"
 
52
#include "video-utils.h"
 
53
 
 
54
static gboolean startup_called = FALSE;
 
55
 
 
56
/* Debug log message handler: discards debug messages unless Totem is run with TOTEM_DEBUG=1.
 
57
 * If we're building in the source tree, enable debug messages by default. */
 
58
static void
 
59
debug_handler (const char *log_domain,
 
60
               GLogLevelFlags log_level,
 
61
               const char *message,
 
62
               GSettings *settings)
 
63
{
 
64
        static int debug = -1;
 
65
 
 
66
        if (debug < 0)
 
67
                debug = g_settings_get_boolean (settings, "debug");
 
68
 
 
69
        if (debug)
 
70
                g_log_default_handler (log_domain, log_level, message, NULL);
 
71
}
 
72
 
 
73
static void
 
74
app_init (Totem *totem, char **argv)
 
75
{
 
76
        GtkSettings *gtk_settings;
 
77
        char *sidebar_pageid;
 
78
 
 
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);
 
84
 
 
85
        /* Debug log handling */
 
86
        g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, (GLogFunc) debug_handler, totem->settings);
 
87
 
 
88
        /* Main window */
 
89
        totem->xml = totem_interface_load ("totem.ui", TRUE, NULL, totem);
 
90
        if (totem->xml == NULL)
 
91
                totem_action_exit (NULL);
 
92
 
 
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);
 
95
        g_object_bind_property (G_OBJECT (totem), "fullscreen",
 
96
                                G_OBJECT (totem->win), "show-menubar",
 
97
                                G_BINDING_INVERT_BOOLEAN);
 
98
 
 
99
        /* Menubar */
 
100
        totem_ui_manager_setup (totem);
 
101
 
 
102
        /* The sidebar */
 
103
        playlist_widget_setup (totem);
 
104
 
 
105
        /* The rest of the widgets */
 
106
        totem->state = STATE_STOPPED;
 
107
        totem->seek = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_seek_hscale"));
 
108
        totem->seekadj = gtk_range_get_adjustment (GTK_RANGE (totem->seek));
 
109
        totem->volume = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_volume_button"));
 
110
        totem->statusbar = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_statusbar"));
 
111
        totem->seek_lock = FALSE;
 
112
        totem->fs = totem_fullscreen_new (GTK_WINDOW (totem->win));
 
113
        gtk_scale_button_set_adjustment (GTK_SCALE_BUTTON (totem->fs->volume),
 
114
                                         gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (totem->volume)));
 
115
        gtk_range_set_adjustment (GTK_RANGE (totem->fs->seek), totem->seekadj);
 
116
 
 
117
        totem_session_setup (totem, argv);
 
118
        totem_setup_file_monitoring (totem);
 
119
        totem_setup_file_filters ();
 
120
        totem_app_menu_setup (totem);
 
121
        totem_callback_connect (totem);
 
122
 
 
123
        sidebar_pageid = totem_setup_window (totem);
 
124
 
 
125
        /* Show ! */
 
126
        if (optionstate.fullscreen == FALSE) {
 
127
                gtk_widget_show (totem->win);
 
128
                totem_gdk_window_set_waiting_cursor (gtk_widget_get_window (totem->win));
 
129
        } else {
 
130
                gtk_widget_realize (totem->win);
 
131
        }
 
132
 
 
133
        totem->controls_visibility = TOTEM_CONTROLS_UNDEFINED;
 
134
 
 
135
        /* Show ! (again) the video widget this time. */
 
136
        video_widget_create (totem);
 
137
        gtk_widget_grab_focus (GTK_WIDGET (totem->bvw));
 
138
        totem_fullscreen_set_video_widget (totem->fs, totem->bvw);
 
139
 
 
140
        if (optionstate.fullscreen != FALSE) {
 
141
                gtk_widget_show (totem->win);
 
142
                gdk_flush ();
 
143
                totem_action_fullscreen (totem, TRUE);
 
144
        }
 
145
 
 
146
        /* The prefs after the video widget is connected */
 
147
        totem->prefs_xml = totem_interface_load ("preferences.ui", TRUE, NULL, totem);
 
148
 
 
149
        totem_setup_preferences (totem);
 
150
 
 
151
        totem_setup_recent (totem);
 
152
 
 
153
        /* Command-line handling */
 
154
        totem_options_process_late (totem, &optionstate);
 
155
 
 
156
        /* Initialise all the plugins, and set the default page, in case
 
157
         * it comes from a plugin */
 
158
        totem_object_plugins_init (totem);
 
159
        totem_sidebar_set_current_page (totem, sidebar_pageid, FALSE);
 
160
        g_free (sidebar_pageid);
 
161
 
 
162
        if (totem->session_restored != FALSE) {
 
163
                totem_session_restore (totem, optionstate.filenames);
 
164
        } else if (optionstate.filenames != NULL && totem_action_open_files (totem, optionstate.filenames)) {
 
165
                totem_action_play_pause (totem);
 
166
        } else {
 
167
                totem_action_set_mrl (totem, NULL, NULL);
 
168
        }
 
169
 
 
170
        /* Set the logo at the last minute so we won't try to show it before a video */
 
171
        bacon_video_widget_set_logo (totem->bvw, "totem");
 
172
 
 
173
        if (optionstate.fullscreen == FALSE)
 
174
                gdk_window_set_cursor (gtk_widget_get_window (totem->win), NULL);
 
175
 
 
176
        gtk_window_set_application (GTK_WINDOW (totem->win), GTK_APPLICATION (totem));
 
177
}
 
178
 
 
179
static void
 
180
app_startup (GApplication *application,
 
181
                Totem        *totem)
 
182
{
 
183
        /* We don't do anything here, as we need to know the options
 
184
         * when we set everything up.
 
185
         * Note that this will break D-Bus activation of the application */
 
186
        startup_called = TRUE;
 
187
}
 
188
 
 
189
static int
 
190
app_command_line (GApplication             *app,
 
191
                  GApplicationCommandLine  *command_line,
 
192
                  Totem                    *totem)
 
193
{
 
194
        GOptionContext *context;
 
195
        int argc;
 
196
        char **argv;
 
197
 
 
198
        argv = g_application_command_line_get_arguments (command_line, &argc);
 
199
 
 
200
        /* Reset the options, if they were used before */
 
201
        memset (&optionstate, 0, sizeof (optionstate));
 
202
 
 
203
        /* Options parsing */
 
204
        context = totem_options_get_context ();
 
205
        g_option_context_set_help_enabled (context, FALSE);
 
206
        if (g_option_context_parse (context, &argc, &argv, NULL) == FALSE) {
 
207
                g_option_context_free (context);
 
208
                return 1;
 
209
        }
 
210
        g_option_context_free (context);
 
211
 
 
212
        totem_options_process_early (totem, &optionstate);
 
213
 
 
214
        /* Don't create another window if we're remote.
 
215
         * We can't use g_application_get_is_remote() because it's not registered yet */
 
216
        if (startup_called != FALSE) {
 
217
                app_init (totem, argv);
 
218
 
 
219
                gdk_notify_startup_complete ();
 
220
 
 
221
                /* Don't add files again through totem_options_process_for_server() */
 
222
                g_strfreev (optionstate.filenames);
 
223
                optionstate.filenames = NULL;
 
224
                startup_called = FALSE;
 
225
        }
 
226
 
 
227
        /* Now do something with it */
 
228
        totem_options_process_for_server (totem, &optionstate);
 
229
 
 
230
        g_strfreev (argv);
 
231
        return 0;
 
232
}
 
233
 
 
234
int
 
235
main (int argc, char **argv)
 
236
{
 
237
        Totem *totem;
 
238
 
 
239
        setlocale (LC_ALL, "");
 
240
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
241
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
242
        textdomain (GETTEXT_PACKAGE);
 
243
 
 
244
#ifdef GDK_WINDOWING_X11
 
245
        if (XInitThreads () == 0)
 
246
        {
 
247
                gtk_init (&argc, &argv);
 
248
                g_set_application_name (_("Videos"));
 
249
                totem_action_error_and_exit (_("Could not initialize the thread-safe libraries."), _("Verify your system installation. Totem will now exit."), NULL);
 
250
        }
 
251
#endif
 
252
 
 
253
        g_type_init ();
 
254
 
 
255
        g_set_prgname ("totem");
 
256
        g_set_application_name (_("Videos"));
 
257
        gtk_window_set_default_icon_name ("totem");
 
258
        g_setenv("PULSE_PROP_media.role", "video", TRUE);
 
259
 
 
260
 
 
261
        /* Build the main Totem object */
 
262
        totem = g_object_new (TOTEM_TYPE_OBJECT,
 
263
                              "application-id", "org.gnome.Totem",
 
264
                              "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
 
265
                              NULL);
 
266
        totem->settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
 
267
 
 
268
        g_signal_connect (G_OBJECT (totem), "startup",
 
269
                          G_CALLBACK (app_startup), totem);
 
270
        g_signal_connect (G_OBJECT (totem), "command-line",
 
271
                          G_CALLBACK (app_command_line), totem);
 
272
 
 
273
        g_application_run (G_APPLICATION (totem), argc, argv);
 
274
 
 
275
        return 0;
 
276
}