From 76d15095ffae6e4fed8ac57f5186ba6107a655b3 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 6 Nov 2015 13:49:07 +0100 Subject: Fork ayatana-ido from Ubuntu's ido shared library. --- src/Makefile.am | 55 ++++++++++++++++++----------------- src/ayatana-private.h | 32 ++++++++++++++++++++ src/ayatanamenuitemfactory.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ src/ayatanamenuitemfactory.h | 61 +++++++++++++++++++++++++++++++++++++++ src/idoalarmmenuitem.c | 2 +- src/idoappointmentmenuitem.c | 2 +- src/idomenuitemfactory.c | 36 +++++++++++------------ src/libayatana-ido.c | 36 +++++++++++++++++++++++ src/libayatana-ido.h | 36 +++++++++++++++++++++++ src/libido.c | 36 ----------------------- src/libido.h | 36 ----------------------- 11 files changed, 283 insertions(+), 118 deletions(-) create mode 100644 src/ayatana-private.h create mode 100644 src/ayatanamenuitemfactory.c create mode 100644 src/ayatanamenuitemfactory.h create mode 100644 src/libayatana-ido.c create mode 100644 src/libayatana-ido.h delete mode 100644 src/libido.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index e18fb70..6b22590 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ CLEANFILES = VER=3 -lib_LTLIBRARIES = libido3-0.1.la +lib_LTLIBRARIES = libayatana-ido3-0.4.la ido_built_public_sources = \ idotypebuiltins.h @@ -11,6 +11,8 @@ stamp_files = \ idotypebuiltins.c sources_h = \ + ayatanamenuitemfactory.h \ + ayatana-private.h \ idoalarmmenuitem.h \ idocalendarmenuitem.h \ idoentrymenuitem.h \ @@ -25,7 +27,7 @@ sources_h = \ idotimestampmenuitem.h \ idolocationmenuitem.h \ idotimeline.h \ - libido.h \ + libayatana-ido.h \ idoactionhelper.h \ idomediaplayermenuitem.h \ idoplaybackmenuitem.h \ @@ -71,8 +73,9 @@ AM_CPPFLAGS = \ AM_CFLAGS = \ $(COVERAGE_CFLAGS) -libido_0_1_la_SOURCES = \ - libido.c \ +libayatana_ido_0_4_la_SOURCES = \ + ayatanamenuitemfactory.c \ + libayatana-ido.c \ idotypebuiltins.c \ idocalendarmenuitem.c \ idoalarmmenuitem.c \ @@ -96,11 +99,11 @@ libido_0_1_la_SOURCES = \ idodetaillabel.c \ idosourcemenuitem.c -libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES) +libayatana_ido3_0_4_la_SOURCES = $(libayatana_ido_0_4_la_SOURCES) -libidoincludedir=$(includedir)/libido$(VER)-0.1/libido +libayatana_idoincludedir=$(includedir)/libayatana-ido$(VER)-0.4/libayatana-ido -libidoinclude_HEADERS = \ +libayatana_idoinclude_HEADERS = \ idocalendarmenuitem.h \ idoentrymenuitem.h \ idomessagedialog.h \ @@ -108,17 +111,17 @@ libidoinclude_HEADERS = \ idoscalemenuitem.h \ idoswitchmenuitem.h \ idotimeline.h \ - libido.h + libayatana-ido.h -libido_0_1_la_LIBADD = $(GTK_LIBS) $(LIBM) -libido_0_1_la_LDFLAGS = \ +libayatana_ido_0_4_la_LIBADD = $(GTK_LIBS) $(LIBM) +libayatana_ido_0_4_la_LDFLAGS = \ $(GTK_LT_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ -no-undefined \ -export-symbols-regex "^[^_].*" -libido3_0_1_la_LIBADD = $(libido_0_1_la_LIBADD) -libido3_0_1_la_LDFLAGS = \ - $(libido_0_1_la_LDFLAGS) +libayatana_ido3_0_4_la_LIBADD = $(libayatana_ido_0_4_la_LIBADD) +libayatana_ido3_0_4_la_LDFLAGS = \ + $(libayatana_ido_0_4_la_LDFLAGS) DISTCLEANFILES = \ stamp-idotypebuiltins.h \ @@ -134,11 +137,11 @@ INTROSPECTION_SCANNER_ARGS = \ if HAVE_INTROSPECTION -Ido3-0.1.gir: libido3-0.1.la -Ido3_0_1_gir_INCLUDES = Gtk-3.0 -Ido3_0_1_gir_CFLAGS = -Ido3_0_1_gir_LIBS = libido3-0.1.la -Ido3_0_1_gir_FILES = \ +AyatanaIdo3-0.4.gir: libayatana-ido3-0.4.la +AyatanaIdo3_0_4_gir_INCLUDES = Gtk-3.0 +AyatanaIdo3_0_4_gir_CFLAGS = +AyatanaIdo3_0_4_gir_LIBS = libayatana-ido3-0.4.la +AyatanaIdo3_0_4_gir_FILES = \ idocalendarmenuitem.h \ idoentrymenuitem.h \ idomessagedialog.h \ @@ -146,12 +149,12 @@ Ido3_0_1_gir_FILES = \ idoscalemenuitem.h \ idoswitchmenuitem.h \ idotimeline.h \ - $(libido_0_1_la_SOURCES) -Ido3_0_1_gir_NAMESPACE = Ido3 -Ido3_0_1_gir_VERSION = 0.1 -Ido3_0_1_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) + $(libayatana_ido_0_4_la_SOURCES) +AyatanaIdo3_0_4_gir_NAMESPACE = AyatanaIdo3 +AyatanaIdo3_0_4_gir_VERSION = 0.4 +AyatanaIdo3_0_4_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) -INTROSPECTION_GIRS += Ido3-0.1.gir +INTROSPECTION_GIRS += AyatanaIdo3-0.4.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -166,10 +169,10 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = Ido3-0.1.vapi +vapi_DATA = AyatanaIdo3-0.4.vapi -Ido3-0.1.vapi: Ido3-0.1.gir - $(VALA_API_GEN) --library=Ido3-0.1 \ +AyatanaIdo3-0.4.vapi: AyatanaIdo3-0.4.gir + $(VALA_API_GEN) --library=AyatanaIdo3-0.4 \ --pkg gtk+-3.0 \ $< diff --git a/src/ayatana-private.h b/src/ayatana-private.h new file mode 100644 index 0000000..3cb7e65 --- /dev/null +++ b/src/ayatana-private.h @@ -0,0 +1,32 @@ +/* +* Copyright 2013 Canonical Ltd. +* +* 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 . +* +* Authors: +* Lars Uebernickel +*/ + +/* + * Warning: this file is not part of gtk+, but an Ubuntu-specific extension. + * The API provided here is meant to be used only from Unity. + * + * Applications should not use this. + */ + +#ifndef __AYATANA_PRIVATE_H__ +#define __AYATANA_PRIVATE_H__ + +#include "ayatanamenuitemfactory.h" + +#endif diff --git a/src/ayatanamenuitemfactory.c b/src/ayatanamenuitemfactory.c new file mode 100644 index 0000000..0e333ab --- /dev/null +++ b/src/ayatanamenuitemfactory.c @@ -0,0 +1,69 @@ +/* +* Copyright 2013 Canonical Ltd. +* +* 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 . +* +* Authors: +* Lars Uebernickel +*/ + +#include "ayatanamenuitemfactory.h" + +G_DEFINE_INTERFACE_WITH_CODE (AyatanaMenuItemFactory, ayatana_menu_item_factory, G_TYPE_OBJECT, + GIOExtensionPoint *ep = g_io_extension_point_register (AYATANA_MENU_ITEM_FACTORY_EXTENSION_POINT_NAME); + g_io_extension_point_set_required_type (ep, g_define_type_id);) + +/* + * ayatana_menu_item_factory_get_all: + * + * Returns a static list of all registered factories. + */ +GList * +ayatana_menu_item_factory_get_all (void) +{ + static GList *factories = NULL; + + if (factories == NULL) + { + GIOExtensionPoint *ep; + GList *it; + + g_type_ensure (AYATANA_TYPE_MENU_ITEM_FACTORY); + ep = g_io_extension_point_lookup (AYATANA_MENU_ITEM_FACTORY_EXTENSION_POINT_NAME); + for (it = g_io_extension_point_get_extensions (ep); it != NULL; it = it->next) + { + GIOExtension *ext = it->data; + AyatanaMenuItemFactory *factory; + + factory = g_object_new (g_io_extension_get_type (ext), NULL); + factories = g_list_prepend (factories, factory); + } + factories = g_list_reverse (factories); + } + + return factories; +} + +static void +ayatana_menu_item_factory_default_init (AyatanaMenuItemFactoryInterface *iface) +{ +} + +GtkMenuItem * +ayatana_menu_item_factory_create_menu_item (AyatanaMenuItemFactory *factory, + const gchar *type, + GMenuItem *menuitem, + GActionGroup *actions) +{ + return AYATANA_MENU_ITEM_FACTORY_GET_IFACE (factory)->create_menu_item (factory, type, menuitem, actions); +} diff --git a/src/ayatanamenuitemfactory.h b/src/ayatanamenuitemfactory.h new file mode 100644 index 0000000..4013cce --- /dev/null +++ b/src/ayatanamenuitemfactory.h @@ -0,0 +1,61 @@ +/* +* Copyright 2013 Canonical Ltd. +* +* 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 . +* +* Authors: +* Lars Uebernickel +*/ + +#ifndef __AYATANA_MENU_ITEM_FACTORY_H__ +#define __AYATANA_MENU_ITEM_FACTORY_H__ + +#include + +G_BEGIN_DECLS + +#define AYATANA_TYPE_MENU_ITEM_FACTORY (ayatana_menu_item_factory_get_type ()) +#define AYATANA_MENU_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), AYATANA_TYPE_MENU_ITEM_FACTORY, AyatanaMenuItemFactory)) +#define AYATANA_IS_MENU_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), AYATANA_TYPE_MENU_ITEM_FACTORY)) +#define AYATANA_MENU_ITEM_FACTORY_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), AYATANA_TYPE_MENU_ITEM_FACTORY, AyatanaMenuItemFactoryInterface)) + +#define AYATANA_MENU_ITEM_FACTORY_EXTENSION_POINT_NAME "ubuntu-menu-item-factory" + +typedef struct _AyatanaMenuItemFactoryInterface AyatanaMenuItemFactoryInterface; +typedef struct _AyatanaMenuItemFactory AyatanaMenuItemFactory; + +struct _AyatanaMenuItemFactoryInterface +{ + GTypeInterface iface; + + GtkMenuItem * (*create_menu_item) (AyatanaMenuItemFactory *factory, + const gchar *type, + GMenuItem *menuitem, + GActionGroup *actions); +}; + +GDK_AVAILABLE_IN_3_10 +GList * ayatana_menu_item_factory_get_all (void); + +GDK_AVAILABLE_IN_3_10 +GType ayatana_menu_item_factory_get_type (void); + +GDK_AVAILABLE_IN_3_10 +GtkMenuItem * ayatana_menu_item_factory_create_menu_item (AyatanaMenuItemFactory *factory, + const gchar *type, + GMenuItem *menuitem, + GActionGroup *actions); + +G_END_DECLS + +#endif diff --git a/src/idoalarmmenuitem.c b/src/idoalarmmenuitem.c index 1c53836..817d6a8 100644 --- a/src/idoalarmmenuitem.c +++ b/src/idoalarmmenuitem.c @@ -33,7 +33,7 @@ * @actions: action group to tell when this GtkMenuItem is activated * * Creates a new IdoTimeStampMenuItem with properties initialized - * appropriately for a com.canonical.indicator.alarm + * appropriately for a org.ayatana.indicator.alarm * * If the menuitem's 'action' attribute is set, trigger that action * in @actions when this IdoAppointmentMenuItem is activated. diff --git a/src/idoappointmentmenuitem.c b/src/idoappointmentmenuitem.c index cfc0bf8..0d6a3d2 100644 --- a/src/idoappointmentmenuitem.c +++ b/src/idoappointmentmenuitem.c @@ -75,7 +75,7 @@ create_color_icon_pixbuf (const char * color_spec) * @actions: action group to tell when this GtkMenuItem is activated * * Creates a new IdoTimeStampMenuItem with properties initialized - * appropriately for a com.canonical.indicator.alarm + * appropriately for a org.ayatana.indicator.alarm * * If the menuitem's 'action' attribute is set, trigger that action * in @actions when this IdoAppointmentMenuItem is activated. diff --git a/src/idomenuitemfactory.c b/src/idomenuitemfactory.c index cb10cce..8d2334b 100644 --- a/src/idomenuitemfactory.c +++ b/src/idomenuitemfactory.c @@ -18,7 +18,7 @@ */ #include -#include +#include "ayatana-private.h" #include "idoalarmmenuitem.h" #include "idoappointmentmenuitem.h" @@ -42,15 +42,15 @@ typedef GObject IdoMenuItemFactory; typedef GObjectClass IdoMenuItemFactoryClass; GType ido_menu_item_factory_get_type (void); -static void ido_menu_item_factory_interface_init (UbuntuMenuItemFactoryInterface *iface); +static void ido_menu_item_factory_interface_init (AyatanaMenuItemFactoryInterface *iface); G_DEFINE_TYPE_WITH_CODE (IdoMenuItemFactory, ido_menu_item_factory, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (UBUNTU_TYPE_MENU_ITEM_FACTORY, ido_menu_item_factory_interface_init) - g_io_extension_point_implement (UBUNTU_MENU_ITEM_FACTORY_EXTENSION_POINT_NAME, + G_IMPLEMENT_INTERFACE (AYATANA_TYPE_MENU_ITEM_FACTORY, ido_menu_item_factory_interface_init) + g_io_extension_point_implement (AYATANA_MENU_ITEM_FACTORY_EXTENSION_POINT_NAME, g_define_type_id, "ido", 0);) static GtkMenuItem * -ido_menu_item_factory_create_menu_item (UbuntuMenuItemFactory *factory, +ido_menu_item_factory_create_menu_item (AyatanaMenuItemFactory *factory, const gchar *type, GMenuItem *menuitem, GActionGroup *actions) @@ -63,40 +63,40 @@ ido_menu_item_factory_create_menu_item (UbuntuMenuItemFactory *factory, if (g_str_equal (type, "indicator.guest-menu-item")) item = ido_guest_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.calendar")) + else if (g_str_equal (type, "org.ayatana.indicator.calendar")) item = ido_calendar_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.location")) + else if (g_str_equal (type, "org.ayatana.indicator.location")) item = ido_location_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.appointment")) + else if (g_str_equal (type, "org.ayatana.indicator.appointment")) item = ido_appointment_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.alarm")) + else if (g_str_equal (type, "org.ayatana.indicator.alarm")) item = ido_alarm_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.basic")) + else if (g_str_equal (type, "org.ayatana.indicator.basic")) item = ido_basic_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.progress")) + else if (g_str_equal (type, "org.ayatana.indicator.progress")) item = ido_progress_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.unity.slider")) + else if (g_str_equal (type, "org.ayatana.unity.slider")) item = ido_scale_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.unity.media-player")) + else if (g_str_equal (type, "org.ayatana.unity.media-player")) item = ido_media_player_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.unity.playback-item")) + else if (g_str_equal (type, "org.ayatana.unity.playback-item")) item = ido_playback_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.application")) + else if (g_str_equal (type, "org.ayatana.application")) item = ido_application_menu_item_new_from_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.messages.source")) + else if (g_str_equal (type, "org.ayatana.indicator.messages.source")) item = ido_source_menu_item_new_from_menu_model (menuitem, actions); - else if (g_str_equal (type, "com.canonical.indicator.switch")) + else if (g_str_equal (type, "org.ayatana.indicator.switch")) item = ido_switch_menu_item_new_from_menu_model (menuitem, actions); return item; @@ -108,7 +108,7 @@ ido_menu_item_factory_class_init (IdoMenuItemFactoryClass *class) } static void -ido_menu_item_factory_interface_init (UbuntuMenuItemFactoryInterface *iface) +ido_menu_item_factory_interface_init (AyatanaMenuItemFactoryInterface *iface) { iface->create_menu_item = ido_menu_item_factory_create_menu_item; } diff --git a/src/libayatana-ido.c b/src/libayatana-ido.c new file mode 100644 index 0000000..0c90213 --- /dev/null +++ b/src/libayatana-ido.c @@ -0,0 +1,36 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * 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 . + * + * Authors: + * Lars Uebernickel + */ + +#include + +/** + * ido_init: + * + * Initializes ido. It has to be called after gtk_init(), but before any + * other calls into ido are made. + */ +void +ido_init (void) +{ + GType ido_menu_item_factory_get_type (void); + + /* make sure this extension point is registered so that gtk calls it + * when finding custom menu items */ + g_type_ensure (ido_menu_item_factory_get_type ()); +} diff --git a/src/libayatana-ido.h b/src/libayatana-ido.h new file mode 100644 index 0000000..43a8168 --- /dev/null +++ b/src/libayatana-ido.h @@ -0,0 +1,36 @@ +/* + * 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 + * + * + * Authors: + * Cody Russell + */ + +#ifndef __IDO__ +#define __IDO__ + +#include +#include +#include +#include + +void ido_init (void); + +#endif /* __IDO__ */ diff --git a/src/libido.c b/src/libido.c deleted file mode 100644 index 0c90213..0000000 --- a/src/libido.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * 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 . - * - * Authors: - * Lars Uebernickel - */ - -#include - -/** - * ido_init: - * - * Initializes ido. It has to be called after gtk_init(), but before any - * other calls into ido are made. - */ -void -ido_init (void) -{ - GType ido_menu_item_factory_get_type (void); - - /* make sure this extension point is registered so that gtk calls it - * when finding custom menu items */ - g_type_ensure (ido_menu_item_factory_get_type ()); -} diff --git a/src/libido.h b/src/libido.h index 43a8168..e69de29 100644 --- a/src/libido.h +++ b/src/libido.h @@ -1,36 +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 - * - * - * Authors: - * Cody Russell - */ - -#ifndef __IDO__ -#define __IDO__ - -#include -#include -#include -#include - -void ido_init (void); - -#endif /* __IDO__ */ -- cgit v1.2.3