aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-07 06:42:14 -0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-07 11:36:56 -0300
commitbad7d0926ca7f83cc7529f4de2a6d392262ada42 (patch)
tree6be728034f88072afc01a2117b0fb3e0ae85baa7 /src
parentcdfeabfbafb64a9ffe0da24328552c18df5fe833 (diff)
Add backward support for gtk2
Support for gtk3 is too new. It is worth keeping support for gtk2 for a while, specially since the code changes to keep it are small. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.c4
-rw-r--r--src/camorama-window.c2
-rw-r--r--src/main.c27
-rw-r--r--src/v4l.h5
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");
diff --git a/src/main.c b/src/main.c
index bb29568..1895372 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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
}
diff --git a/src/v4l.h b/src/v4l.h
index e049d44..f68a8a9 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -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;

Privacy Policy