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);
}
Exemple #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;
}
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
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
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);
}
Exemple #6
0
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;
}
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("");
}
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);
}
Exemple #9
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);
}
Exemple #10
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);
}
Exemple #11
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;
}
Exemple #12
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("");
}
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;
	}
}
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;
	}

}
Exemple #15
0
void
pm_queue_proc (GHook *proc)
{
    g_hook_append (pm, proc);
}