aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Russell <crussell@canonical.com>2010-07-19 05:56:50 -0500
committerCody Russell <crussell@canonical.com>2010-07-19 05:56:50 -0500
commit29475f3334df3b7c7b5b547afa8b31944ac28237 (patch)
treeeb7e269a960b0e9702b81b855a649af79d336899
parent272dafa2317a9ac6602cf595b7571ed5bb96decc (diff)
downloadayatana-ido-29475f3334df3b7c7b5b547afa8b31944ac28237.tar.gz
ayatana-ido-29475f3334df3b7c7b5b547afa8b31944ac28237.tar.bz2
ayatana-ido-29475f3334df3b7c7b5b547afa8b31944ac28237.zip
Calendar
-rw-r--r--example/menus.c4
-rw-r--r--gtk-doc.make14
-rw-r--r--src/Makefile.am3
-rw-r--r--src/idocalendarmenuitem.c233
-rw-r--r--src/idocalendarmenuitem.h63
5 files changed, 313 insertions, 4 deletions
diff --git a/example/menus.c b/example/menus.c
index a2647bb..9c94fe3 100644
--- a/example/menus.c
+++ b/example/menus.c
@@ -1,6 +1,7 @@
#include <gtk/gtk.h>
#include "idoscalemenuitem.h"
+#include "idocalendarmenuitem.h"
#include "idoentrymenuitem.h"
static void
@@ -67,6 +68,9 @@ main (int argc, char *argv[])
menuitem = ido_entry_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ menuitem = ido_calendar_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
menuitem = ido_scale_menu_item_new_with_range ("Volume",
IDO_RANGE_STYLE_SMALL,
65, 0, 100, 1);
diff --git a/gtk-doc.make b/gtk-doc.make
index 63adaed..57fab98 100644
--- a/gtk-doc.make
+++ b/gtk-doc.make
@@ -75,8 +75,11 @@ $(REPORT_FILES): sgml-build.stamp
scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB)
@echo 'gtk-doc: Scanning header files'
@-chmod -R u+w $(srcdir)
- @cd $(srcdir) && \
- gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="$(IGNORE_HFILES)" $(SCAN_OPTIONS) $(EXTRA_HFILES)
+ @_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 \
@@ -109,8 +112,11 @@ $(srcdir)/tmpl/*.sgml:
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)
- @cd $(srcdir) && \
- gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $(MKDB_OPTIONS)
+ @_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
diff --git a/src/Makefile.am b/src/Makefile.am
index 85382c7..1485019 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,7 @@ stamp_files = \
idotypebuiltins.c
sources_h = \
+ idocalendarmenuitem.h \
idoentrymenuitem.h \
idomessagedialog.h \
idorange.h \
@@ -51,6 +52,7 @@ lib_LTLIBRARIES = libido-0.1.la
libido_0_1_la_SOURCES = \
idotypebuiltins.c \
+ idocalendarmenuitem.c \
idoentrymenuitem.c \
idomessagedialog.c \
idorange.c \
@@ -60,6 +62,7 @@ libido_0_1_la_SOURCES = \
libidoincludedir=$(includedir)/libido-0.1/libido
libidoinclude_HEADERS = \
+ idocalendarmenuitem.h \
idoentrymenuitem.h \
idomessagedialog.h \
idorange.h \
diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c
new file mode 100644
index 0000000..15d64ee
--- /dev/null
+++ b/src/idocalendarmenuitem.c
@@ -0,0 +1,233 @@
+/*
+ * 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 <gdk/gdkkeysyms.h>
+#include "idocalendarmenuitem.h"
+
+static void ido_calendar_menu_item_select (GtkItem *item);
+static void ido_calendar_menu_item_deselect (GtkItem *item);
+static gboolean ido_calendar_menu_item_button_release (GtkWidget *widget,
+ GdkEventButton *event);
+static gboolean ido_calendar_menu_item_button_press (GtkWidget *widget,
+ GdkEventButton *event);
+static void ido_calendar_menu_item_send_focus_change (GtkWidget *widget,
+ gboolean in);
+static void calendar_realized_cb (GtkWidget *widget,
+ IdoCalendarMenuItem *item);
+static void calendar_move_focus_cb (GtkWidget *widget,
+ GtkDirectionType direction,
+ IdoCalendarMenuItem *item);
+
+struct _IdoCalendarMenuItemPrivate
+{
+ GtkWidget *box;
+ GtkWidget *calendar;
+ gboolean selected;
+};
+
+G_DEFINE_TYPE (IdoCalendarMenuItem, ido_calendar_menu_item, GTK_TYPE_MENU_ITEM)
+
+#define IDO_CALENDAR_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_CALENDAR_MENU_ITEM, IdoCalendarMenuItemPrivate))
+
+static void
+ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
+ GtkMenuItemClass *menu_item_class;
+ GtkItemClass *item_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+ menu_item_class = GTK_MENU_ITEM_CLASS (klass);
+ item_class = GTK_ITEM_CLASS (klass);
+
+ widget_class->button_release_event = ido_calendar_menu_item_button_release;
+ widget_class->button_press_event = ido_calendar_menu_item_button_press;
+
+ item_class->select = ido_calendar_menu_item_select;
+ item_class->deselect = ido_calendar_menu_item_deselect;
+
+ menu_item_class->hide_on_activate = TRUE;
+
+ g_type_class_add_private (gobject_class, sizeof (IdoCalendarMenuItemPrivate));
+}
+
+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);
+
+ priv->calendar = g_object_new (gtk_calendar_get_type (),
+ NULL);
+
+ g_signal_connect (priv->calendar,
+ "realize",
+ G_CALLBACK (calendar_realized_cb),
+ item);
+ g_signal_connect (priv->calendar,
+ "move-focus",
+ G_CALLBACK (calendar_move_focus_cb),
+ item);
+
+ priv->box = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->box), priv->calendar, FALSE, FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (item), priv->box);
+
+ gtk_widget_show_all (priv->box);
+}
+
+static void
+ido_calendar_menu_item_send_focus_change (GtkWidget *widget,
+ gboolean in)
+{
+ GdkEvent *event = gdk_event_new (GDK_FOCUS_CHANGE);
+
+ g_object_ref (widget);
+
+ if (in)
+ {
+ GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
+ }
+ else
+ {
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
+ }
+
+ event->focus_change.type = GDK_FOCUS_CHANGE;
+ event->focus_change.window = g_object_ref (widget->window);
+ event->focus_change.in = in;
+
+ gtk_widget_event (widget, event);
+
+ g_object_notify (G_OBJECT (widget), "has-focus");
+
+ g_object_unref (widget);
+ gdk_event_free (event);
+}
+
+static gboolean
+ido_calendar_menu_item_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar;
+
+ if (event->button == 1)
+ {
+ if (calendar->window != NULL)
+ {
+ gdk_window_raise (calendar->window);
+ }
+
+ if (!gtk_widget_has_focus (calendar))
+ {
+ gtk_widget_grab_focus (calendar);
+ }
+
+ gtk_widget_event (calendar,
+ ((GdkEvent *)(void*)(event)));
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+ido_calendar_menu_item_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar;
+
+ gtk_widget_event (calendar,
+ ((GdkEvent *)(void*)(event)));
+
+ return TRUE;
+}
+
+static void
+ido_calendar_menu_item_select (GtkItem *item)
+{
+ IDO_CALENDAR_MENU_ITEM (item)->priv->selected = TRUE;
+
+ ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), TRUE);
+}
+
+static void
+ido_calendar_menu_item_deselect (GtkItem *item)
+{
+ IDO_CALENDAR_MENU_ITEM (item)->priv->selected = FALSE;
+
+ ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), FALSE);
+}
+
+
+static void
+calendar_realized_cb (GtkWidget *widget,
+ IdoCalendarMenuItem *item)
+{
+ if (widget->window != NULL)
+ {
+ gdk_window_raise (widget->window);
+ }
+
+ ido_calendar_menu_item_send_focus_change (widget, TRUE);
+}
+
+static void
+calendar_move_focus_cb (GtkWidget *widget,
+ GtkDirectionType direction,
+ IdoCalendarMenuItem *item)
+{
+ ido_calendar_menu_item_send_focus_change (GTK_WIDGET (IDO_CALENDAR_MENU_ITEM (item)->priv->calendar), FALSE);
+
+ g_signal_emit_by_name (item,
+ "move-focus",
+ GTK_DIR_TAB_FORWARD);
+}
+
+/* Public API */
+GtkWidget *
+ido_calendar_menu_item_new (void)
+{
+ return g_object_new (IDO_TYPE_CALENDAR_MENU_ITEM, NULL);
+}
+
+GtkWidget *
+ido_calendar_menu_item_get_calendar (IdoCalendarMenuItem *item)
+{
+ g_return_val_if_fail (IDO_IS_CALENDAR_MENU_ITEM (item), NULL);
+
+ return item->priv->calendar;
+}
diff --git a/src/idocalendarmenuitem.h b/src/idocalendarmenuitem.h
new file mode 100644
index 0000000..3f9bf96
--- /dev/null
+++ b/src/idocalendarmenuitem.h
@@ -0,0 +1,63 @@
+/*
+ * 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_CALENDAR_MENU_ITEM_H__
+#define __IDO_CALENDAR_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define IDO_TYPE_CALENDAR_MENU_ITEM (ido_calendar_menu_item_get_type ())
+#define IDO_CALENDAR_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_CALENDAR_MENU_ITEM, IdoCalendarMenuItem))
+#define IDO_CALENDAR_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), IDO_TYPE_CALENDAR_MENU_ITEM, IdoCalendarMenuItemClass))
+#define IDO_IS_CALENDAR_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), IDO_TYPE_CALENDAR_MENU_ITEM))
+#define IDO_IS_CALENDAR_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), IDO_TYPE_CALENDAR_MENU_ITEM))
+#define IDO_CALENDAR_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), IDO_TYPE_CALENDAR_MENU_ITEM, IdoCalendarMenuItemClass))
+
+typedef struct _IdoCalendarMenuItem IdoCalendarMenuItem;
+typedef struct _IdoCalendarMenuItemClass IdoCalendarMenuItemClass;
+typedef struct _IdoCalendarMenuItemPrivate IdoCalendarMenuItemPrivate;
+
+struct _IdoCalendarMenuItem
+{
+ GtkMenuItem parent_instance;
+
+ IdoCalendarMenuItemPrivate *priv;
+};
+
+struct _IdoCalendarMenuItemClass
+{
+ GtkMenuItemClass parent_class;
+};
+
+GType ido_calendar_menu_item_get_type (void) G_GNUC_CONST;
+
+GtkWidget *ido_calendar_menu_item_new (void);
+GtkWidget *ido_calendar_menu_item_get_calendar (IdoCalendarMenuItem *menuitem);
+
+G_END_DECLS
+
+#endif /* __IDO_CALENDAR_MENU_ITEM_H__ */