aboutsummaryrefslogtreecommitdiff
path: root/src/metadata-menu-item.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/metadata-menu-item.c')
-rw-r--r--src/metadata-menu-item.c186
1 files changed, 186 insertions, 0 deletions
diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c
new file mode 100644
index 0000000..f111baa
--- /dev/null
+++ b/src/metadata-menu-item.c
@@ -0,0 +1,186 @@
+/* metadata-menu-item.c generated by valac, the Vala compiler
+ * generated from metadata-menu-item.vala, do not modify */
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-glib/menuitem-proxy.h>
+#include <libdbusmenu-glib/menuitem.h>
+#include <libdbusmenu-glib/server.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gee.h>
+
+
+#define TYPE_METADATA_MENUITEM (metadata_menuitem_get_type ())
+#define METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitem))
+#define METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
+#define IS_METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_METADATA_MENUITEM))
+#define IS_METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_METADATA_MENUITEM))
+#define METADATA_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
+
+typedef struct _MetadataMenuitem MetadataMenuitem;
+typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
+typedef struct _MetadataMenuitemPrivate MetadataMenuitemPrivate;
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+struct _MetadataMenuitem {
+ DbusmenuMenuitem parent_instance;
+ MetadataMenuitemPrivate * priv;
+};
+
+struct _MetadataMenuitemClass {
+ DbusmenuMenuitemClass parent_class;
+};
+
+
+static gpointer metadata_menuitem_parent_class = NULL;
+
+GType metadata_menuitem_get_type (void);
+enum {
+ METADATA_MENUITEM_DUMMY_PROPERTY
+};
+#define METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item"
+#define METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist"
+#define METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TEXT_PIECE "x-canonical-metadata-text-piece"
+#define METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER "x-canonical-metadata-text-container"
+#define METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image"
+MetadataMenuitem* metadata_menuitem_new (void);
+MetadataMenuitem* metadata_menuitem_construct (GType object_type);
+char* metadata_menuitem_sanitize_image_path (const char* path);
+void metadata_menuitem_update (MetadataMenuitem* self, GeeHashMap* data);
+static void metadata_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
+
+
+
+MetadataMenuitem* metadata_menuitem_construct (GType object_type) {
+ MetadataMenuitem * self;
+ self = g_object_newv (object_type, 0, NULL);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_TYPE, METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TYPE);
+ return self;
+}
+
+
+MetadataMenuitem* metadata_menuitem_new (void) {
+ return metadata_menuitem_construct (TYPE_METADATA_MENUITEM);
+}
+
+
+static char* string_strip (const char* self) {
+ char* result = NULL;
+ char* _result_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _result_ = g_strdup (self);
+ g_strstrip (_result_);
+ result = _result_;
+ return result;
+}
+
+
+void metadata_menuitem_update (MetadataMenuitem* self, GeeHashMap* data) {
+ char* _tmp1_;
+ char* _tmp0_;
+ char* _tmp3_;
+ char* _tmp2_;
+ char* _tmp5_;
+ char* _tmp4_;
+ char* _tmp7_;
+ char* _tmp6_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (data != NULL);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, _tmp1_ = string_strip (_tmp0_ = (char*) gee_abstract_map_get ((GeeAbstractMap*) data, "artist")));
+ _g_free0 (_tmp1_);
+ _g_free0 (_tmp0_);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, _tmp3_ = string_strip (_tmp2_ = (char*) gee_abstract_map_get ((GeeAbstractMap*) data, "title")));
+ _g_free0 (_tmp3_);
+ _g_free0 (_tmp2_);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, _tmp5_ = string_strip (_tmp4_ = (char*) gee_abstract_map_get ((GeeAbstractMap*) data, "album")));
+ _g_free0 (_tmp5_);
+ _g_free0 (_tmp4_);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, METADATA_MENUITEM_DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, _tmp7_ = metadata_menuitem_sanitize_image_path (_tmp6_ = (char*) gee_abstract_map_get ((GeeAbstractMap*) data, "arturl")));
+ _g_free0 (_tmp7_);
+ _g_free0 (_tmp6_);
+}
+
+
+static char* string_slice (const char* self, glong start, glong end) {
+ char* result = NULL;
+ glong string_length;
+ gboolean _tmp0_ = FALSE;
+ gboolean _tmp1_ = FALSE;
+ const char* start_string;
+ g_return_val_if_fail (self != NULL, NULL);
+ string_length = g_utf8_strlen (self, -1);
+ if (start < 0) {
+ start = string_length + start;
+ }
+ if (end < 0) {
+ end = string_length + end;
+ }
+ if (start >= 0) {
+ _tmp0_ = start <= string_length;
+ } else {
+ _tmp0_ = FALSE;
+ }
+ g_return_val_if_fail (_tmp0_, NULL);
+ if (end >= 0) {
+ _tmp1_ = end <= string_length;
+ } else {
+ _tmp1_ = FALSE;
+ }
+ g_return_val_if_fail (_tmp1_, NULL);
+ g_return_val_if_fail (start <= end, NULL);
+ start_string = g_utf8_offset_to_pointer (self, start);
+ result = g_strndup (start_string, ((gchar*) g_utf8_offset_to_pointer (start_string, end - start)) - ((gchar*) start_string));
+ return result;
+}
+
+
+char* metadata_menuitem_sanitize_image_path (const char* path) {
+ char* result = NULL;
+ char* _result_;
+ g_return_val_if_fail (path != NULL, NULL);
+ _result_ = string_strip (path);
+ if (g_str_has_prefix (_result_, "file:///")) {
+ char* _tmp0_;
+ _result_ = (_tmp0_ = string_slice (_result_, (glong) 7, g_utf8_strlen (_result_, -1)), _g_free0 (_result_), _tmp0_);
+ }
+ g_debug ("metadata-menu-item.vala:32: Sanitize image path - result = %s", _result_);
+ result = _result_;
+ return result;
+}
+
+
+static void metadata_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp) {
+ MetadataMenuitem * self;
+ self = (MetadataMenuitem*) base;
+ g_return_if_fail (name != NULL);
+ g_debug ("metadata-menu-item.vala:38: MetadataItem -> handle event caught!");
+}
+
+
+static void metadata_menuitem_class_init (MetadataMenuitemClass * klass) {
+ metadata_menuitem_parent_class = g_type_class_peek_parent (klass);
+ DBUSMENU_MENUITEM_CLASS (klass)->handle_event = metadata_menuitem_real_handle_event;
+}
+
+
+static void metadata_menuitem_instance_init (MetadataMenuitem * self) {
+}
+
+
+GType metadata_menuitem_get_type (void) {
+ static volatile gsize metadata_menuitem_type_id__volatile = 0;
+ if (g_once_init_enter (&metadata_menuitem_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (MetadataMenuitemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) metadata_menuitem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MetadataMenuitem), 0, (GInstanceInitFunc) metadata_menuitem_instance_init, NULL };
+ GType metadata_menuitem_type_id;
+ metadata_menuitem_type_id = g_type_register_static (DBUSMENU_TYPE_MENUITEM, "MetadataMenuitem", &g_define_type_info, 0);
+ g_once_init_leave (&metadata_menuitem_type_id__volatile, metadata_menuitem_type_id);
+ }
+ return metadata_menuitem_type_id__volatile;
+}
+
+
+
+