diff options
-rw-r--r-- | Makefile.am | 18 | ||||
-rw-r--r-- | configure.ac | 26 | ||||
-rw-r--r-- | example/Makefile.am | 24 | ||||
-rw-r--r-- | example/gesture.c | 173 | ||||
-rw-r--r-- | gtk-doc.make | 230 | ||||
-rw-r--r-- | libido3.pc.in | 11 | ||||
-rw-r--r-- | src/Makefile.am | 25 | ||||
-rw-r--r-- | src/idocalendarmenuitem.c | 181 | ||||
-rw-r--r-- | src/idocalendarmenuitem.h | 18 | ||||
-rw-r--r-- | src/idoentrymenuitem.c | 61 | ||||
-rw-r--r-- | src/idogesturemanager.c | 688 | ||||
-rw-r--r-- | src/idogesturemanager.h | 162 | ||||
-rw-r--r-- | src/idomessagedialog.c | 20 | ||||
-rw-r--r-- | src/idomessagedialog.h | 2 | ||||
-rw-r--r-- | src/idorange.c | 2 | ||||
-rw-r--r-- | src/idorange.h | 2 | ||||
-rw-r--r-- | src/idoscalemenuitem.c | 49 | ||||
-rw-r--r-- | src/idoscalemenuitem.h | 6 | ||||
-rw-r--r-- | src/idotimeline.c | 4 | ||||
-rw-r--r-- | src/idotimeline.h | 2 | ||||
-rw-r--r-- | src/libido.h | 1 |
21 files changed, 317 insertions, 1388 deletions
diff --git a/Makefile.am b/Makefile.am index 3348e87..68fd066 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,9 @@ +if USE_GTK3 +VER=3 +else +VER= +endif + ACLOCAL_AMFLAGS = -I build/autotools V = @ @@ -6,14 +12,14 @@ QUIET_GEN = $(Q:@=@echo ' GEN '$@;) SUBDIRS = build src example -libido-0.1.pc: libido.pc - $(QUIET_GEN) cp -f libido.pc libido-0.1.pc +%-0.1.pc: %.pc + $(QUIET_GEN) cp -f $< $@ pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libido-0.1.pc +pkgconfig_DATA = libido$(VER)-0.1.pc -CLEANFILES = libido-0.1.pc -DISTCLEANFILES = libido.pc -EXTRA_DIST = libido.pc.in +CLEANFILES = libido-0.1.pc libido3-0.1.pc +DISTCLEANFILES = libido.pc libido3.pc +EXTRA_DIST = libido.pc.in libido3.pc.in DISTCHECK_CONFIGURE_FLAGS = --disable-gtk-doc diff --git a/configure.ac b/configure.ac index b53afa7..4dfe223 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # shamelessly stolen from clutter-gtk # m4_define([ido_major_version], [0]) -m4_define([ido_minor_version], [1]) -m4_define([ido_micro_version], [11]) +m4_define([ido_minor_version], [2]) +m4_define([ido_micro_version], [2]) m4_define([ido_api_version], [ido_major_version.ido_minor_version]) @@ -24,7 +24,7 @@ AC_CONFIG_MACRO_DIR([build/autotools]) AM_CONFIG_HEADER([config.h]) -AM_INIT_AUTOMAKE([1.9]) +AM_INIT_AUTOMAKE([1.9 foreign]) IDO_MAJOR_VERSION=ido_major_version IDO_MINOR_VERSION=ido_minor_version @@ -52,9 +52,11 @@ dnl =========================================================================== # Checks for programs AC_PROG_CC +AM_PROG_CC_C_O AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) +PKG_PROG_PKG_CONFIG # Checks for header files AC_HEADER_STDC @@ -68,14 +70,21 @@ AC_FUNC_MALLOC AC_FUNC_MMAP AC_CHECK_FUNCS([memset munmap strcasecmp strdup]) -PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.19.7) +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], + [Which version of gtk to use @<:@default=3@:>@])], + [], + [with_gtk=3]) +AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) + +if test "x$with_gtk" = "x2"; then + PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.19.7) +else + PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0.0) +fi AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) -PKG_CHECK_MODULES(GEIS, libutouch-geis >= 0.3) -AC_SUBST(GEIS_CFLAGS) -AC_SUBST(GEIS_LIBS) - dnl =========================================================================== if test "x$GCC" = "xyes"; then @@ -118,6 +127,7 @@ AC_CONFIG_FILES([ src/Makefile example/Makefile libido.pc + libido3.pc ]) AC_OUTPUT diff --git a/example/Makefile.am b/example/Makefile.am index 702cc8f..b986b9b 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -1,19 +1,13 @@ +if USE_GTK3 +VER=3 +else +VER= +endif + noinst_PROGRAMS = \ - gesture \ messagedialog \ menus -gesture_SOURCES = \ - gesture.c - -gesture_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - $(GCC_FLAGS) \ - $(GTK_CFLAGS) \ - $(MAINTAINER_CFLAGS) - messagedialog_SOURCES = \ messagedialog.c @@ -36,8 +30,6 @@ menus_CPPFLAGS = \ $(GTK_CFLAGS) \ $(MAINTAINER_CFLAGS) -gesture_LDADD = $(top_builddir)/src/libido-0.1.la - -messagedialog_LDADD = $(top_builddir)/src/libido-0.1.la +messagedialog_LDADD = $(top_builddir)/src/libido$(VER)-0.1.la $(GTK_LIBS) -menus_LDADD = $(top_builddir)/src/libido-0.1.la +menus_LDADD = $(top_builddir)/src/libido$(VER)-0.1.la $(GTK_LIBS) diff --git a/example/gesture.c b/example/gesture.c deleted file mode 100644 index 57c4c24..0000000 --- a/example/gesture.c +++ /dev/null @@ -1,173 +0,0 @@ -#include <stdlib.h> -#include <string.h> -#include <signal.h> - -#include "idogesturemanager.h" - -static gint rotate = 0; -static gdouble scale = 1.0; -static gdouble translate[2] = { 200, 200 }; -static gint in_touch = 0; - -static gboolean -expose_event (GtkWidget *widget, - GdkEventExpose *event, - gpointer data) -{ - cairo_t *cr; - gdouble radians; - gint width = (in_touch > 0) ? 10 : 1; - - cr = gdk_cairo_create (widget->window); - - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_set_line_width (cr, width); - - radians = rotate * (G_PI / 180); - cairo_translate (cr, translate[0], translate[1]); - cairo_scale (cr, scale, scale); - cairo_rotate (cr, radians); - - cairo_rectangle (cr, -50, -50, 100, 100); - cairo_stroke_preserve (cr); - cairo_set_source_rgb (cr, 1, 0, 1); - cairo_fill (cr); - - cairo_destroy (cr); - - return FALSE; -} - -GtkWidget * -create_window (void) -{ - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - GtkWidget *da; - const GdkColor white = { 0, 0xffff, 0xffff, 0xffff }; - - gtk_window_set_title (GTK_WINDOW (window), "Touch Demo"); - gtk_window_set_default_size (GTK_WINDOW (window), 600, 600); - g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); - - da = gtk_drawing_area_new (); - gtk_container_add (GTK_CONTAINER (window), da); - - gtk_widget_modify_bg (da, GTK_STATE_NORMAL, &white); - - g_signal_connect (da, "expose-event", - G_CALLBACK (expose_event), NULL); - - return window; -} - -static void -gesture_start (GtkWindow *window, - IdoGestureEvent *event) -{ - in_touch++; - - gtk_widget_queue_draw (GTK_WIDGET (window)); -} - -static void -gesture_end (GtkWindow *window, - IdoGestureEvent *event) -{ - in_touch--; - - gtk_widget_queue_draw (GTK_WIDGET (window)); -} - -static void -rotate_update (GtkWindow *window, - IdoGestureEvent *event) -{ - IdoEventGestureRotate *e = (IdoEventGestureRotate *)event; - - rotate += e->angle_delta * 100; - - gtk_widget_queue_draw (GTK_WIDGET (window)); -} - -static void -pinch_update (GtkWindow *window, - IdoGestureEvent *event) -{ - IdoEventGesturePinch *e = (IdoEventGesturePinch *)event; - - scale += e->radius_delta / 100; - - gtk_widget_queue_draw (GTK_WIDGET (window)); -} - -static void -drag_update (GtkWindow *window, - IdoGestureEvent *event) -{ - IdoEventGestureDrag *e = (IdoEventGestureDrag *)event; - - translate[0] += e->delta_x; - translate[1] += e->delta_y; - - gtk_widget_queue_draw (GTK_WIDGET (window)); -} - -static void -window_mapped (GtkWidget *widget) -{ - IdoGestureManager *manager = ido_gesture_manager_get (); - GtkWindow *window = GTK_WINDOW (widget); - - ido_gesture_manager_register_window (manager, - window, - IDO_GESTURE_PINCH2, - gesture_start, - pinch_update, - gesture_end); - - ido_gesture_manager_register_window (manager, - window, - IDO_GESTURE_ROTATE2, - gesture_start, - rotate_update, - gesture_end); - - ido_gesture_manager_register_window (manager, - window, - IDO_GESTURE_DRAG2, - gesture_start, - drag_update, - gesture_end); -} - -static void -abort_handler (int x) -{ - g_print (" **** ABORT ****\n"); - - exit (1); -} - -int -main (int argc, char **argv) -{ - GtkWidget *window; - - gtk_init (&argc, &argv); - - /* Don't crash X if we're using some shitty Intel graphics like - * my Dell XT2 has in it. */ - signal (SIGABRT, abort_handler); - - window = create_window (); - - g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); - g_signal_connect (window, "map-event", G_CALLBACK (window_mapped), NULL); - - gtk_widget_show_all (window); - - gtk_main (); - - return 0; -} - diff --git a/gtk-doc.make b/gtk-doc.make deleted file mode 100644 index 57fab98..0000000 --- a/gtk-doc.make +++ /dev/null @@ -1,230 +0,0 @@ -# -*- mode: makefile -*- - -#################################### -# Everything below here is generic # -#################################### - -if GTK_DOC_USE_LIBTOOL -GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -GTKDOC_RUN = $(LIBTOOL) --mode=execute -else -GTKDOC_CC = $(CC) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -GTKDOC_LD = $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -GTKDOC_RUN = -endif - -# We set GPATH here; this gives us semantics for GNU make -# which are more like other make's VPATH, when it comes to -# whether a source that is a target of one rule is then -# searched for in VPATH/GPATH. -# -GPATH = $(srcdir) - -TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) - -EXTRA_DIST = \ - $(content_files) \ - $(HTML_IMAGES) \ - $(DOC_MAIN_SGML_FILE) \ - $(DOC_MODULE)-sections.txt \ - $(DOC_MODULE)-overrides.txt - -DOC_STAMPS=scan-build.stamp tmpl-build.stamp sgml-build.stamp html-build.stamp \ - pdf-build.stamp \ - $(srcdir)/tmpl.stamp $(srcdir)/sgml.stamp $(srcdir)/html.stamp \ - $(srcdir)/pdf.stamp - -SCANOBJ_FILES = \ - $(DOC_MODULE).args \ - $(DOC_MODULE).hierarchy \ - $(DOC_MODULE).interfaces \ - $(DOC_MODULE).prerequisites \ - $(DOC_MODULE).signals - -REPORT_FILES = \ - $(DOC_MODULE)-undocumented.txt \ - $(DOC_MODULE)-undeclared.txt \ - $(DOC_MODULE)-unused.txt - -CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) - -if ENABLE_GTK_DOC -if GTK_DOC_BUILD_HTML -HTML_BUILD_STAMP=html-build.stamp -else -HTML_BUILD_STAMP= -endif -if GTK_DOC_BUILD_PDF -PDF_BUILD_STAMP=pdf-build.stamp -else -PDF_BUILD_STAMP= -endif - -all-local: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) -else -all-local: -endif - -docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) - -$(REPORT_FILES): sgml-build.stamp - -#### scan #### - -scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB) - @echo 'gtk-doc: Scanning header files' - @-chmod -R u+w $(srcdir) - @_source_dir='' ; for i in $(DOC_SOURCE_DIR) ; do \ - _source_dir="$${_source_dir} --source-dir=$$i" ; \ - done ; \ - cd $(srcdir) && \ - gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES) - @if grep -l '^..*$$' $(srcdir)/$(DOC_MODULE).types > /dev/null 2>&1 ; then \ - CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" gtkdoc-scangobj $(SCANGOBJ_OPTIONS) --module=$(DOC_MODULE) --output-dir=$(srcdir) ; \ - else \ - cd $(srcdir) ; \ - for i in $(SCANOBJ_FILES) ; do \ - test -f $$i || touch $$i ; \ - done \ - fi - @touch scan-build.stamp - -$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp - @true - -#### templates #### - -tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt - @echo 'gtk-doc: Rebuilding template files' - @-chmod -R u+w $(srcdir) - @cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE) $(MKTMPL_OPTIONS) - @touch tmpl-build.stamp - -tmpl.stamp: tmpl-build.stamp - @true - -$(srcdir)/tmpl/*.sgml: - @true - -#### xml #### - -sgml-build.stamp: tmpl.stamp $(DOC_MODULE)-sections.txt $(srcdir)/tmpl/*.sgml $(expand_content_files) - @echo 'gtk-doc: Building XML' - @-chmod -R u+w $(srcdir) - @_source_dir='' ; for i in $(DOC_SOURCE_DIR) ; do \ - _source_dir="$${_source_dir} --source-dir=$$i" ; \ - done ; \ - cd $(srcdir) && \ - gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS) - @touch sgml-build.stamp - -sgml.stamp: sgml-build.stamp - @true - -#### html #### - -html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) - @echo 'gtk-doc: Building HTML' - @-chmod -R u+w $(srcdir) - @rm -rf $(srcdir)/html - @mkdir $(srcdir)/html - @mkhtml_options=""; \ - gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \ - if test "$(?)" = "0"; then \ - mkhtml_options=--path="$(srcdir)"; \ - fi; \ - cd $(srcdir)/html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) - @test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html ) - @echo 'gtk-doc: Fixing cross-references' - @cd $(srcdir) && gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) - @touch html-build.stamp - -#### pdf #### - -pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) - @echo 'gtk-doc: Building PDF' - @-chmod -R u+w $(srcdir) - @rm -rf $(srcdir)/$(DOC_MODULE).pdf - @mkpdf_imgdirs=""; \ - if test "x$(HTML_IMAGES)" != "x"; then \ - for img in $(HTML_IMAGES); do \ - part=`dirname $$img`; \ - echo $$mkpdf_imgdirs | grep >/dev/null "\-\-imgdir=$$part "; \ - if test $$? != 0; then \ - mkpdf_imgdirs="$$mkpdf_imgdirs --imgdir=$$part"; \ - fi; \ - done; \ - fi; \ - cd $(srcdir) && gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_imgdirs $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS) - @touch pdf-build.stamp - -############## - -clean-local: - rm -f *~ *.bak - rm -rf .libs - -distclean-local: - cd $(srcdir) && \ - rm -rf xml $(REPORT_FILES) $(DOC_MODULE).pdf \ - $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt - -maintainer-clean-local: clean - cd $(srcdir) && rm -rf xml html - -install-data-local: - @installfiles=`echo $(srcdir)/html/*`; \ - if test "$$installfiles" = '$(srcdir)/html/*'; \ - then echo '-- Nothing to install' ; \ - else \ - if test -n "$(DOC_MODULE_VERSION)"; then \ - installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ - else \ - installdir="$(DESTDIR)$(TARGET_DIR)"; \ - fi; \ - $(mkinstalldirs) $${installdir} ; \ - for i in $$installfiles; do \ - echo '-- Installing '$$i ; \ - $(INSTALL_DATA) $$i $${installdir}; \ - done; \ - if test -n "$(DOC_MODULE_VERSION)"; then \ - mv -f $${installdir}/$(DOC_MODULE).devhelp2 \ - $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \ - mv -f $${installdir}/$(DOC_MODULE).devhelp \ - $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp; \ - fi; \ - $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \ - fi - -uninstall-local: - @if test -n "$(DOC_MODULE_VERSION)"; then \ - installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ - else \ - installdir="$(DESTDIR)$(TARGET_DIR)"; \ - fi; \ - rm -rf $${installdir} - -# -# Require gtk-doc when making dist -# -if ENABLE_GTK_DOC -dist-check-gtkdoc: -else -dist-check-gtkdoc: - @echo "*** gtk-doc must be installed and enabled in order to make dist" - @false -endif - -dist-hook: dist-check-gtkdoc dist-hook-local - mkdir $(distdir)/tmpl - mkdir $(distdir)/html - -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl - cp $(srcdir)/html/* $(distdir)/html - -cp $(srcdir)/$(DOC_MODULE).pdf $(distdir)/ - -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/ - -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/ - cd $(distdir) && rm -f $(DISTCLEANFILES) - $(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html - -.PHONY : dist-hook-local docs diff --git a/libido3.pc.in b/libido3.pc.in new file mode 100644 index 0000000..db3ed1b --- /dev/null +++ b/libido3.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libido +Description: Ayatana Indicator Display Objects +Version: @VERSION@ +Libs: -L${libdir} -lido3-0.1 +Cflags: -I${includedir}/libido3-0.1 +Requires: gtk+-3.0 diff --git a/src/Makefile.am b/src/Makefile.am index d17482d..5ac5a01 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,11 @@ +if USE_GTK3 +VER=3 +lib_LTLIBRARIES = libido3-0.1.la +else +VER= +lib_LTLIBRARIES = libido-0.1.la +endif + ido_built_public_sources = \ idotypebuiltins.h @@ -8,7 +16,6 @@ stamp_files = \ sources_h = \ idocalendarmenuitem.h \ idoentrymenuitem.h \ - idogesturemanager.h \ idomessagedialog.h \ idorange.h \ idoscalemenuitem.h \ @@ -41,28 +48,24 @@ INCLUDES = \ -DLIBDIR=\"$(libdir)"\" \ -DG_DISABLE_DEPRECATED \ -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED + -DGDK_DISABLE_DEPRECATED AM_CPPFLAGS = \ $(GCC_FLAGS) \ $(GTK_CFLAGS) \ - $(GEIS_CFLAGS) \ $(MAINTAINER_CFLAGS) -lib_LTLIBRARIES = libido-0.1.la - libido_0_1_la_SOURCES = \ idotypebuiltins.c \ idocalendarmenuitem.c \ idoentrymenuitem.c \ - idogesturemanager.c \ idomessagedialog.c \ idorange.c \ idoscalemenuitem.c \ idotimeline.c +libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES) -libidoincludedir=$(includedir)/libido-0.1/libido +libidoincludedir=$(includedir)/libido$(VER)-0.1/libido libidoinclude_HEADERS = \ idocalendarmenuitem.h \ @@ -73,10 +76,10 @@ libidoinclude_HEADERS = \ idotimeline.h \ libido.h -libido_0_1_la_LIBADD = $(GTK_LIBS) $(GEIS_LIBS) +libido_0_1_la_LIBADD = $(GTK_LIBS) libido_0_1_la_LDFLAGS = $(GTK_LT_LDFLAGS) - -idoheadersdir = $(includedir)/ido-0.1/ido +libido3_0_1_la_LIBADD = $(libido_0_1_la_LIBADD) +libido3_0_1_la_LDFLAGS = $(libido_0_1_la_LDFLAGS) DISTCLEANFILES = \ stamp-idotypebuiltins.h \ diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c index fca4bb6..806c863 100644 --- a/src/idocalendarmenuitem.c +++ b/src/idocalendarmenuitem.c @@ -26,8 +26,13 @@ #include <gdk/gdkkeysyms.h> #include "idocalendarmenuitem.h" +#if GTK_CHECK_VERSION (3, 0, 0) +static void ido_calendar_menu_item_select (GtkMenuItem *item); +static void ido_calendar_menu_item_deselect (GtkMenuItem *item); +#else static void ido_calendar_menu_item_select (GtkItem *item); static void ido_calendar_menu_item_deselect (GtkItem *item); +#endif static gboolean ido_calendar_menu_item_button_release (GtkWidget *widget, GdkEventButton *event); static gboolean ido_calendar_menu_item_button_press (GtkWidget *widget, @@ -42,7 +47,12 @@ static void calendar_realized_cb (GtkWidget *widg static void calendar_move_focus_cb (GtkWidget *widget, GtkDirectionType direction, IdoCalendarMenuItem *item); - +static void calendar_month_changed_cb (GtkWidget *widget, + gpointer user_data); +static void calendar_day_selected_double_click_cb (GtkWidget *widget, + gpointer user_data); +static void calendar_day_selected_cb (GtkWidget *widget, + gpointer user_data); struct _IdoCalendarMenuItemPrivate { GtkWidget *box; @@ -60,34 +70,51 @@ ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass) GObjectClass *gobject_class; GtkWidgetClass *widget_class; GtkMenuItemClass *menu_item_class; +#if ! GTK_CHECK_VERSION (3, 0, 0) GtkItemClass *item_class; +#endif gobject_class = G_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); menu_item_class = GTK_MENU_ITEM_CLASS (klass); +#if ! GTK_CHECK_VERSION (3, 0, 0) item_class = GTK_ITEM_CLASS (klass); +#endif widget_class->button_release_event = ido_calendar_menu_item_button_release; widget_class->button_press_event = ido_calendar_menu_item_button_press; +#if GTK_CHECK_VERSION (3, 0, 0) + menu_item_class->select = ido_calendar_menu_item_select; + menu_item_class->deselect = ido_calendar_menu_item_deselect; +#else item_class->select = ido_calendar_menu_item_select; item_class->deselect = ido_calendar_menu_item_deselect; +#endif menu_item_class->hide_on_activate = TRUE; g_type_class_add_private (gobject_class, sizeof (IdoCalendarMenuItemPrivate)); + + g_signal_new("month-changed", G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + g_signal_new("day-selected", G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + g_signal_new("day-selected-double-click", G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void ido_calendar_menu_item_init (IdoCalendarMenuItem *item) { IdoCalendarMenuItemPrivate *priv; - GtkBorder border; - - border.left = 4; - border.right = 4; - border.top = 2; - border.bottom = 2; priv = item->priv = IDO_CALENDAR_MENU_ITEM_GET_PRIVATE (item); @@ -124,7 +151,7 @@ ido_calendar_menu_item_send_focus_change (GtkWidget *widget, gtk_widget_grab_focus (widget); event->focus_change.type = GDK_FOCUS_CHANGE; - event->focus_change.window = g_object_ref (widget->window); + event->focus_change.window = g_object_ref (gtk_widget_get_window (widget)); event->focus_change.in = in; gtk_widget_event (widget, event); @@ -149,9 +176,9 @@ ido_calendar_menu_item_key_press (GtkWidget *widget, gtk_widget_event (calendar, ((GdkEvent *)(void*)(event))); - if (calendar->window != NULL) + if (gtk_widget_get_window (calendar) != NULL) { - gdk_window_raise (calendar->window); + gdk_window_raise (gtk_widget_get_window (calendar)); } if (!gtk_widget_has_focus (calendar)) @@ -159,7 +186,7 @@ ido_calendar_menu_item_key_press (GtkWidget *widget, gtk_widget_grab_focus (calendar); } - return event->keyval != GDK_Return; + return event->keyval != GDK_KEY_Return; } return FALSE; @@ -173,9 +200,9 @@ ido_calendar_menu_item_button_press (GtkWidget *widget, if (event->button == 1) { - if (calendar->window != NULL) + if (gtk_widget_get_window (calendar) != NULL) { - gdk_window_raise (calendar->window); + gdk_window_raise (gtk_widget_get_window (calendar)); } if (!gtk_widget_has_focus (calendar)) @@ -183,9 +210,6 @@ ido_calendar_menu_item_button_press (GtkWidget *widget, gtk_widget_grab_focus (calendar); } - gtk_widget_event (calendar, - ((GdkEvent *)(void*)(event))); - return TRUE; } @@ -198,14 +222,15 @@ ido_calendar_menu_item_button_release (GtkWidget *widget, { GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar; - gtk_widget_event (calendar, - ((GdkEvent *)(void*)(event))); - return TRUE; } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_calendar_menu_item_select (GtkMenuItem *item) +#else ido_calendar_menu_item_select (GtkItem *item) +#endif { IDO_CALENDAR_MENU_ITEM (item)->priv->selected = TRUE; @@ -213,7 +238,11 @@ ido_calendar_menu_item_select (GtkItem *item) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_calendar_menu_item_deselect (GtkMenuItem *item) +#else ido_calendar_menu_item_deselect (GtkItem *item) +#endif { IDO_CALENDAR_MENU_ITEM (item)->priv->selected = FALSE; @@ -225,16 +254,29 @@ static void calendar_realized_cb (GtkWidget *widget, IdoCalendarMenuItem *item) { - if (widget->window != NULL) + if (gtk_widget_get_window (widget) != NULL) { - gdk_window_raise (widget->window); + gdk_window_raise (gtk_widget_get_window (widget)); } - g_signal_connect (GTK_WIDGET (item)->parent, + g_signal_connect (gtk_widget_get_parent (GTK_WIDGET (item)), "key-press-event", G_CALLBACK (ido_calendar_menu_item_key_press), item); - + + g_signal_connect (item->priv->calendar, + "month-changed", + G_CALLBACK (calendar_month_changed_cb), + item); + g_signal_connect (item->priv->calendar, + "day-selected", + G_CALLBACK (calendar_day_selected_cb), + item); + g_signal_connect (item->priv->calendar, + "day-selected-double-click", + G_CALLBACK (calendar_day_selected_double_click_cb), + item); + ido_calendar_menu_item_send_focus_change (widget, TRUE); } @@ -250,6 +292,32 @@ calendar_move_focus_cb (GtkWidget *widget, GTK_DIR_TAB_FORWARD); } +static void +calendar_month_changed_cb (GtkWidget *widget, + gpointer user_data) +{ + IdoCalendarMenuItem *item = (IdoCalendarMenuItem *)user_data; + g_signal_emit_by_name (item, "month-changed", NULL); +} + +static void +calendar_day_selected_cb (GtkWidget *widget, + gpointer user_data) +{ + IdoCalendarMenuItem *item = (IdoCalendarMenuItem *)user_data; + g_signal_emit_by_name (item, "day-selected", NULL); +} + +static void +calendar_day_selected_double_click_cb (GtkWidget *widget, + gpointer user_data) +{ + IdoCalendarMenuItem *item = (IdoCalendarMenuItem *)user_data; + guint day, month, year; + gtk_calendar_get_date (GTK_CALENDAR (widget), &year, &month, &day); + g_signal_emit_by_name (item, "day-selected-double-click", NULL); +} + /* Public API */ GtkWidget * ido_calendar_menu_item_new (void) @@ -264,3 +332,70 @@ ido_calendar_menu_item_get_calendar (IdoCalendarMenuItem *item) return item->priv->calendar; } + +gboolean +ido_calendar_menu_item_mark_day (IdoCalendarMenuItem *menuitem, guint day) +{ + g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE); + + gtk_calendar_mark_day(GTK_CALENDAR (menuitem->priv->calendar), day); + return TRUE; +} + +gboolean +ido_calendar_menu_item_unmark_day (IdoCalendarMenuItem *menuitem, guint day) +{ + g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE); + + gtk_calendar_unmark_day(GTK_CALENDAR (menuitem->priv->calendar), day); + return TRUE; +} + +void +ido_calendar_menu_item_clear_marks (IdoCalendarMenuItem *menuitem) +{ + g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem)); + + gtk_calendar_clear_marks(GTK_CALENDAR (menuitem->priv->calendar)); +} + +void +ido_calendar_menu_item_set_display_options (IdoCalendarMenuItem *menuitem, GtkCalendarDisplayOptions flags) +{ + g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem)); + + gtk_calendar_set_display_options (GTK_CALENDAR (menuitem->priv->calendar), flags); +} + +GtkCalendarDisplayOptions +ido_calendar_menu_item_get_display_options (IdoCalendarMenuItem *menuitem) +{ + g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), 0); + + return gtk_calendar_get_display_options (GTK_CALENDAR (menuitem->priv->calendar)); +} + +void +ido_calendar_menu_item_get_date (IdoCalendarMenuItem *menuitem, + guint *year, + guint *month, + guint *day) { + + g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem)); + gtk_calendar_get_date (GTK_CALENDAR (menuitem->priv->calendar), year, month, day); +} + +gboolean +ido_calendar_menu_item_set_date (IdoCalendarMenuItem *menuitem, + guint year, + guint month, + guint day) +{ + g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE); + gtk_calendar_select_month (GTK_CALENDAR (menuitem->priv->calendar), month, year); + gtk_calendar_select_day (GTK_CALENDAR (menuitem->priv->calendar), day); + return TRUE; +} + + + diff --git a/src/idocalendarmenuitem.h b/src/idocalendarmenuitem.h index 3f9bf96..c4833fb 100644 --- a/src/idocalendarmenuitem.h +++ b/src/idocalendarmenuitem.h @@ -53,11 +53,23 @@ struct _IdoCalendarMenuItemClass GtkMenuItemClass parent_class; }; -GType ido_calendar_menu_item_get_type (void) G_GNUC_CONST; +GType ido_calendar_menu_item_get_type (void) G_GNUC_CONST; -GtkWidget *ido_calendar_menu_item_new (void); +GtkWidget *ido_calendar_menu_item_new (void); GtkWidget *ido_calendar_menu_item_get_calendar (IdoCalendarMenuItem *menuitem); - +gboolean ido_calendar_menu_item_mark_day (IdoCalendarMenuItem *menuitem, guint day); +gboolean ido_calendar_menu_item_unmark_day (IdoCalendarMenuItem *menuitem, guint day); +void ido_calendar_menu_item_clear_marks (IdoCalendarMenuItem *menuitem); +void ido_calendar_menu_item_set_display_options (IdoCalendarMenuItem *menuitem, GtkCalendarDisplayOptions flags); +GtkCalendarDisplayOptions ido_calendar_menu_item_get_display_options (IdoCalendarMenuItem *menuitem); +void ido_calendar_menu_item_get_date (IdoCalendarMenuItem *menuitem, + guint *year, + guint *month, + guint *day); +gboolean ido_calendar_menu_item_set_date (IdoCalendarMenuItem *menuitem, + guint year, + guint month, + guint day); G_END_DECLS #endif /* __IDO_CALENDAR_MENU_ITEM_H__ */ diff --git a/src/idoentrymenuitem.c b/src/idoentrymenuitem.c index 251d108..1636da9 100644 --- a/src/idoentrymenuitem.c +++ b/src/idoentrymenuitem.c @@ -26,8 +26,13 @@ #include <gdk/gdkkeysyms.h> #include "idoentrymenuitem.h" +#if GTK_CHECK_VERSION (3, 0, 0) +static void ido_entry_menu_item_select (GtkMenuItem *item); +static void ido_entry_menu_item_deselect (GtkMenuItem *item); +#else static void ido_entry_menu_item_select (GtkItem *item); static void ido_entry_menu_item_deselect (GtkItem *item); +#endif static gboolean ido_entry_menu_item_button_release (GtkWidget *widget, GdkEventButton *event); static gboolean ido_entry_menu_item_key_press (GtkWidget *widget, @@ -60,18 +65,27 @@ ido_entry_menu_item_class_init (IdoEntryMenuItemClass *klass) GObjectClass *gobject_class; GtkWidgetClass *widget_class; GtkMenuItemClass *menu_item_class; +#if ! GTK_CHECK_VERSION (3, 0, 0) GtkItemClass *item_class; +#endif gobject_class = G_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); menu_item_class = GTK_MENU_ITEM_CLASS (klass); +#if ! GTK_CHECK_VERSION (3, 0, 0) item_class = GTK_ITEM_CLASS (klass); +#endif widget_class->button_release_event = ido_entry_menu_item_button_release; widget_class->button_press_event = ido_entry_menu_item_button_press; +#if GTK_CHECK_VERSION (3, 0, 0) + menu_item_class->select = ido_entry_menu_item_select; + menu_item_class->deselect = ido_entry_menu_item_deselect; +#else item_class->select = ido_entry_menu_item_select; item_class->deselect = ido_entry_menu_item_deselect; +#endif menu_item_class->hide_on_activate = TRUE; @@ -118,11 +132,11 @@ is_key_press_valid (IdoEntryMenuItem *item, { switch (key) { - case GDK_Escape: - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Escape: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: return FALSE; default: @@ -145,21 +159,11 @@ ido_entry_menu_item_key_press (GtkWidget *widget, gtk_widget_event (entry, ((GdkEvent *)(void*)(event))); - if (entry->window != NULL) - { - gdk_window_raise (entry->window); - } - - if (!gtk_widget_has_focus (entry)) - { - gtk_widget_grab_focus (entry); - } - - /* We've handled the event, but if the key was GDK_Return + /* We've handled the event, but if the key was GDK_KEY_Return * we still want to forward the event up to the menu shell * to ensure that the menuitem receives the activate signal. */ - return event->keyval != GDK_Return; + return event->keyval != GDK_KEY_Return; } return FALSE; @@ -173,11 +177,8 @@ ido_entry_menu_item_send_focus_change (GtkWidget *widget, g_object_ref (widget); - if (in) - gtk_widget_grab_focus (widget); - event->focus_change.type = GDK_FOCUS_CHANGE; - event->focus_change.window = g_object_ref (widget->window); + event->focus_change.window = g_object_ref (gtk_widget_get_window (widget)); event->focus_change.in = in; gtk_widget_event (widget, event); @@ -196,9 +197,9 @@ ido_entry_menu_item_button_press (GtkWidget *widget, if (event->button == 1) { - if (entry->window != NULL) + if (gtk_widget_get_window (entry) != NULL) { - gdk_window_raise (entry->window); + gdk_window_raise (gtk_widget_get_window (entry)); } if (!gtk_widget_has_focus (entry)) @@ -228,7 +229,11 @@ ido_entry_menu_item_button_release (GtkWidget *widget, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_entry_menu_item_select (GtkMenuItem *item) +#else ido_entry_menu_item_select (GtkItem *item) +#endif { IDO_ENTRY_MENU_ITEM (item)->priv->selected = TRUE; @@ -236,7 +241,11 @@ ido_entry_menu_item_select (GtkItem *item) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_entry_menu_item_deselect (GtkMenuItem *item) +#else ido_entry_menu_item_deselect (GtkItem *item) +#endif { IDO_ENTRY_MENU_ITEM (item)->priv->selected = FALSE; @@ -248,12 +257,12 @@ static void entry_realized_cb (GtkWidget *widget, IdoEntryMenuItem *item) { - if (widget->window != NULL) + if (gtk_widget_get_window (widget) != NULL) { - gdk_window_raise (widget->window); + gdk_window_raise (gtk_widget_get_window (widget)); } - g_signal_connect (GTK_WIDGET (item)->parent, + g_signal_connect (gtk_widget_get_parent (GTK_WIDGET (item)), "key-press-event", G_CALLBACK (ido_entry_menu_item_key_press), item); diff --git a/src/idogesturemanager.c b/src/idogesturemanager.c deleted file mode 100644 index f603816..0000000 --- a/src/idogesturemanager.c +++ /dev/null @@ -1,688 +0,0 @@ -/* - * Copyright 2010 Canonical, Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of either or both of the following licenses: - * - * 1) the GNU Lesser General Public License version 3, as published by the - * Free Software Foundation; and/or - * 2) the GNU Lesser General Public License version 2.1, as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the applicable version of the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of both the GNU Lesser General Public - * License version 3 and version 2.1 along with this program. If not, see - * <http://www.gnu.org/licenses/> - * - * Authors: - * Cody Russell <crussell@canonical.com> - */ - -#include "idogesturemanager.h" - -#include <gdk/gdkx.h> -#include <geis/geis.h> - -typedef struct _IdoGestureRegistration IdoGestureRegistration; -typedef struct _IdoGestureBinding IdoGestureBinding; - -struct _IdoGestureManagerPrivate -{ - GHashTable *hash; -}; - -struct _IdoGestureBinding -{ - IdoGestureType type; - IdoGestureCallback start; - IdoGestureCallback update; - IdoGestureCallback end; -}; - -struct _IdoGestureRegistration -{ - GtkWindow *window; - GList *bindings; - GeisInstance instance; -}; - -static void gesture_added (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs); - -static void gesture_removed (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs); - -static void gesture_start (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs); - -static void gesture_update (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs); - -static void gesture_finish (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs); - -static IdoGestureManager *manager_singleton = NULL; -static GeisGestureFuncs gesture_funcs = { - gesture_added, - gesture_removed, - gesture_start, - gesture_update, - gesture_finish -}; - -G_DEFINE_TYPE (IdoGestureManager, ido_gesture_manager, G_TYPE_OBJECT) - -#define IDO_GESTURE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_GESTURE_MANAGER, IdoGestureManagerPrivate)) - -static void -ido_gesture_manager_dispose (GObject *object) -{ - IdoGestureManagerPrivate *priv = IDO_GESTURE_MANAGER (object)->priv; - - if (priv->hash != NULL) - { - g_hash_table_unref (priv->hash); - } -} - -static GObject * -ido_gesture_manager_constructor (GType type, - guint n_params, - GObjectConstructParam *params) -{ - GObject *object; - - if (manager_singleton != NULL) - { - object = g_object_ref (manager_singleton); - } - else - { - object = G_OBJECT_CLASS (ido_gesture_manager_parent_class)->constructor (type, - n_params, - params); - - manager_singleton = IDO_GESTURE_MANAGER (object); - g_object_add_weak_pointer (object, (gpointer) &manager_singleton); - } - - return object; -} - -static void -ido_gesture_manager_class_init (IdoGestureManagerClass *class) -{ - GObjectClass *gobject_class; - - gobject_class = G_OBJECT_CLASS (class); - - ido_gesture_manager_parent_class = g_type_class_peek_parent (class); - - g_type_class_add_private (gobject_class, sizeof (IdoGestureManagerPrivate)); - - gobject_class->constructor = ido_gesture_manager_constructor; - gobject_class->dispose = ido_gesture_manager_dispose; -} - -/* -static void -print_attr (GeisGestureAttr *attr) -{ - return; - - g_print ("\tattr '%s'=", attr->name); - switch (attr->type) - { - case GEIS_ATTR_TYPE_BOOLEAN: - g_print ("%s\n", attr->boolean_val ? "true" : "false"); - break; - case GEIS_ATTR_TYPE_FLOAT: - g_print ("%f\n", attr->float_val); - break; - case GEIS_ATTR_TYPE_INTEGER: - g_print ("%d\n", (gint)attr->integer_val); - break; - case GEIS_ATTR_TYPE_STRING: - g_print ("\"%s\"\n", attr->string_val); - break; - default: - g_print ("<unknown>\n"); - break; - } -} -*/ - -static void -pinch_gesture_handle_properties (IdoEventGesturePinch *event, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ - gint i = 0; - - for (i = 0; i < attr_count; ++i) - { - if (g_strcmp0 (attrs[i].name, "timestamp") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_INTEGER) - { - event->timestamp = attrs[i].integer_val; - } - else if (g_strcmp0 (attrs[i].name, "focus X") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->focus_x = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "focus Y") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->focus_y = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "radius delta") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->radius_delta = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "radial velocity") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->radial_velocity = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "radius") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->radius = attrs[i].float_val; - } - } -} - -static void -drag_gesture_handle_properties (IdoEventGestureDrag *event, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ - gint i; - - for (i = 0; i < attr_count; ++i) - { - if (g_strcmp0 (attrs[i].name, "timestamp") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_INTEGER) - { - event->timestamp = attrs[i].integer_val; - } - else if (g_strcmp0 (attrs[i].name, "focus X") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->focus_x = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "focus Y") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->focus_y = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "delta X") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->delta_x = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "delta Y") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->delta_y = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "velocity X") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->velocity_x = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "velocity Y") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->velocity_y = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "position X") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->position_x = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "position Y") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->position_y = attrs[i].float_val; - } - } -} - -static void -rotate_gesture_handle_properties (IdoEventGestureRotate *event, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ - gint i; - - for (i = 0; i < attr_count; ++i) - { - if (g_strcmp0 (attrs[i].name, "timestamp") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_INTEGER) - { - event->timestamp = attrs[i].integer_val; - } - else if (g_strcmp0 (attrs[i].name, "focus X") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->focus_x = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "focus Y") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->focus_y = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "angle delta") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->angle_delta = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "angular velocity") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->angular_velocity = attrs[i].float_val; - } - else if (g_strcmp0 (attrs[i].name, "angle") == 0 && - attrs[i].type == GEIS_ATTR_TYPE_FLOAT) - { - event->angle = attrs[i].float_val; - } - } -} - - -static void -gesture_added (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ -} - -static void -gesture_removed (void *cookie, - GeisGestureType gesture_type, - GeisGestureId gesture_id, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ -} - -static void -gesture_start (void *cookie, - GeisGestureType type, - GeisGestureId id, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ - IdoGestureRegistration *reg = (IdoGestureRegistration *)cookie; - GList *l = NULL; - - for (l = reg->bindings; l != NULL; l = l->next) - { - IdoGestureBinding *binding = (IdoGestureBinding *)l->data; - - if (binding->type == type) - { - if (type == IDO_GESTURE_DRAG1 || - type == IDO_GESTURE_DRAG2 || - type == IDO_GESTURE_DRAG3 || - type == IDO_GESTURE_DRAG4 || - type == IDO_GESTURE_DRAG5) - { - IdoEventGestureDrag drag; - - drag.type = type; - drag.id = id; - - drag_gesture_handle_properties (&drag, - attr_count, - attrs); - - binding->start (reg->window, - ((IdoGestureEvent*)&drag)); - } - else if (type == IDO_GESTURE_PINCH1 || - type == IDO_GESTURE_PINCH2 || - type == IDO_GESTURE_PINCH3 || - type == IDO_GESTURE_PINCH4 || - type == IDO_GESTURE_PINCH5) - { - IdoEventGesturePinch pinch; - - pinch.type = type; - pinch.id = id; - - pinch_gesture_handle_properties (&pinch, - attr_count, - attrs); - - binding->start (reg->window, - ((IdoGestureEvent*)&pinch)); - } - else if (type == IDO_GESTURE_ROTATE1 || - type == IDO_GESTURE_ROTATE2 || - type == IDO_GESTURE_ROTATE3 || - type == IDO_GESTURE_ROTATE4 || - type == IDO_GESTURE_ROTATE5) - { - IdoEventGestureRotate rotate; - - rotate.type = type; - rotate.id = id; - - rotate_gesture_handle_properties (&rotate, - attr_count, - attrs); - - binding->start (reg->window, - ((IdoGestureEvent*)&rotate)); - } - - return; - } - } -} - -static void -gesture_update (void *cookie, - GeisGestureType type, - GeisGestureId id, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ - IdoGestureRegistration *reg = (IdoGestureRegistration *)cookie; - GList *l = NULL; - - for (l = reg->bindings; l != NULL; l = l->next) - { - IdoGestureBinding *binding = (IdoGestureBinding *)l->data; - - if (binding->type == type) - { - if (type == IDO_GESTURE_DRAG1 || - type == IDO_GESTURE_DRAG2 || - type == IDO_GESTURE_DRAG3 || - type == IDO_GESTURE_DRAG4 || - type == IDO_GESTURE_DRAG5) - { - IdoEventGestureDrag drag; - - drag.type = type; - drag.id = id; - - drag_gesture_handle_properties (&drag, - attr_count, - attrs); - - binding->update (reg->window, - ((IdoGestureEvent*)&drag)); - } - else if (type == IDO_GESTURE_PINCH1 || - type == IDO_GESTURE_PINCH2 || - type == IDO_GESTURE_PINCH3 || - type == IDO_GESTURE_PINCH4 || - type == IDO_GESTURE_PINCH5) - { - IdoEventGesturePinch pinch; - - pinch.type = type; - pinch.id = id; - - pinch_gesture_handle_properties (&pinch, - attr_count, - attrs); - - binding->update (reg->window, - ((IdoGestureEvent*)&pinch)); - } - else if (type == IDO_GESTURE_ROTATE1 || - type == IDO_GESTURE_ROTATE2 || - type == IDO_GESTURE_ROTATE3 || - type == IDO_GESTURE_ROTATE4 || - type == IDO_GESTURE_ROTATE5) - { - IdoEventGestureRotate rotate; - - rotate.type = type; - rotate.id = id; - - rotate_gesture_handle_properties (&rotate, - attr_count, - attrs); - - binding->update (reg->window, - ((IdoGestureEvent*)&rotate)); - } - } - } -} - -static void -gesture_finish (void *cookie, - GeisGestureType type, - GeisGestureId id, - GeisSize attr_count, - GeisGestureAttr *attrs) -{ - IdoGestureRegistration *reg = (IdoGestureRegistration *)cookie; - GList *l = NULL; - - for (l = reg->bindings; l != NULL; l = l->next) - { - IdoGestureBinding *binding = (IdoGestureBinding *)l->data; - - if (binding->type == type) - { - if (type == IDO_GESTURE_DRAG1 || - type == IDO_GESTURE_DRAG2 || - type == IDO_GESTURE_DRAG3 || - type == IDO_GESTURE_DRAG4 || - type == IDO_GESTURE_DRAG5) - { - IdoEventGestureDrag drag; - - drag.type = type; - drag.id = id; - - drag_gesture_handle_properties (&drag, - attr_count, - attrs); - - binding->end (reg->window, - ((IdoGestureEvent*)&drag)); - } - else if (type == IDO_GESTURE_PINCH1 || - type == IDO_GESTURE_PINCH2 || - type == IDO_GESTURE_PINCH3 || - type == IDO_GESTURE_PINCH4 || - type == IDO_GESTURE_PINCH5) - { - IdoEventGesturePinch pinch; - - pinch.type = type; - pinch.id = id; - - pinch_gesture_handle_properties (&pinch, - attr_count, - attrs); - - binding->end (reg->window, - ((IdoGestureEvent*)&pinch)); - } - else if (type == IDO_GESTURE_ROTATE1 || - type == IDO_GESTURE_ROTATE2 || - type == IDO_GESTURE_ROTATE3 || - type == IDO_GESTURE_ROTATE4 || - type == IDO_GESTURE_ROTATE5) - { - IdoEventGestureRotate rotate; - - rotate.type = type; - rotate.id = id; - - rotate_gesture_handle_properties (&rotate, - attr_count, - attrs); - - binding->end (reg->window, - ((IdoGestureEvent*)&rotate)); - } - } - } -} - -static void -ido_gesture_manager_init (IdoGestureManager *item) -{ - IdoGestureManagerPrivate *priv; - - priv = item->priv = IDO_GESTURE_MANAGER_GET_PRIVATE (item); - - priv->hash = g_hash_table_new (g_direct_hash, g_direct_equal); -} - -static gboolean -io_callback (GIOChannel *source, - GIOCondition condition, - gpointer data) -{ - IdoGestureRegistration *reg = (IdoGestureRegistration *)data; - - geis_event_dispatch (reg->instance); - - return TRUE; -} - -/* Public API */ -IdoGestureManager * -ido_gesture_manager_get (void) -{ - return g_object_new (IDO_TYPE_GESTURE_MANAGER, NULL); -} - -/** - * ido_gesture_manager_register_window: - * @window: A #GtkWindow to register the gesture event for. - * @gesture_type: The type of gesture event to register. - * @start: Called when a user initiates a gesture. - * @update: Called each time the user updates the gesture. - * @end: Called when the user ends the gesture. - * - * Registers a toplevel window to receive gesture events. - * The callback parameters provided will be called by the - * #IdoGestureManager whenever the user initiates a gesture - * on the specified window. - */ -void -ido_gesture_manager_register_window (IdoGestureManager *manager, - GtkWindow *window, - IdoGestureType gesture_type, - IdoGestureCallback start, - IdoGestureCallback update, - IdoGestureCallback end) -{ - IdoGestureManagerPrivate *priv; - IdoGestureRegistration *reg; - IdoGestureBinding *binding; - - g_return_if_fail (IDO_IS_GESTURE_MANAGER (manager)); - g_return_if_fail (GTK_IS_WINDOW (window)); - g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window))); - - priv = manager->priv; - - if (!(reg = g_hash_table_lookup (priv->hash, window))) - { - GeisInstance instance; - GIOChannel *iochannel; - gint fd = -1; - GeisXcbWinInfo xcb_win_info = { - .display_name = NULL, - .screenp = NULL, - .window_id = GDK_DRAWABLE_XID (GTK_WIDGET (window)->window) - }; - GeisWinInfo win_info = { - GEIS_XCB_FULL_WINDOW, - &xcb_win_info - }; - - if (geis_init (&win_info, &instance) != GEIS_STATUS_SUCCESS) - { - g_warning ("Failed to initialize gesture manager."); - return; - } - - if (geis_configuration_supported (instance, - GEIS_CONFIG_UNIX_FD) != GEIS_STATUS_SUCCESS) - { - g_warning ("Gesture manager does not support UNIX fd."); - return; - } - - if (geis_configuration_get_value (instance, - GEIS_CONFIG_UNIX_FD, - &fd) != GEIS_STATUS_SUCCESS) - { - g_error ("Gesture manager failed to obtain UNIX fd."); - return; - } - - reg = g_new0 (IdoGestureRegistration, 1); - - reg->window = window; - reg->instance = instance; - - geis_subscribe (reg->instance, - GEIS_ALL_INPUT_DEVICES, - GEIS_ALL_GESTURES, - &gesture_funcs, - reg); - - iochannel = g_io_channel_unix_new (fd); - g_io_add_watch (iochannel, - G_IO_IN, - io_callback, - reg); - } - - /* XXX - check for duplicates in reg->bindings first */ - binding = g_new0 (IdoGestureBinding, 1); - - g_print (" *** Adding binding type %d\n", (gint)gesture_type); - - binding->type = gesture_type; - binding->start = start; - binding->update = update; - binding->end = end; - - reg->bindings = g_list_append (reg->bindings, binding); - - g_hash_table_insert (priv->hash, - window, - reg); -} diff --git a/src/idogesturemanager.h b/src/idogesturemanager.h deleted file mode 100644 index bc3ad33..0000000 --- a/src/idogesturemanager.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2010 Canonical, Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of either or both of the following licenses: - * - * 1) the GNU Lesser General Public License version 3, as published by the - * Free Software Foundation; and/or - * 2) the GNU Lesser General Public License version 2.1, as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the applicable version of the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of both the GNU Lesser General Public - * License version 3 and version 2.1 along with this program. If not, see - * <http://www.gnu.org/licenses/> - * - * Authors: - * Cody Russell <crussell@canonical.com> - */ - -#ifndef __IDO_GESTURE_MANAGER_H__ -#define __IDO_GESTURE_MANAGER_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define IDO_TYPE_GESTURE_MANAGER (ido_gesture_manager_get_type ()) -#define IDO_GESTURE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_GESTURE_MANAGER, IdoGestureManager)) -#define IDO_GESTURE_MANAGER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), IDO_TYPE_GESTURE_MANAGER, IdoGestureManagerClass)) -#define IDO_IS_GESTURE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), IDO_TYPE_GESTURE_MANAGER)) -#define IDO_IS_GESTURE_MANAGER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), IDO_TYPE_GESTURE_MANAGER)) -#define IDO_GESTURE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), IDO_TYPE_GESTURE_MANAGER, IdoGestureManagerClass)) - -typedef struct _IdoGestureManager IdoGestureManager; -typedef struct _IdoGestureManagerClass IdoGestureManagerClass; -typedef struct _IdoGestureManagerPrivate IdoGestureManagerPrivate; - -typedef union _IdoGestureEvent IdoGestureEvent; -typedef struct _IdoEventGestureDrag IdoEventGestureDrag; -typedef struct _IdoEventGesturePinch IdoEventGesturePinch; -typedef struct _IdoEventGestureRotate IdoEventGestureRotate; - -typedef enum { - IDO_GESTURE_DRAG1, - IDO_GESTURE_PINCH1, - IDO_GESTURE_ROTATE1, - - IDO_GESTURE_DRAG2, - IDO_GESTURE_PINCH2, - IDO_GESTURE_ROTATE2, - - IDO_GESTURE_DRAG3, - IDO_GESTURE_PINCH3, - IDO_GESTURE_ROTATE3, - - IDO_GESTURE_DRAG4, - IDO_GESTURE_PINCH4, - IDO_GESTURE_ROTATE4, - - IDO_GESTURE_DRAG5, - IDO_GESTURE_PINCH5, - IDO_GESTURE_ROTATE5, - - IDO_GESTURE_TAP1, - IDO_GESTURE_TAP2, - IDO_GESTURE_TAP3, - IDO_GESTURE_TAP4, - IDO_GESTURE_TAP5 -} IdoGestureType; - -struct _IdoEventGestureDrag -{ - IdoGestureType type; - guint id; - GdkWindow *window; - GdkWindow *root; - GdkWindow *child; - guint32 timestamp; - gint fingers; - gdouble focus_x; - gdouble focus_y; - gint delta_x; - gint delta_y; - gdouble velocity_x; - gdouble velocity_y; - gdouble position_x; - gdouble position_y; -}; - -struct _IdoEventGesturePinch -{ - IdoGestureType type; - guint id; - GdkWindow *window; - GdkWindow *root; - GdkWindow *child; - guint32 timestamp; - guint fingers; - gdouble focus_x; - gdouble focus_y; - gdouble radius_delta; - gdouble radial_velocity; - gdouble radius; -}; - -struct _IdoEventGestureRotate -{ - IdoGestureType type; - guint id; - GdkWindow *window; - GdkWindow *root; - GdkWindow *child; - guint32 timestamp; - guint fingers; - gdouble focus_x; - gdouble focus_y; - gdouble angle_delta; - gdouble angular_velocity; - gdouble angle; -}; - -union _IdoGestureEvent -{ - IdoGestureType type; - IdoEventGestureDrag drag; - IdoEventGesturePinch pinch; - IdoEventGestureRotate rotate; -}; - -struct _IdoGestureManager -{ - GObject parent_instance; - - IdoGestureManagerPrivate *priv; -}; - -struct _IdoGestureManagerClass -{ - GObjectClass parent_class; -}; - -typedef void (* IdoGestureCallback) (GtkWindow *window, - IdoGestureEvent *gesture); - -GType ido_gesture_manager_get_type (void) G_GNUC_CONST; -IdoGestureManager *ido_gesture_manager_get (void); -void ido_gesture_manager_register_window (IdoGestureManager *manager, - GtkWindow *window, - IdoGestureType gesture_type, - IdoGestureCallback start, - IdoGestureCallback update, - IdoGestureCallback end); - -G_END_DECLS - -#endif /* __IDO_GESTURE_MANAGER_H__ */ diff --git a/src/idomessagedialog.c b/src/idomessagedialog.c index ba73233..9b5fe2c 100644 --- a/src/idomessagedialog.c +++ b/src/idomessagedialog.c @@ -82,7 +82,7 @@ ido_message_dialog_map (GtkWidget *widget) * * See: https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/240794 */ - gdk_window_set_functions (widget->window, + gdk_window_set_functions (gtk_widget_get_window (widget), GDK_FUNC_RESIZE | GDK_FUNC_MOVE); ido_message_dialog_get_secondary_label (IDO_MESSAGE_DIALOG (widget)); @@ -166,14 +166,14 @@ ido_message_dialog_focus_in_event (GtkWidget *widget, IdoTimeline *timeline; IdoMessageDialogMorphContext *context; - start = GTK_WIDGET (dialog)->requisition; + gtk_widget_get_requisition (GTK_WIDGET (dialog), &start); priv->expanded = TRUE; gtk_widget_show (priv->action_area); gtk_widget_show (priv->secondary_label); - gtk_widget_size_request (GTK_WIDGET (dialog), &end); + gtk_widget_get_requisition (GTK_WIDGET (dialog), &end); gtk_widget_hide (priv->action_area); gtk_widget_hide (priv->secondary_label); @@ -209,7 +209,7 @@ ido_message_dialog_constructed (GObject *object) event_box = gtk_event_box_new (); gtk_widget_show (event_box); - vbox = GTK_DIALOG (object)->vbox; + vbox = gtk_dialog_get_content_area (GTK_DIALOG (object)); priv->action_area = gtk_dialog_get_action_area (GTK_DIALOG (object)); g_object_ref (G_OBJECT (vbox)); @@ -237,11 +237,7 @@ ido_message_dialog_class_init (IdoMessageDialogClass *class) static void ido_message_dialog_init (IdoMessageDialog *dialog) { - IdoMessageDialogPrivate *priv; - gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE); - - priv = IDO_MESSAGE_DIALOG_GET_PRIVATE (dialog); } /** @@ -284,11 +280,13 @@ ido_message_dialog_new (GtkWindow *parent, NULL); dialog = GTK_DIALOG (widget); +#if ! GTK_CHECK_VERSION(3, 0, 0) if (flags & GTK_DIALOG_NO_SEPARATOR) { g_warning ("The GTK_DIALOG_NO_SEPARATOR flag cannot be used for IdoMessageDialog"); flags &= ~GTK_DIALOG_NO_SEPARATOR; } +#endif if (message_format) { @@ -296,8 +294,7 @@ ido_message_dialog_new (GtkWindow *parent, msg = g_strdup_vprintf (message_format, args); va_end (args); - gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (widget)->label), - msg); + g_object_set (G_OBJECT (widget), "text", msg, NULL); g_free (msg); } @@ -397,7 +394,8 @@ ido_message_dialog_get_label (IdoMessageDialog *dialog, gboolean primary) label = GTK_LABEL (vlist->data); - if (strcmp ((primary ? text : secondary_text), label->label) == 0) + if (strcmp ((primary ? text : secondary_text), + gtk_label_get_label (label)) == 0) { return GTK_WIDGET (label); } diff --git a/src/idomessagedialog.h b/src/idomessagedialog.h index 4a44957..4313fb3 100644 --- a/src/idomessagedialog.h +++ b/src/idomessagedialog.h @@ -29,7 +29,7 @@ #ifndef __IDO_MESSAGE_DIALOG_H__ #define __IDO_MESSAGE_DIALOG_H__ -#include <gtk/gtkmessagedialog.h> +#include <gtk/gtk.h> #define IDO_TYPE_MESSAGE_DIALOG (ido_message_dialog_get_type ()) #define IDO_MESSAGE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_MESSAGE_DIALOG, IdoMessageDialog)) diff --git a/src/idorange.c b/src/idorange.c index c38ac88..ba5c2c8 100644 --- a/src/idorange.c +++ b/src/idorange.c @@ -179,7 +179,7 @@ ido_range_init (IdoRange *range) * Creates a new #IdoRange widget. **/ GtkWidget * -ido_range_new (GtkObject *adj, +ido_range_new (GtkAdjustment *adj, IdoRangeStyle style) { g_return_val_if_fail (GTK_IS_ADJUSTMENT (adj), NULL); diff --git a/src/idorange.h b/src/idorange.h index a88a900..f502520 100644 --- a/src/idorange.h +++ b/src/idorange.h @@ -64,7 +64,7 @@ struct _IdoRangeClass GType ido_range_get_type (void) G_GNUC_CONST; -GtkWidget* ido_range_new (GtkObject *adj, +GtkWidget* ido_range_new (GtkAdjustment *adj, IdoRangeStyle style); G_END_DECLS diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c index f29c2dc..8b9e1ac 100644 --- a/src/idoscalemenuitem.c +++ b/src/idoscalemenuitem.c @@ -70,6 +70,7 @@ struct _IdoScaleMenuItemPrivate { gboolean grabbed; IdoScaleMenuItemStyle style; IdoRangeStyle range_style; + gint toggle_size; }; enum { @@ -184,11 +185,11 @@ ido_scale_menu_item_size_allocate (GtkWidget *widget, priv->right_padding = primary_padding; } - priv->child_allocation.x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness; - priv->child_allocation.y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness; + priv->child_allocation.x = gtk_container_get_border_width (GTK_CONTAINER (widget)) + gtk_widget_get_style (widget)->xthickness; + priv->child_allocation.y = gtk_container_get_border_width (GTK_CONTAINER (widget)) + gtk_widget_get_style (widget)->ythickness; priv->child_allocation.x += horizontal_padding; - priv->child_allocation.x += GTK_MENU_ITEM (widget)->toggle_size; + priv->child_allocation.x += priv->toggle_size; priv->child_allocation.width = MAX (1, (gint)allocation->width - priv->child_allocation.x * 2); priv->child_allocation.width -= (primary_padding + secondary_padding); @@ -198,11 +199,21 @@ ido_scale_menu_item_size_allocate (GtkWidget *widget, } static void +ido_scale_menu_item_toggle_size_allocate (IdoScaleMenuItem *item, + gint toggle_size, + gpointer user_data) +{ + IdoScaleMenuItemPrivate *priv = GET_PRIVATE (item); + + priv->toggle_size = toggle_size; +} + +static void ido_scale_menu_item_constructed (GObject *object) { IdoScaleMenuItem *self = IDO_SCALE_MENU_ITEM (object); IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); - GtkObject *adj = gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0); + GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0)); IdoRangeStyle range_style; GtkWidget *hbox; @@ -235,6 +246,10 @@ ido_scale_menu_item_constructed (GObject *object) update_packing (self, priv->style, priv->style); + g_signal_connect (self, "toggle-size-allocate", + G_CALLBACK (ido_scale_menu_item_toggle_size_allocate), + NULL); + g_signal_connect (self, "notify", G_CALLBACK (ido_scale_menu_item_notify), NULL); @@ -246,7 +261,6 @@ static void ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (item_class); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (item_class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (item_class); widget_class->button_press_event = ido_scale_menu_item_button_press_event; @@ -310,7 +324,7 @@ ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (object_class, sizeof (IdoScaleMenuItemPrivate)); + g_type_class_add_private (item_class, sizeof (IdoScaleMenuItemPrivate)); } static void @@ -456,11 +470,9 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem, { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); GtkWidget *scale = priv->scale; - GtkWidget *parent; gdouble x; // can we block emissions of "grab-notify" on parent?? - parent = gtk_widget_get_parent (GTK_WIDGET (menuitem)); translate_event_coordinates (menuitem, event->x, &x); event->x = x; @@ -490,7 +502,6 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem, { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); GtkWidget *scale = priv->scale; - GdkWindow *tmp = event->window; gdouble x; if (event->x > priv->child_allocation.x && @@ -539,8 +550,6 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem, return TRUE; } - event->window = GTK_RANGE (scale)->event_window; - translate_event_coordinates (menuitem, event->x, &x); event->x = x; @@ -550,8 +559,6 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem, gtk_widget_event (scale, ((GdkEvent *)(void*)(event))); - event->window = tmp; - if (priv->grabbed) { priv->grabbed = FALSE; @@ -673,13 +680,13 @@ ido_scale_menu_item_new_with_range (const gchar *label, gdouble max, gdouble step) { - GtkObject *adjustment = gtk_adjustment_new (value, min, max, step, 10 * step, 0); + GtkAdjustment *adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (value, min, max, step, 10 * step, 0)); - return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, - "label", label, - "range-style", range_style, - "adjustment", adjustment, - NULL); + return GTK_WIDGET (g_object_new (IDO_TYPE_SCALE_MENU_ITEM, + "label", label, + "range-style", range_style, + "adjustment", adjustment, + NULL)); } /** @@ -789,7 +796,7 @@ ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem) * Whether this is visible depends upon the return value from * ido_scale_menu_item_get_style(). **/ -G_CONST_RETURN gchar* +const gchar* ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem) { IdoScaleMenuItemPrivate *priv; @@ -810,7 +817,7 @@ ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem) * Whether this is visible depends upon the return value from * ido_scale_menu_item_get_style(). **/ -G_CONST_RETURN gchar* +const gchar* ido_scale_menu_item_get_secondary_label (IdoScaleMenuItem *menuitem) { IdoScaleMenuItemPrivate *priv; diff --git a/src/idoscalemenuitem.h b/src/idoscalemenuitem.h index 44a9033..5afafd3 100644 --- a/src/idoscalemenuitem.h +++ b/src/idoscalemenuitem.h @@ -26,7 +26,7 @@ #ifndef __IDO_SCALE_MENU_ITEM_H__ #define __IDO_SCALE_MENU_ITEM_H__ -#include <gtk/gtkmenuitem.h> +#include <gtk/gtk.h> #include "idorange.h" G_BEGIN_DECLS @@ -79,8 +79,8 @@ void ido_scale_menu_item_set_style (IdoScaleMenuItem IdoScaleMenuItemStyle style); GtkWidget *ido_scale_menu_item_get_primary_image (IdoScaleMenuItem *menuitem); GtkWidget *ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem); -G_CONST_RETURN gchar *ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem); -G_CONST_RETURN gchar *ido_scale_menu_item_get_secondary_label (IdoScaleMenuItem *menuitem); +const gchar *ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem); +const gchar *ido_scale_menu_item_get_secondary_label (IdoScaleMenuItem *menuitem); void ido_scale_menu_item_set_primary_label (IdoScaleMenuItem *menuitem, const gchar *label); void ido_scale_menu_item_set_secondary_label (IdoScaleMenuItem *menuitem, diff --git a/src/idotimeline.c b/src/idotimeline.c index a9ca0c6..c6275ae 100644 --- a/src/idotimeline.c +++ b/src/idotimeline.c @@ -22,7 +22,7 @@ #include "idotimeline.h" #include "idotypebuiltins.h" -#include <gtk/gtksettings.h> +#include <gtk/gtk.h> #include <math.h> #define IDO_TIMELINE_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IDO_TYPE_TIMELINE, IdoTimelinePriv)) @@ -194,10 +194,8 @@ ido_timeline_set_property (GObject *object, GParamSpec *pspec) { IdoTimeline *timeline; - IdoTimelinePriv *priv; timeline = IDO_TIMELINE (object); - priv = IDO_TIMELINE_GET_PRIV (timeline); switch (prop_id) { diff --git a/src/idotimeline.h b/src/idotimeline.h index 5df6b97..e26f9d3 100644 --- a/src/idotimeline.h +++ b/src/idotimeline.h @@ -21,7 +21,7 @@ #define __IDO_TIMELINE_H__ #include <glib-object.h> -#include <gtk/gtkenums.h> +#include <gtk/gtk.h> #include <gdk/gdk.h> G_BEGIN_DECLS diff --git a/src/libido.h b/src/libido.h index ef0b8b3..4c4f68b 100644 --- a/src/libido.h +++ b/src/libido.h @@ -26,6 +26,7 @@ #ifndef __IDO__ #define __IDO__ +#include <libido/idocalendarmenuitem.h> #include <libido/idoscalemenuitem.h> #include <libido/idoentrymenuitem.h> #include <libido/idomessagedialog.h> |