Example #1
0
void
gnc_gconf_general_register_cb (const gchar *key,
                               GncGconfGeneralCb func,
                               gpointer user_data)
{
    GHookList *hook_list;
    GHook *hook;

    g_once(&gcb_init_once, gcb_init, NULL);
    hook_list = g_hash_table_lookup(gcb_callback_hash, key);
    if (hook_list == NULL)
    {
        hook_list = g_malloc(sizeof(GHookList));
        g_hook_list_init(hook_list, sizeof(GHook));
        g_hash_table_insert(gcb_callback_hash, (gpointer)key, hook_list);
    }

    hook = g_hook_find_func_data(hook_list, TRUE, func, user_data);
    if (hook != NULL)
    {
        return;
    }

    hook = g_hook_alloc(hook_list);
    hook->func = func;
    hook->data = user_data;
    g_hook_append(hook_list, hook);
}
Example #2
0
/* Wait for time to pass, then add the child func to the PM */
static gboolean proc_wait_func (gpointer data)
{
    proc_wait_data_t *wdata = (proc_wait_data_t *) data;

    g_assert (data != NULL);

    wdata->start_time += delta_time;
    if (wdata->start_time > wdata->stop_time)
    {
        if (wdata->child_func == NULL)
            g_error ("wait process has no child func");
        if (wdata->child_data == NULL)
            g_error ("wait process has no child data");

        GHook *h = g_hook_alloc (pm);
        g_assert (h != NULL);

        h->data = wdata->child_data;
        h->func = wdata->child_func;
        g_hook_append (pm, h);
        wdata->child_func = NULL;

        return FALSE;
    }
    else
        return TRUE;
}
Example #3
0
/* init this file */
void
decode_dcerpc_init(void) {
    GHook*      hook_init_proto;


    /* add a hook function to the dcerpc init_protocols hook */
    hook_init_proto = g_hook_alloc(&dcerpc_hooks_init_protos);
    hook_init_proto->func = decode_dcerpc_inject_bindings;
    g_hook_prepend(&dcerpc_hooks_init_protos, hook_init_proto);
}
void
_cogl_pango_glyph_cache_add_reorganize_callback (CoglPangoGlyphCache *cache,
                                                 GHookFunc func,
                                                 void *user_data)
{
  GHook *hook = g_hook_alloc (&cache->reorganize_callbacks);
  hook->func = func;
  hook->data = user_data;
  g_hook_prepend (&cache->reorganize_callbacks, hook);
}
void
skype_command_client_add_on_disconnect_hook(SkypeCommandClient *dcc,
					      SkypeCommandClientConnectHook dhcch,
					      gpointer ud) {
  GHook *newhook;
  
  newhook = g_hook_alloc(&(dcc->ondisconnect_hooklist));
  newhook->func = dhcch;
  newhook->data = ud;
  
  g_hook_append(&(dcc->ondisconnect_hooklist), newhook);
}
void
dropbox_command_client_add_on_connect_hook(DropboxCommandClient *dcc,
					   DropboxCommandClientConnectHook dhcch,
					   gpointer ud) {
  GHook *newhook;
  
  newhook = g_hook_alloc(&(dcc->onconnect_hooklist));
  newhook->func = dhcch;
  newhook->data = ud;
  
  g_hook_append(&(dcc->onconnect_hooklist), newhook);
}
void
nautilus_dropbox_hooks_add_on_connect_hook(NautilusDropboxHookserv *hookserv,
					   DropboxHookClientConnectHook dhcch,
					   gpointer ud) {
  GHook *newhook;
  
  newhook = g_hook_alloc(&(hookserv->onconnect_hooklist));
  newhook->func = dhcch;
  newhook->data = ud;
  
  g_hook_append(&(hookserv->onconnect_hooklist), newhook);
}
Example #8
0
void
_cogl_atlas_add_reorganize_callback (CoglAtlas            *atlas,
                                     GHookFunc             pre_callback,
                                     GHookFunc             post_callback,
                                     void                 *user_data)
{
  if (pre_callback)
    {
      GHook *hook = g_hook_alloc (&atlas->post_reorganize_callbacks);
      hook->func = pre_callback;
      hook->data = user_data;
      g_hook_prepend (&atlas->pre_reorganize_callbacks, hook);
    }
  if (post_callback)
    {
      GHook *hook = g_hook_alloc (&atlas->pre_reorganize_callbacks);
      hook->func = post_callback;
      hook->data = user_data;
      g_hook_prepend (&atlas->post_reorganize_callbacks, hook);
    }
}
Example #9
0
File: kiro-sb.c Project: IMCG/kiro
gulong
kiro_sb_add_sync_callback (KiroSb *self, KiroSbSyncCallbackFunc func, void *user_data)
{
    g_return_val_if_fail (self != NULL, 0);

    KiroSbPrivate *priv = KIRO_SB_GET_PRIVATE (self);

    GHook *new_hook = g_hook_alloc (&(priv->callbacks));
    new_hook->data = user_data;
    new_hook->func = (GHookCheckFunc)func;
    g_hook_append (&(priv->callbacks), new_hook);
    return new_hook->hook_id;
}
Example #10
0
void
gnc_hook_add_dangler (const gchar *name, GFunc callback, gpointer cb_arg)
{
    GncHook *gnc_hook;
    GHook *hook;

    ENTER("list %s, function %p, cbarg %p", name, callback, cb_arg);
    gnc_hook = gnc_hook_lookup(name);
    g_return_if_fail(gnc_hook != NULL);
    hook = g_hook_alloc(gnc_hook->c_danglers);
    hook->func = callback;
    hook->data = cb_arg;
    hook->destroy = NULL;
    g_hook_append(gnc_hook->c_danglers, hook);
    LEAVE("");
}
Example #11
0
void
gnc_gconf_general_register_any_cb (GncGconfGeneralAnyCb func,
                                   gpointer user_data)
{
    GHook *hook;

    g_once(&gcb_init_once, gcb_init, NULL);
    hook = g_hook_find_func_data(gcb_final_hook_list, TRUE, func, user_data);
    if (hook != NULL)
        return;

    hook = g_hook_alloc(gcb_final_hook_list);
    hook->func = func;
    hook->data = user_data;
    g_hook_append(gcb_final_hook_list, hook);
}
guint 
g_source_add (gint           priority,
	      gboolean       can_recurse,
	      GSourceFuncs  *funcs,
	      gpointer       source_data, 
	      gpointer       user_data,
	      GDestroyNotify notify)
{
  guint return_val;
  GSource *source;

  G_LOCK (main_loop);

  if (!source_list.is_setup)
    {
      g_hook_list_init (&source_list, sizeof (GSource));

      source_list.hook_destroy = G_HOOK_DEFERRED_DESTROY;
      source_list.hook_free = g_source_destroy_func;
    }

  source = (GSource*) g_hook_alloc (&source_list);
  source->priority = priority;
  source->source_data = source_data;
  source->hook.func = funcs;
  source->hook.data = user_data;
  source->hook.destroy = notify;
  
  g_hook_insert_sorted (&source_list, 
			(GHook *)source, 
			g_source_compare);

  if (can_recurse)
    source->hook.flags |= G_SOURCE_CAN_RECURSE;

  return_val = source->hook.hook_id;

#ifdef G_THREADS_ENABLED
  /* Now wake up the main loop if it is waiting in the poll() */
  g_main_wakeup ();
#endif

  G_UNLOCK (main_loop);

  return return_val;
}
/* prefs_add_notifier:
 *	registers pref change notifier
 */
void prefs_add_notifier(const gchar * pref_name, GHookFunc func)
{
	GHook * hook;
	struct prefs_value * value;
	const gchar * value_key;
	gboolean found_pref;

	found_pref = g_hash_table_lookup_extended(
			prefs_hash, pref_name, (gpointer*)&value_key, (gpointer*)&value);
	g_assert(found_pref);

	/* setup new hook for this preference */
	hook = g_hook_alloc(&value->change_hook);
	hook->func = func;
	hook->data = (gpointer)value_key;

	g_hook_prepend(&value->change_hook, hook);
}
Example #14
0
void
gth_hook_add_callback (const char *name,
		       int         sort_order,
		       GCallback   callback,
		       gpointer    data)
{
	GthHook *hook;
	GHook   *function;

	hook = GET_HOOK (name);

	function = g_hook_alloc (hook->list);
	function->func = callback;
	function->data = data;
	function->destroy = NULL;
	GTH_HOOK_CALLBACK (function)->sort_order = sort_order;

	g_hook_insert_sorted (hook->list, function, hook_compare_func);
}
Example #15
0
void
qof_session_add_close_hook (GFunc fn, gpointer data)
{
    GHook *hook;

    if (session_closed_hooks == NULL)
    {
        session_closed_hooks = static_cast<GHookList*>(malloc(sizeof(GHookList))); /* LEAKED */
        g_hook_list_init (session_closed_hooks, sizeof(GHook));
    }

    hook = g_hook_alloc(session_closed_hooks);
    if (!hook)
        return;

    hook->func = reinterpret_cast<void*>(fn);
    hook->data = data;
    g_hook_append(session_closed_hooks, hook);
}
Example #16
0
void
qof_session_add_close_hook (GFunc fn, gpointer data)
{
    GHook *hook;

    if (session_closed_hooks == NULL)
    {
        session_closed_hooks = malloc(sizeof(GHookList)); /* LEAKED */
        g_hook_list_init (session_closed_hooks, sizeof(GHook));
    }

    hook = g_hook_alloc(session_closed_hooks);
    if (!hook)
        return;

    hook->func = (GHookFunc)fn;
    hook->data = data;
    g_hook_append(session_closed_hooks, hook);
}
Example #17
0
int lualock_lua_hook_connect(lua_State *L) {
    lua_settop(L, 2);
    const char *hook_str = luaL_checkstring(L, 1);
    GHookList *list = g_hash_table_lookup(lualock.hooks, hook_str);
    luaL_argcheck(L, list, 1, "not a valid hook");
    
    luaL_checktype(L, 2, LUA_TFUNCTION);
    
    GHook *hook = g_hook_alloc(list);
    hook_data_t *data = g_malloc(sizeof(hook_data_t));
    data->L = L;
    data->r = luaL_ref(L, LUA_REGISTRYINDEX);
    hook->data = data;
    hook->func = hook_call_lua_function;
    
    g_hook_append(list, hook);
    
    return 0;
}
Example #18
0
void
gnc_hook_add_scm_dangler (const gchar *name, SCM proc)
{
    GncHook *gnc_hook;
    GHook *hook;
    GncScmDangler *scm;

    ENTER("list %s, proc ???", name);
    gnc_hook = gnc_hook_lookup(name);
    g_return_if_fail(gnc_hook != NULL);
    scm = g_new0(GncScmDangler, 1);
    scm_gc_protect_object(proc);
    scm->proc = proc;
    hook = g_hook_alloc(gnc_hook->scm_danglers);
    hook->func = call_scm_hook;
    hook->data = scm;
    hook->destroy = delete_scm_hook;
    g_hook_append(gnc_hook->scm_danglers, hook);
    LEAVE("");
}
Example #19
0
/**
 * Add an InitFunc to the hooklist with the name 'name'
 */
void
NamedInitFuncAdd(const char *name, InitFuncPriority priority, InitFunc func, const char *func_name)
{
    if (!namedInitFuncs)
    {
        namedInitFuncs = g_hash_table_new(g_str_hash, g_str_equal);
        if (!namedInitFuncs)
        {
            g_error("%s: Out of memory on initialization.\n", __FUNCTION__);
            abort();
        }
    }

    if (g_hash_table_lookup(namedInitFuncs, (gconstpointer)name) == NULL)
    {
        GNamedHookList *namedHookList = malloc(sizeof (GNamedHookList));
        if (!namedHookList)
        {
            g_error("%s: Out of memory on initialization.\n", __FUNCTION__);
            abort();
        }
        g_hook_list_init((GHookList*)namedHookList, sizeof(GPrioritizedHook));

        namedHookList->name = name;
       
        g_hash_table_insert(namedInitFuncs, (char*)name, namedHookList);
    }

    GHookList *hookList = (GHookList*)g_hash_table_lookup(namedInitFuncs, (gconstpointer)name);

    GPrioritizedHook *hook = (GPrioritizedHook*)g_hook_alloc(hookList);

    hook->base.data = func;
    hook->base.func = HookInit;
    hook->priority  = priority;
    hook->func_name = func_name;

    g_hook_insert_sorted(hookList, (GHook*)hook, GPrioritizedHookCompare);
}
static void
deskmenu_construct_item (DeskmenuObject *dm_object)
{
	DeskmenuItem *item = dm_object->current_item;
	GtkWidget *menu_item, *submenu;
	gchar *name, *icon, *command, *vpicon;
	gboolean images;
	gint w, h;
	//constructs the items in menu
	switch (item->type)
	{
		case DESKMENU_ITEM_LAUNCHER:
			if (item->name_exec)
			{
				GtkWidget *label;
				GHook *hook;

				name = g_strstrip (item->name->str);

				menu_item = gtk_image_menu_item_new ();
				label = gtk_label_new_with_mnemonic (NULL);
				gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

				g_object_set_data (G_OBJECT (label), "exec", g_strdup (name));
				gtk_container_add (GTK_CONTAINER (menu_item), label);
				hook = g_hook_alloc (dm_object->show_hooks);

				hook->data = (gpointer) label;
				hook->func = (GHookFunc *) launcher_name_exec_update;
				g_hook_append (dm_object->show_hooks, hook);
			}
			else
			{
				if (item->name)
					name = g_strstrip (item->name->str);
				else
					name = "";

				menu_item = gtk_image_menu_item_new_with_mnemonic (name);

			}
			if (item->icon)
			{
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                   )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
						gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU));
					}
			}
			if (item->command_pipe)
			{
				command = g_strstrip (item->command->str);
				if (item->cache_output)
				{
					g_object_set_data(G_OBJECT(menu_item), "cached", g_strdup("yes"));
				}
				else
				{
					g_object_set_data(G_OBJECT(menu_item), "cached", g_strdup("no"));
				}
				g_object_set_data(G_OBJECT(menu_item), "menu", dm_object);
				g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (pipe_menu_recreate), g_strdup(command));
				submenu = gtk_menu_new();
				gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			}
			else
			{
				if (item->command)
				{
					command = g_strstrip (item->command->str);
					g_signal_connect (G_OBJECT (menu_item), "activate",
						G_CALLBACK (launcher_activated), g_strdup (command));
				}
			}
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
				menu_item);
			break;
#if HAVE_WNCK
		case DESKMENU_ITEM_WINDOWLIST:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("_Windows");
			images = FALSE;
			gboolean this_vp = FALSE;
			gboolean mini_only = FALSE;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->thisvp
				&& strcmp (g_strstrip (item->thisvp->str), "true") == 0)
				this_vp = TRUE;
			if (item->mini_only
				&& strcmp (g_strstrip (item->mini_only->str), "true") == 0)
				mini_only = TRUE;
			g_object_set_data(G_OBJECT(menu_item), "windowlist", deskmenu_windowlist_initialize (images, this_vp, mini_only));
			g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (refresh_windowlist_item), NULL);
			submenu = gtk_menu_new();
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), menu_item);
			break;


		case DESKMENU_ITEM_DESKTOPLIST:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("_Desktops");
			gboolean file;
			images = FALSE;
			file = FALSE;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->vpicon)
			{
				vpicon = g_strstrip (parse_expand_tilde(item->vpicon->str));
				if (item->vpicon_file)
				{
					file = TRUE;
				}
			}
			else
			{
				vpicon = "";
			}
			g_object_set_data(G_OBJECT(menu_item), "dplist", deskmenu_dplist_initialize (images, file, vpicon));
			g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (refresh_desktoplist_item), NULL);
			submenu = gtk_menu_new();
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), menu_item);
			break;

		case DESKMENU_ITEM_VIEWPORTLIST:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("_Viewports");
			gboolean wrap;
			wrap = FALSE;
			images = FALSE;
			file = FALSE;
			if (item->wrap && strcmp (g_strstrip (item->wrap->str), "true") == 0)
				wrap = TRUE;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->vpicon)
			{
				vpicon = g_strstrip (parse_expand_tilde(item->vpicon->str));
				if (item->vpicon_file)
				{
					file = TRUE;
				}
			}
			else
			{
				vpicon = "";
			}
			g_object_set_data(G_OBJECT(menu_item), "vplist", deskmenu_vplist_initialize (wrap, images, file, vpicon));
			g_signal_connect (G_OBJECT (menu_item), "activate",
					G_CALLBACK (refresh_viewportlist_item), NULL);
			submenu = gtk_menu_new();
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), menu_item);
			break;
#endif
		case DESKMENU_ITEM_RELOAD:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("Reload");

			if (item->icon)
			{
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			g_signal_connect (G_OBJECT (menu_item), "activate",
				G_CALLBACK (quit), NULL);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
				menu_item);
			break;

		case DESKMENU_ITEM_DOCUMENTS:
			menu_item = gtk_image_menu_item_new_with_mnemonic ("Recent Doc_uments");
			gint limit, age;
			gchar *sort_type;
			images = FALSE;
			sort_type = "least used";
			age = 25;
			if (item->icon)
			{
				images = TRUE;
				icon = g_strstrip (item->icon->str);
				if (item->icon_file)
				{
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
					                               gtk_image_new_from_pixbuf (
					                                   gdk_pixbuf_new_from_file_at_size (
					                                       parse_expand_tilde(icon), w, h, NULL
					                                       )
					                                  )
					                              );
				}
				else {
					gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
					                               gtk_image_new_from_icon_name (icon, 
					                                                             GTK_ICON_SIZE_MENU)
					                               );
				}
			}
			if (item->age)
			{
				age = atoi(g_strstrip (item->age->str));
			}
			if (item->sort_type)
			{
				sort_type = g_strstrip (item->sort_type->str);
			}
			if (item->quantity)
			{
				limit = atoi(g_strstrip (item->quantity->str));
			}
			else
			{
				limit = -1;
			}
			if (item->command)
			{
				command = g_strstrip (item->command->str);
			}
			else
			{
				command = g_strdup ("xdg-open");
			}
			GtkWidget *docs = make_recent_documents_list(images, command, limit, age, sort_type);
			gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item),
				docs);
			gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
				menu_item);
			break;

		default:
			break;
	}

}
static void
start_element (GMarkupParseContext *context,
               const gchar         *element_name,
               const gchar        **attr_names,
               const gchar        **attr_values,
               gpointer             user_data,
               GError             **error)
{
	DeskmenuObject *dm_object = user_data;

	DeskmenuElementType element_type;
	const gchar **ncursor = attr_names, **vcursor = attr_values;
	GtkWidget *item, *menu;
	gint w, h;

	element_type = GPOINTER_TO_INT (g_hash_table_lookup
		(element_hash, element_name));

	if ((dm_object->menu && !dm_object->current_menu)
	   || (!dm_object->menu && element_type != DESKMENU_ELEMENT_MENU))
	{
		gint line_num, char_num;
		g_markup_parse_context_get_position (context, &line_num, &char_num);
		g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
			"Error on line %d char %d: Element '%s' declared outside of "
			"toplevel menu element", line_num, char_num, element_name);
		return;
	}

	switch (element_type)
	{
		case DESKMENU_ELEMENT_MENU:

			if (dm_object->current_item != NULL)
			{
				gint line_num, char_num;
				g_markup_parse_context_get_position (context, &line_num,
					&char_num);
				g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
					"Error on line %d char %d: Element 'menu' cannot be nested "
					"inside of an item element", line_num, char_num);
				return;
			}
			if (!dm_object->menu)
			{
				/*if (strcmp (*ncursor, "size") == 0) {
					deskmenu->w = g_strdup (*vcursor);
					deskmenu->h = g_strdup (*vcursor);
					}
				else {
					gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, deskmenu->w, deskmenu->h);
				}*/
				dm_object->menu = gtk_menu_new ();
				g_object_set_data (G_OBJECT (dm_object->menu), "parent menu",
					NULL);
				dm_object->current_menu = dm_object->menu;
			}
			else
			{
				gchar *name = NULL;
				gchar *icon = NULL;
				gboolean name_exec = FALSE;
				gboolean icon_file = FALSE;
				while (*ncursor)
				{
					if (strcmp (*ncursor, "name") == 0)
						name = g_strdup (*vcursor);
					else if (strcmp (*ncursor, "icon") == 0)
						icon = g_strdup (*vcursor);
					else if ((strcmp (*ncursor, "mode") == 0)
						&& (strcmp (*vcursor, "exec") == 0))
						name_exec = TRUE;
					else if ((strcmp (*ncursor, "mode1") == 0)
						&& (strcmp (*vcursor, "file") == 0))
						icon_file = TRUE;
					else
						g_set_error (error, G_MARKUP_ERROR,
							G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
							"Unknown attribute: %s", *ncursor);
					ncursor++;
					vcursor++;
				}
				if (name_exec)
				{
					GtkWidget *label;
					GHook *hook;

					item = gtk_image_menu_item_new ();
					label = gtk_label_new_with_mnemonic (NULL);
					gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

					g_object_set_data (G_OBJECT (label), "exec", g_strdup (name));
					gtk_container_add (GTK_CONTAINER (item), label);
					hook = g_hook_alloc (dm_object->show_hooks);

					hook->data = (gpointer) label;
					hook->func = (GHookFunc *) launcher_name_exec_update;
					g_hook_append (dm_object->show_hooks, hook);
				}
				else
				{
					if (name)
						item = gtk_image_menu_item_new_with_mnemonic (name);
					else
						item = gtk_image_menu_item_new_with_mnemonic ("");
				}
				if (icon)
				{
					if (icon_file)
					{
						gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
						gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item), 
													   gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_file_at_size (parse_expand_tilde(icon), w, h, NULL)));
					}
					else {
						gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
													   gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU));
					}
				}
				gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), item);
				menu = gtk_menu_new ();
				g_object_set_data (G_OBJECT (menu), "parent menu",
					dm_object->current_menu);
				dm_object->current_menu = menu;
				gtk_menu_item_set_submenu (GTK_MENU_ITEM (item),
					dm_object->current_menu);

				if (!dm_object->make_from_pipe)
				{
					GtkWidget *pin = gtk_tearoff_menu_item_new();
					gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
						pin); //add a pin menu item
					dm_object->pin_items = g_slist_prepend (dm_object->pin_items, pin);
				}
				else
				{
					if (gtk_menu_get_tearoff_state (GTK_MENU(dm_object->menu)))
					{
						GtkWidget *pin = gtk_tearoff_menu_item_new();
						gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu),
							pin); //add a pin menu item
					}
				}

				g_free (name);
				g_free (icon);
			}
			break;

		case DESKMENU_ELEMENT_SEPARATOR:
		if (dm_object->current_item != NULL)
		{
				gint line_num, char_num;
				g_markup_parse_context_get_position (context, &line_num,
					&char_num);
				g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
					"Error on line %d char %d: Element 'menu' cannot be nested "
					"inside of an item element", line_num, char_num);
				return;
		}
		else {
				gchar *name = NULL;
				gchar *icon = NULL;
				gboolean name_exec = FALSE;
				gboolean icon_file = FALSE;
				gboolean decorate = FALSE;
				gint w, h;
				item = gtk_separator_menu_item_new();
				while (*ncursor)
				{
					if (strcmp (*ncursor, "name") == 0)
					{
						name = g_strdup (*vcursor);
						if (!decorate)
						{
							decorate = TRUE;
						}
					}
					else if (strcmp (*ncursor, "icon") == 0)
					{
						icon = g_strdup (*vcursor);
						if (!decorate)
						{
							decorate = TRUE;
						}
					}
					else if ((strcmp (*ncursor, "mode") == 0)
					         && (strcmp (*vcursor, "exec") == 0))
						name_exec = TRUE;
					else if ((strcmp (*ncursor, "mode1") == 0)
					         && (strcmp (*vcursor, "file") == 0))
						icon_file = TRUE;
					else
						g_set_error (error, G_MARKUP_ERROR,
							G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
							"Unknown attribute: %s", *ncursor);
					ncursor++;
					vcursor++;
				}
				if (decorate)
				{
					GtkWidget *box = gtk_hbox_new (FALSE, 3);
					gtk_container_add (GTK_CONTAINER(item), GTK_WIDGET(box));
					if (name_exec)
					{
						GtkWidget *label;
						GHook *hook;

						label = gtk_label_new_with_mnemonic (NULL);

						g_object_set_data (G_OBJECT (label), "exec", g_strdup (name));
						gtk_box_pack_end (GTK_BOX(box), label, TRUE, FALSE, 0);
						hook = g_hook_alloc (dm_object->show_hooks);

						hook->data = (gpointer) label;
						hook->func = (GHookFunc *) launcher_name_exec_update;
						g_hook_append (dm_object->show_hooks, hook);
					}
					else
					{
						gtk_box_pack_end (GTK_BOX(box), gtk_label_new_with_mnemonic (name), TRUE, FALSE, 0);
					}
					if (icon)
					{
						GtkWidget *image;
						if (icon_file)
						{
							gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
							image = gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_file_at_size (parse_expand_tilde(icon), w, h, NULL));
						}
						else {
							image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
						}
						gtk_box_pack_start (GTK_BOX(box), image, FALSE, FALSE, 0);
					}
					gtk_widget_set_state (item, GTK_STATE_PRELIGHT); /*derive colors from menu hover*/
					g_free (name);
					g_free (icon);
				}
				gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), item);
			}
			break;

		case DESKMENU_ELEMENT_ITEM:

			if (dm_object->current_item != NULL)
			{
				gint line_num, char_num;
				g_markup_parse_context_get_position (context, &line_num,
					&char_num);
				g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
					"Error on line %d char %d: Element 'item' cannot be nested "
					"inside of another item element", line_num, char_num);
				return;
			}

			dm_object->current_item = g_slice_new0 (DeskmenuItem);
				while (*ncursor)
				{
					if (strcmp (*ncursor, "type") == 0)
						dm_object->current_item->type = GPOINTER_TO_INT
						(g_hash_table_lookup (item_hash, *vcursor));
					else
						g_set_error (error, G_MARKUP_ERROR,
							G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
							"Unknown attribute: %s", *ncursor);
					ncursor++;
					vcursor++;
				}
			break;

		case DESKMENU_ELEMENT_NAME:
			 while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode") == 0)
						&& (strcmp (*vcursor, "exec") == 0))
						dm_object->current_item->name_exec = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_ICON:
				while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode1") == 0)
						&& (strcmp (*vcursor, "file") == 0))
						dm_object->current_item->icon_file = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_VPICON:
				while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode1") == 0)
						&& (strcmp (*vcursor, "file") == 0))
						dm_object->current_item->vpicon_file = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_COMMAND:
				while (*ncursor)
				{
					if ((strcmp (*ncursor, "mode2") == 0)
						&& (strcmp (*vcursor, "pipe") == 0))
						dm_object->current_item->command_pipe = TRUE;
					if (dm_object->current_item->command_pipe == TRUE
						&& (strcmp (*ncursor, "cache") == 0)
						&& (strcmp (*vcursor, "true") == 0))
						dm_object->current_item->cache_output = TRUE;
					ncursor++;
					vcursor++;
				} /* no break here to let it fall through */
		case DESKMENU_ELEMENT_WRAP:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_THISVP:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_MINIONLY:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_QUANTITY:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_SORT:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;
		case DESKMENU_ELEMENT_AGE:
			if (dm_object->current_item)
				dm_object->current_item->current_element = element_type;
			break;

		default:
			g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
				"Unknown element: %s", element_name);
			break;
	}
}