diff options
-rw-r--r-- | src/callbacks.c | 4 | ||||
-rw-r--r-- | src/camorama-window.c | 2 | ||||
-rw-r--r-- | src/main.c | 27 | ||||
-rw-r--r-- | src/v4l.h | 5 |
4 files changed, 37 insertions, 1 deletions
diff --git a/src/callbacks.c b/src/callbacks.c index 0145f20..a35cee4 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -333,7 +333,11 @@ void prefs_func(GtkWidget *okbutton, cam_t *cam) void on_quit_activate(GtkMenuItem *menuitem, cam_t *cam) { +#if GTK_MAJOR_VERSION >= 3 g_application_quit(G_APPLICATION(cam->app)); +#else + gtk_main_quit(); +#endif } void on_preferences1_activate(GtkMenuItem *menuitem, gpointer user_data) diff --git a/src/camorama-window.c b/src/camorama-window.c index 7ea6006..0bb830e 100644 --- a/src/camorama-window.c +++ b/src/camorama-window.c @@ -183,7 +183,9 @@ void load_interface(cam_t *cam) "main_window")); GtkTreeView *treeview; +#if GTK_MAJOR_VERSION >= 3 gtk_application_add_window(cam->app, GTK_WINDOW(window)); +#endif menu_item_filter_type = g_quark_from_static_string("camorama-menu-item-filter-type"); @@ -78,11 +78,19 @@ static void close_app(GtkWidget* widget, cam_t *cam) g_source_remove(cam->timeout_fps_id); gtk_widget_destroy(widget); +#if GTK_MAJOR_VERSION < 3 + gtk_main_quit(); +#endif + } static cam_t cam_object = { 0 }; +#if GTK_MAJOR_VERSION < 3 +static void activate(void) +#else static void activate(GtkApplication *app) +#endif { cam_t *cam = &cam_object; GConfClient *gc; @@ -99,7 +107,9 @@ static void activate(GtkApplication *app) cam->res = NULL; cam->n_res = 0; cam->scale = 1.f; +#if GTK_MAJOR_VERSION >= 3 cam->app = app; +#endif /* gtk is initialized now */ camorama_filters_init(); @@ -257,13 +267,18 @@ static void activate(GtkApplication *app) int main(int argc, char *argv[]) { +#if GTK_MAJOR_VERSION >= 3 GtkApplication *app; gint status; +#else + GError *error = NULL; +#endif bindtextdomain(PACKAGE_NAME, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); textdomain(PACKAGE_NAME); +#if GTK_MAJOR_VERSION >= 3 app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); g_application_add_main_option_entries(G_APPLICATION(app), options); g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); @@ -273,4 +288,16 @@ int main(int argc, char *argv[]) g_object_unref(app); return status; +#else + if (!gtk_init_with_args(&argc, &argv, _("camorama"), options, + PACKAGE_NAME, &error) || error) { + g_printerr(_("Invalid argument\nRun '%s --help'\n"), argv[0]); + return 1; + } + activate(); + + gtk_main(); + + return 0; +#endif } @@ -76,7 +76,6 @@ typedef struct camera { gboolean timestamp, rtimestamp, usedate, usestring; gboolean rtimefn, timefn; GtkWidget *da, *status; - GtkApplication *app; unsigned char *pic_buf, *tmp; guint timeout_id, timeout_fps_id, idle_id; guint32 timeout_interval; @@ -84,6 +83,10 @@ typedef struct camera { GtkBuilder *xml; GdkPixbuf *pb; +#if GTK_MAJOR_VERSION >= 3 + GtkApplication *app; +#endif + CamoramaFilterChain *filter_chain; gboolean rdir_ok; |