aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-08-20 15:49:29 (GMT)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-08-28 11:18:04 (GMT)
commit9a02ea2ee858beece4a1e9a48c448b13b7789834 (patch)
tree0bd1eaec55b80ca8f6f64962d68b88c6b4ec12e9
parent56b3f8970959f087cbc59f7de70ab09b56aee773 (diff)
Replace custom widget by GtkDrawingArea
There's no need to use a custom widget here. Just use a GtkDrawingArea and simplify the code. With such change, glade-3 doesn't complain anymore about the usage of obsolete widgets. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--data/camorama.glade3
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in5
-rw-r--r--src/camorama-display.c128
-rw-r--r--src/camorama-display.h58
-rw-r--r--src/main.c39
7 files changed, 19 insertions, 217 deletions
diff --git a/data/camorama.glade b/data/camorama.glade
index c2397ef..eb6e42b 100644
--- a/data/camorama.glade
+++ b/data/camorama.glade
@@ -190,12 +190,11 @@
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
- <widget class="Custom" id="da">
+ <widget class="GtkDrawingArea" id="da">
<property name="width_request">320</property>
<property name="height_request">240</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="string1">CamoDisplay</property>
</widget>
</child>
</widget>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a20a5c2..8345863 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -5,7 +5,6 @@ camorama.desktop.in
data/camorama.glade
data/camorama.schemas
src/callbacks.c
-src/camorama-display.c
src/camorama-filter-chain.c
src/camorama-filter-laplace.c
src/camorama-filter-mirror.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 531cc48..d4f5a5b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,8 +9,6 @@ bin_PROGRAMS = camorama
camorama_SOURCES = \
callbacks.c \
- camorama-display.c \
- camorama-display.h \
camorama-filter-chain.c \
camorama-filter-chain.h \
camorama-filter-laplace.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 133ce91..4782c57 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -102,7 +102,7 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am__objects_1 =
-am_camorama_OBJECTS = callbacks.$(OBJEXT) camorama-display.$(OBJEXT) \
+am_camorama_OBJECTS = callbacks.$(OBJEXT) \
camorama-filter-chain.$(OBJEXT) \
camorama-filter-laplace.$(OBJEXT) \
camorama-filter-mirror.$(OBJEXT) \
@@ -301,8 +301,6 @@ AM_CPPFLAGS = \
camorama_SOURCES = \
callbacks.c \
- camorama-display.c \
- camorama-display.h \
camorama-filter-chain.c \
camorama-filter-chain.h \
camorama-filter-laplace.c \
@@ -418,7 +416,6 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/callbacks.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/camorama-display.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/camorama-filter-chain.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/camorama-filter-laplace.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/camorama-filter-mirror.Po@am__quote@
diff --git a/src/camorama-display.c b/src/camorama-display.c
deleted file mode 100644
index ad5c080..0000000
--- a/src/camorama-display.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* This file is part of camorama
- *
- * AUTHORS
- * Sven Herzberg <herzi@gnome-de.org>
- *
- * Copyright (C) 2007 Sven Herzberg
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "camorama-display.h"
-
-#include "camorama-globals.h" // frames
-
-struct _CamoDisplayPrivate {
- cam* camera;
-};
-
-enum {
- PROP_0,
- PROP_CAMERA
-};
-
-G_DEFINE_TYPE (CamoDisplay, camo_display, GTK_TYPE_DRAWING_AREA);
-
-GtkWidget*
-camo_display_new (cam* camera)
-{
- return g_object_new (CAMO_TYPE_DISPLAY,
- "camera", camera,
- NULL);
-}
-
-static void
-camo_display_init (CamoDisplay* self)
-{
- self->_private = G_TYPE_INSTANCE_GET_PRIVATE (self, CAMO_TYPE_DISPLAY, CamoDisplayPrivate);
-}
-
-static void
-display_get_property (GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec* pspec)
-{
- CamoDisplay* self = CAMO_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_CAMERA:
- g_value_set_pointer (value, self->_private->camera);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-display_set_property (GObject * object,
- guint prop_id,
- GValue const* value,
- GParamSpec * pspec)
-{
- CamoDisplay* self = CAMO_DISPLAY (object);
-
- switch (prop_id) {
- case PROP_CAMERA:
- self->_private->camera = g_value_get_pointer (value);
- g_object_notify (object, "camera");
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-display_expose_event (GtkWidget * widget,
- GdkEventExpose* event)
-{
- CamoDisplay* self = CAMO_DISPLAY (widget);
-
- gdk_draw_drawable (widget->window,
- widget->style->fg_gc[gtk_widget_get_state (widget)],
- self->_private->camera->pixmap,
- event->area.x, event->area.y, event->area.x,
- event->area.y, event->area.width, event->area.height);
-
- frames++;
-
- return FALSE;
-}
-
-static void
-camo_display_class_init (CamoDisplayClass* self_class)
-{
- GObjectClass* object_class = G_OBJECT_CLASS (self_class);
- GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (self_class);
-
- object_class->get_property = display_get_property;
- object_class->set_property = display_set_property;
-
- g_object_class_install_property (object_class,
- PROP_CAMERA,
-#warning "FIXME: use a camera object here"
- g_param_spec_pointer ("camera",
- "camera",
- "camera",
- G_PARAM_READWRITE));
-
- widget_class->expose_event = display_expose_event;
-
- g_type_class_add_private (self_class, sizeof (CamoDisplayPrivate));
-}
-
diff --git a/src/camorama-display.h b/src/camorama-display.h
deleted file mode 100644
index 14027e4..0000000
--- a/src/camorama-display.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* This file is part of camorama
- *
- * AUTHORS
- * Sven Herzberg <herzi@gnome-de.org>
- *
- * Copyright (C) 2007 Sven Herzberg
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifndef CAMORAMA_DISPLAY_H
-#define CAMORAMA_DISPLAY_H
-
-#include <gtk/gtk.h>
-
-#include "v4l.h"
-
-G_BEGIN_DECLS
-
-typedef struct _CamoDisplay CamoDisplay;
-typedef struct _CamoDisplayPrivate CamoDisplayPrivate;
-typedef struct _CamoDisplayClass CamoDisplayClass;
-
-#define CAMO_TYPE_DISPLAY (camo_display_get_type ())
-#define CAMO_DISPLAY(i) (G_TYPE_CHECK_INSTANCE_CAST ((i), CAMO_TYPE_DISPLAY, CamoDisplay))
-#define CAMO_DISPLAY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), CAMO_TYPE_DISPLAY, CamoDisplayClass))
-#define CAMO_IS_DISPLAY(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i), CAMO_TYPE_DISPLAY))
-#define CAMO_IS_DISPLAY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), CAMO_TYPE_DISPLAY))
-#define CAMO_DISPLAY_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i), CAMO_TYPE_DISPLAY, CamoDisplayClass))
-
-GType camo_display_get_type (void);
-GtkWidget* camo_display_new (cam* camera);
-
-struct _CamoDisplay {
- GtkDrawingArea base_instance;
- CamoDisplayPrivate* _private;
-};
-
-struct _CamoDisplayClass {
- GtkDrawingAreaClass base_class;
-};
-
-G_END_DECLS
-
-#endif /* !CAMORAMA_DISPLAY_H */
diff --git a/src/main.c b/src/main.c
index 5ad0145..6eec251 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,6 +4,7 @@
#include "callbacks.h"
#include "filter.h"
#include "camorama-window.h"
+#include "camorama-globals.h"
#include "support.h"
#include <config.h>
@@ -13,7 +14,6 @@
#include <locale.h>
#include <libv4l2.h>
-#include "camorama-display.h"
#include "camorama-stock-items.h"
static gboolean ver = FALSE, max = FALSE, min = FALSE, half =
@@ -39,26 +39,19 @@ static gboolean ver = FALSE, max = FALSE, min = FALSE, half =
return true;
}*/
-static GtkWidget*
-camorama_glade_handler (GladeXML* xml,
- gchar * func_name,
- gchar * name,
- gchar * string1,
- gchar * string2,
- gint int1,
- gint int2,
- gpointer data)
+gboolean
+draw_camera_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
- gboolean reached = TRUE;
-#warning "FIXME: move the glade crap into the window class"
- if (string1 && !strcmp (string1, "CamoDisplay")) {
- GtkWidget* widget = camo_display_new ((cam*)data);
- gtk_widget_show (widget);
- return widget;
- }
+ cam* camera = data;
+
+ gdk_draw_drawable (widget->window,
+ widget->style->fg_gc[gtk_widget_get_state (widget)],
+ camera->pixmap,
+ event->area.x, event->area.y, event->area.x,
+ event->area.y, event->area.width, event->area.height);
- g_return_val_if_fail (!reached, NULL);
- return NULL;
+ frames++;
+ return TRUE;
}
int
@@ -129,9 +122,6 @@ main(int argc, char *argv[]) {
cam->width = x;
cam->height = y;
glade_gnome_init ();
- glade_set_custom_handler (camorama_glade_handler,
- cam);
-
if (ver) {
fprintf (stderr, _("\n\nCamorama version %s\n\n"), PACKAGE_VERSION);
@@ -271,6 +261,11 @@ main(int argc, char *argv[]) {
* gtk_widget_show_all (GTK_WIDGET (tray_icon)); */
load_interface (cam);
+ GtkWidget *widget = glade_xml_get_widget(cam->xml, "da");
+ gtk_widget_show (widget);
+ g_signal_connect (widget, "expose_event",
+ G_CALLBACK (draw_camera_callback), cam);
+
cam->idle_id = gtk_idle_add ((GSourceFunc) pt2Function, (gpointer) cam);
gtk_timeout_add (2000, (GSourceFunc) fps, cam->status);

Privacy Policy