File: | src/main.c |
Warning: | line 67, column 9 This statement is never executed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* Eye Of Cafe - Main |
2 | * |
3 | * Copyright (C) 2000-2006 The Free Software Foundation |
4 | * |
5 | * Author: Lucas Rocha <lucasr@gnome.org> |
6 | * |
7 | * Based on code by: |
8 | * - Federico Mena-Quintero <federico@gnu.org> |
9 | * - Jens Finke <jens@gnome.org> |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. |
15 | * |
16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
24 | */ |
25 | |
26 | #ifdef HAVE_CONFIG_H1 |
27 | #include "config.h" |
28 | #endif |
29 | #ifdef HAVE_INTROSPECTION1 |
30 | #include <girepository.h> |
31 | #endif |
32 | |
33 | #include "eoc-session.h" |
34 | #include "eoc-debug.h" |
35 | #include "eoc-thumbnail.h" |
36 | #include "eoc-job-queue.h" |
37 | #include "eoc-application.h" |
38 | #include "eoc-application-internal.h" |
39 | #include "eoc-util.h" |
40 | |
41 | #include <string.h> |
42 | #include <stdlib.h> |
43 | #include <glib/gi18n.h> |
44 | |
45 | #if HAVE_EXEMPI1 |
46 | #include <exempi/xmp.h> |
47 | #endif |
48 | |
49 | #define EOC_CSS_FILE_PATH"/usr/local/share/eoc" "/" "eoc.css" EOC_DATA_DIR"/usr/local/share/eoc" G_DIR_SEPARATOR_S"/" "eoc.css" |
50 | |
51 | static EocStartupFlags flags; |
52 | |
53 | static gboolean fullscreen = FALSE(0); |
54 | static gboolean slide_show = FALSE(0); |
55 | static gboolean disable_collection = FALSE(0); |
56 | static gboolean force_new_instance = FALSE(0); |
57 | static gchar **startup_files = NULL((void*)0); |
58 | |
59 | static gboolean |
60 | _print_version_and_exit (const gchar *option_name, |
61 | const gchar *value, |
62 | gpointer data, |
63 | GError **error) |
64 | { |
65 | g_print("%s %s\n", _("Eye of CAFE Image Viewer")gettext ("Eye of CAFE Image Viewer"), VERSION"1.25.0"); |
66 | exit (EXIT_SUCCESS0); |
67 | return TRUE(!(0)); |
This statement is never executed | |
68 | } |
69 | |
70 | static const GOptionEntry goption_options[] = |
71 | { |
72 | { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) }, |
73 | { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) }, |
74 | { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) }, |
75 | { "new-instance", 'n', 0, G_OPTION_ARG_NONE, &force_new_instance, N_("Start a new instance instead of reusing an existing one")("Start a new instance instead of reusing an existing one"), NULL((void*)0) }, |
76 | { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, |
77 | _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)}, |
78 | { NULL((void*)0) } |
79 | }; |
80 | |
81 | static void |
82 | set_startup_flags (void) |
83 | { |
84 | if (fullscreen) |
85 | flags |= EOC_STARTUP_FULLSCREEN; |
86 | |
87 | if (disable_collection) |
88 | flags |= EOC_STARTUP_DISABLE_COLLECTION; |
89 | |
90 | if (slide_show) |
91 | flags |= EOC_STARTUP_SLIDE_SHOW; |
92 | } |
93 | |
94 | int |
95 | main (int argc, char **argv) |
96 | { |
97 | GError *error = NULL((void*)0); |
98 | GOptionContext *ctx; |
99 | GFile *css_file; |
100 | CtkCssProvider *provider; |
101 | |
102 | bindtextdomain (GETTEXT_PACKAGE"eoc", EOC_LOCALE_DIR"/usr/local/share/locale"); |
103 | bind_textdomain_codeset (GETTEXT_PACKAGE"eoc", "UTF-8"); |
104 | textdomain (GETTEXT_PACKAGE"eoc"); |
105 | |
106 | cdk_set_allowed_backends ("wayland,x11"); |
107 | |
108 | ctx = g_option_context_new (_("[FILE…]")gettext ("[FILE…]")); |
109 | g_option_context_add_main_entries (ctx, goption_options, PACKAGE"eoc"); |
110 | /* Option groups are free'd together with the context |
111 | * Using ctk_get_option_group here initializes ctk during parsing */ |
112 | g_option_context_add_group (ctx, ctk_get_option_group (TRUE(!(0)))); |
113 | #ifdef HAVE_INTROSPECTION1 |
114 | g_option_context_add_group (ctx, g_irepository_get_option_group ()); |
115 | #endif |
116 | |
117 | if (!g_option_context_parse (ctx, &argc, &argv, &error)) { |
118 | gchar *help_msg; |
119 | |
120 | /* I18N: The '%s' is replaced with eoc's command name. */ |
121 | help_msg = g_strdup_printf (_("Run '%s --help' to see a full "gettext ("Run '%s --help' to see a full " "list of available command line " "options.") |
122 | "list of available command line "gettext ("Run '%s --help' to see a full " "list of available command line " "options.") |
123 | "options.")gettext ("Run '%s --help' to see a full " "list of available command line " "options."), argv[0]); |
124 | g_printerr ("%s\n%s\n", error->message, help_msg); |
125 | g_error_free (error); |
126 | g_free (help_msg); |
127 | g_option_context_free (ctx); |
128 | |
129 | return 1; |
130 | } |
131 | g_option_context_free (ctx); |
132 | |
133 | |
134 | set_startup_flags (); |
135 | |
136 | #ifdef HAVE_EXEMPI1 |
137 | xmp_init(); |
138 | #endif |
139 | eoc_debug_init (); |
140 | eoc_job_queue_init (); |
141 | eoc_thumbnail_init (); |
142 | |
143 | /* Load special style properties for EocThumbView's scrollbar */ |
144 | css_file = g_file_new_for_uri ("resource:///org/cafe/eoc/ui/eoc.css"); |
145 | provider = ctk_css_provider_new (); |
146 | if (G_UNLIKELY (!ctk_css_provider_load_from_file(provider,(!ctk_css_provider_load_from_file(provider, css_file, &error )) |
147 | css_file,(!ctk_css_provider_load_from_file(provider, css_file, &error )) |
148 | &error))(!ctk_css_provider_load_from_file(provider, css_file, &error ))) |
149 | { |
150 | g_critical ("Could not load CSS data: %s", error->message); |
151 | g_clear_error (&error); |
152 | } else { |
153 | ctk_style_context_add_provider_for_screen ( |
154 | cdk_screen_get_default(), |
155 | CTK_STYLE_PROVIDER (provider)((((CtkStyleProvider*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((provider)), ((ctk_style_provider_get_type ( ))))))), |
156 | CTK_STYLE_PROVIDER_PRIORITY_APPLICATION600); |
157 | } |
158 | g_object_unref (provider); |
159 | g_object_unref (css_file); |
160 | |
161 | /* Add application specific icons to search path */ |
162 | ctk_icon_theme_append_search_path (ctk_icon_theme_get_default (), |
163 | EOC_DATA_DIR"/usr/local/share/eoc" G_DIR_SEPARATOR_S"/" "icons"); |
164 | |
165 | ctk_window_set_default_icon_name ("eoc"); |
166 | g_set_application_name (_("Eye of CAFE Image Viewer")gettext ("Eye of CAFE Image Viewer")); |
167 | |
168 | g_object_set (ctk_settings_get_default (), "ctk-button-images", TRUE(!(0)), NULL((void*)0)); |
169 | g_object_set (ctk_settings_get_default (), "ctk-menu-images", TRUE(!(0)), NULL((void*)0)); |
170 | |
171 | EOC_APP(eoc_application_get_instance ())->priv->flags = flags; |
172 | if (force_new_instance) { |
173 | GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOC_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance *) (((eoc_application_get_instance ()))), ((g_application_get_type ()))))))); |
174 | app_flags |= G_APPLICATION_NON_UNIQUE; |
175 | g_application_set_flags (G_APPLICATION (EOC_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance *) (((eoc_application_get_instance ()))), ((g_application_get_type ())))))), app_flags); |
176 | } |
177 | |
178 | g_application_run (G_APPLICATION (EOC_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance *) (((eoc_application_get_instance ()))), ((g_application_get_type ())))))), argc, argv); |
179 | g_object_unref (EOC_APP(eoc_application_get_instance ())); |
180 | |
181 | if (startup_files) |
182 | g_strfreev (startup_files); |
183 | |
184 | #ifdef HAVE_EXEMPI1 |
185 | xmp_terminate(); |
186 | #endif |
187 | return 0; |
188 | } |