From 1b7166676eb42a26a8547e795064631edd0653df Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 25 Jul 2013 18:53:48 -0500 Subject: add support for com.canonical.indicator.alarm menuitems. --- debian/libido3-0.1-0.symbols | 7 +-- src/Makefile.am | 4 ++ src/idoalarmmenuitem.c | 116 +++++++++++++++++++++++++++++++++++++++++++ src/idoalarmmenuitem.h | 32 ++++++++++++ src/idomenuitemfactory.c | 4 ++ 5 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 src/idoalarmmenuitem.c create mode 100644 src/idoalarmmenuitem.h diff --git a/debian/libido3-0.1-0.symbols b/debian/libido3-0.1-0.symbols index 93aad90..332f518 100644 --- a/debian/libido3-0.1-0.symbols +++ b/debian/libido3-0.1-0.symbols @@ -5,13 +5,8 @@ libido3-0.1.so.0 libido3-0.1-0 #MINVER# ido_action_helper_get_type@Base 13.10.0daily13.06.19 ido_action_helper_get_widget@Base 13.10.0daily13.06.19 ido_action_helper_new@Base 13.10.0daily13.06.19 - ido_appointment_menu_item_get_type@Base 13.10.0daily13.06.19 - ido_appointment_menu_item_new@Base 13.10.0daily13.06.19 + ido_alarm_menu_item_new_from_model@Base 0replaceme ido_appointment_menu_item_new_from_model@Base 13.10.0daily13.06.19 - ido_appointment_menu_item_set_color@Base 13.10.0daily13.06.19 - ido_appointment_menu_item_set_format@Base 13.10.0daily13.06.19 - ido_appointment_menu_item_set_summary@Base 13.10.0daily13.06.19 - ido_appointment_menu_item_set_time@Base 13.10.0daily13.06.19 ido_basic_menu_item_get_type@Base 0replaceme ido_basic_menu_item_new@Base 0replaceme ido_basic_menu_item_set_icon@Base 0replaceme diff --git a/src/Makefile.am b/src/Makefile.am index a4ca6fd..725652f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ stamp_files = \ idotypebuiltins.c sources_h = \ + idoalarmmenuitem.h \ idocalendarmenuitem.h \ idoentrymenuitem.h \ idomessagedialog.h \ @@ -20,6 +21,7 @@ sources_h = \ idousermenuitem.h \ idoappointmentmenuitem.h \ idobasicmenuitem.h \ + idotimestampmenuitem.h \ idolocationmenuitem.h \ idotimeline.h \ libido.h \ @@ -69,6 +71,7 @@ libido_0_1_la_SOURCES = \ libido.c \ idotypebuiltins.c \ idocalendarmenuitem.c \ + idoalarmmenuitem.c \ idoentrymenuitem.c \ idomessagedialog.c \ idorange.c \ @@ -82,6 +85,7 @@ libido_0_1_la_SOURCES = \ idoplaybackmenuitem.c \ idoappointmentmenuitem.c \ idobasicmenuitem.c \ + idotimestampmenuitem.c \ idolocationmenuitem.c libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES) diff --git a/src/idoalarmmenuitem.c b/src/idoalarmmenuitem.c new file mode 100644 index 0000000..1c53836 --- /dev/null +++ b/src/idoalarmmenuitem.c @@ -0,0 +1,116 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * Authors: + * Charles Kerr + * Ted Gould + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include + +#include "idoactionhelper.h" +#include "idotimestampmenuitem.h" + +/** + * ido_alarm_menu_item_new_from_model: + * @menu_item: the corresponding menuitem + * @actions: action group to tell when this GtkMenuItem is activated + * + * Creates a new IdoTimeStampMenuItem with properties initialized + * appropriately for a com.canonical.indicator.alarm + * + * If the menuitem's 'action' attribute is set, trigger that action + * in @actions when this IdoAppointmentMenuItem is activated. + */ +GtkMenuItem * +ido_alarm_menu_item_new_from_model (GMenuItem * menu_item, + GActionGroup * actions) +{ + guint i; + guint n; + gint64 i64; + gchar * str; + IdoBasicMenuItem * ido_menu_item; + GParameter parameters[8]; + + /* create the ido_menu_item */ + + n = 0; + + if (g_menu_item_get_attribute (menu_item, G_MENU_ATTRIBUTE_LABEL, "s", &str)) + { + GParameter p = { "text", G_VALUE_INIT }; + g_value_init (&p.value, G_TYPE_STRING); + g_value_take_string (&p.value, str); + parameters[n++] = p; + } + + if (TRUE) + { + GParameter p = { "icon", G_VALUE_INIT }; + g_value_init (&p.value, G_TYPE_OBJECT); + g_value_take_object (&p.value, g_themed_icon_new_with_default_fallbacks ("alarm-symbolic")); + parameters[n++] = p; + } + + if (g_menu_item_get_attribute (menu_item, "x-canonical-time-format", "s", &str)) + { + GParameter p = { "format", G_VALUE_INIT }; + g_value_init (&p.value, G_TYPE_STRING); + g_value_take_string (&p.value, str); + parameters[n++] = p; + } + + if (g_menu_item_get_attribute (menu_item, "x-canonical-time", "x", &i64)) + { + GParameter p = { "date-time", G_VALUE_INIT }; + g_value_init (&p.value, G_TYPE_DATE_TIME); + g_value_take_boxed (&p.value, g_date_time_new_from_unix_local (i64)); + parameters[n++] = p; + } + + g_assert (n <= G_N_ELEMENTS (parameters)); + ido_menu_item = g_object_newv (IDO_TYPE_TIME_STAMP_MENU_ITEM, n, parameters); + + for (i=0; i + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef __IDO_ALARM_MENU_ITEM_H__ +#define __IDO_ALARM_MENU_ITEM_H__ + +#include + +G_BEGIN_DECLS + +GtkMenuItem * ido_alarm_menu_item_new_from_model (GMenuItem * menuitem, + GActionGroup * actions); + +G_END_DECLS + +#endif diff --git a/src/idomenuitemfactory.c b/src/idomenuitemfactory.c index b233095..0b38941 100644 --- a/src/idomenuitemfactory.c +++ b/src/idomenuitemfactory.c @@ -20,6 +20,7 @@ #include #include +#include "idoalarmmenuitem.h" #include "idoappointmentmenuitem.h" #include "idobasicmenuitem.h" #include "idocalendarmenuitem.h" @@ -67,6 +68,9 @@ ido_menu_item_factory_create_menu_item (UbuntuMenuItemFactory *factory, else if (g_str_equal (type, "com.canonical.indicator.appointment")) item = ido_appointment_menu_item_new_from_model (menuitem, actions); + else if (g_str_equal (type, "com.canonical.indicator.alarm")) + item = ido_alarm_menu_item_new_from_model (menuitem, actions); + else if (g_str_equal (type, "com.canonical.indicator.progress")) item = ido_progress_menu_item_new_from_model (menuitem, actions); -- cgit v1.2.3