~ubuntu-branches/ubuntu/precise/cheese/precise-proposed

« back to all changes in this revision

Viewing changes to src/cheese.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Jeremy Bicha, Robert Ancell
  • Date: 2011-06-10 11:45:37 UTC
  • mfrom: (1.2.24 upstream)
  • Revision ID: james.westby@ubuntu.com-20110610114537-p9e4zl8m0ehf2b5a
Tags: 3.0.0-0ubuntu1
* Upload to oneiric

[ Jeremy Bicha ]
* Depend on gnome-video-effects since clicking Effects when it is
  not installed results in a segmentation fault.

[ Robert Ancell]
* New upstream version
* debian/control:
  - Use standards version 3.9.1
  - Add build-depends on dh-autoreconf, valac, libclutter-1.0-dev,
    libclutter-gtk-1.0-dev, libclutter-gst-dev, libmx-dev,
    gnome-video-effects-dev, libgee-dev, gnome-common, gobject-introspection, 
    libgirepository1.0-dev, gir1.2-freedesktop, gir1.2-glib-2.0, 
    gir1.2-gstreamer-0.10, gir1.2-clutter-1.0, gir1.2-gdkpixbuf-2.0
  - Drop build-depends on libgconf2-dev, libdbus-1-dev, libdbus-glib-1-dev,
  - Bump build-depends on libglib2.0-dev, libgtk-3-dev,
    libgnome-desktop-3-dev, libgstreamer0.10-dev,
    libgstreamer-plugins-base0.10-dev, libcairo2-dev, libpango1.0-dev,
    librsvg2-dev, libcanberra-gtk3-dev
  - Add new gir1.2-cheese-3.0 package
  - libcheese-gtk18 -> libcheese-gtk19
* debian/cheese.install:
* debian/cheese-common.install:
* debian/libcheese-gtk-dev.install
  - Update for new/changed files
* debian/gir1.2-cheese-3.0.install:
  - Install typelib
* debian/patches/fix-linking.patch:
  - Fix linking issues
* debian/patches/no-gnu-gettext.patch:
  - Don't use both AM_GNU_GETTEXT and IT_PROG_INTLTOOL

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2007-2009 daniel g. siegel <dgsiegel@gnome.org>
3
 
 * Copyright © 2007,2008 Jaap Haitsma <jaap@haitsma.org>
4
 
 * Copyright © 2008 Felix Kaser <f.kaser@gmx.net>
5
 
 *
6
 
 * Licensed under the GNU General Public License Version 2
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or modify
9
 
 * it under the terms of the GNU General Public License as published by
10
 
 * the Free Software Foundation; either version 2 of the License, or
11
 
 * (at your option) any later version.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
 */
21
 
 
22
 
#ifdef HAVE_CONFIG_H
23
 
  #include <cheese-config.h>
24
 
#endif
25
 
 
26
 
#include <glib.h>
27
 
#include <glib/gi18n.h>
28
 
#include <gio/gio.h>
29
 
#include <gtk/gtk.h>
30
 
#include <gst/gst.h>
31
 
#include <librsvg/rsvg.h>
32
 
 
33
 
#include "cheese-fileutil.h"
34
 
#include "cheese-window.h"
35
 
#include "cheese-dbus.h"
36
 
 
37
 
struct _CheeseOptions
38
 
{
39
 
  gboolean verbose;
40
 
  gboolean wide_mode;
41
 
  gboolean version;
42
 
} CheeseOptions;
43
 
 
44
 
void
45
 
cheese_print_handler (char *string)
46
 
{
47
 
  static FILE *fp = NULL;
48
 
  GDir        *dir;
49
 
  char        *filename, *path;
50
 
 
51
 
  CheeseFileUtil *fileutil = cheese_fileutil_new ();
52
 
 
53
 
  if (CheeseOptions.verbose)
54
 
    fprintf (stdout, "%s", string);
55
 
 
56
 
  if (fp == NULL)
57
 
  {
58
 
    path = cheese_fileutil_get_log_path (fileutil);
59
 
 
60
 
    dir = g_dir_open (path, 0, NULL);
61
 
    if (!dir)
62
 
    {
63
 
      return;
64
 
    }
65
 
 
66
 
    /* remove the old logfile if it exists */
67
 
    filename = g_build_filename (path, "log", NULL);
68
 
    if (g_file_test (filename, G_FILE_TEST_EXISTS))
69
 
    {
70
 
      GFile *old = g_file_new_for_path (filename);
71
 
      g_file_delete (old, NULL, NULL);
72
 
      g_object_unref (old);
73
 
    }
74
 
    g_free (filename);
75
 
 
76
 
    filename = g_build_filename (path, "log.txt", NULL);
77
 
    fp       = fopen (filename, "w");
78
 
    fputs ("Cheese " VERSION "\n\n", fp);
79
 
 
80
 
    g_object_unref (fileutil);
81
 
    g_free (filename);
82
 
  }
83
 
 
84
 
  if (fp)
85
 
    fputs (string, fp);
86
 
}
87
 
 
88
 
int
89
 
main (int argc, char **argv)
90
 
{
91
 
  GOptionContext *context;
92
 
  CheeseDbus     *dbus_server;
93
 
  GError         *error = NULL;
94
 
 
95
 
  GOptionEntry options[] = {
96
 
    {"verbose",    'v', 0,                    G_OPTION_ARG_NONE,   &CheeseOptions.verbose,
97
 
     _("Be verbose"), NULL},
98
 
    {"wide",       'w', 0,                    G_OPTION_ARG_NONE,   &CheeseOptions.wide_mode,
99
 
     _("Enable wide mode"), NULL},
100
 
    {"version",    0,   0,                    G_OPTION_ARG_NONE,   &CheeseOptions.version,
101
 
     _("output version information and exit"), NULL},
102
 
    {NULL}
103
 
  };
104
 
 
105
 
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
106
 
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
107
 
  textdomain (GETTEXT_PACKAGE);
108
 
 
109
 
  gtk_rc_parse (APPNAME_DATA_DIR G_DIR_SEPARATOR_S "gtkrc");
110
 
 
111
 
  g_thread_init (NULL);
112
 
  gdk_threads_init ();
113
 
 
114
 
  /* initialize rsvg */
115
 
  /* needed to load the camera icon for the countdown widget */
116
 
  rsvg_init ();
117
 
 
118
 
  g_set_application_name (_("Cheese"));
119
 
 
120
 
  context = g_option_context_new (N_("- Take photos and videos with your webcam, with fun graphical effects"));
121
 
  g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
122
 
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
123
 
  g_option_context_add_group (context, gst_init_get_option_group ());
124
 
  if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
125
 
  {
126
 
    gchar *help_text = g_option_context_get_help (context, TRUE, NULL);
127
 
    g_print ("%s\n\n%s", error->message, help_text);
128
 
    g_free (help_text);
129
 
    g_error_free (error);
130
 
    g_option_context_free (context);
131
 
    return -1;
132
 
  }
133
 
  g_option_context_free (context);
134
 
 
135
 
  if (CheeseOptions.version)
136
 
  {
137
 
    g_print ("Cheese " VERSION " \n");
138
 
    return 0;
139
 
  }
140
 
 
141
 
  dbus_server = cheese_dbus_new ();
142
 
  if (dbus_server == NULL)
143
 
  {
144
 
    gdk_notify_startup_complete ();
145
 
    return -1;
146
 
  }
147
 
 
148
 
  g_set_print_handler ((GPrintFunc) cheese_print_handler);
149
 
  g_print ("Cheese " VERSION " \n");
150
 
 
151
 
  gtk_window_set_default_icon_name ("cheese");
152
 
  gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
153
 
                                     APPNAME_DATA_DIR G_DIR_SEPARATOR_S "icons");
154
 
 
155
 
  CheeseWindow *window = g_object_new (CHEESE_TYPE_WINDOW,
156
 
                                       "startup-wide", CheeseOptions.wide_mode,
157
 
                                       NULL);
158
 
 
159
 
  cheese_dbus_set_window (window);
160
 
 
161
 
  gtk_widget_show (GTK_WIDGET (window));
162
 
 
163
 
  gdk_threads_enter ();
164
 
  gtk_main ();
165
 
  gdk_threads_leave ();
166
 
 
167
 
  /* cleanup rsvg */
168
 
  /* Note: this function is bad with multithread applications as it
169
 
   * calls xmlCleanupParser() and should be only called right before
170
 
   * exit */
171
 
  rsvg_term ();
172
 
 
173
 
  return 0;
174
 
}