gboolean panel_menu_button_create (PanelToplevel *toplevel, int position, const char *filename, const char *menu_path, gboolean use_menu_path, const char *tooltip) { MateConfClient *client; const char *scheme; const char *key; char *id; client = panel_mateconf_get_client (); id = panel_profile_prepare_object (PANEL_OBJECT_MENU, toplevel, position, FALSE); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_menu_path"); mateconf_client_set_bool (client, key, use_menu_path, NULL); scheme = panel_menu_filename_to_scheme (filename); if (filename && !scheme) { g_warning ("Failed to find menu scheme for %s\n", filename); g_free (id); return FALSE; } if (use_menu_path && menu_path && menu_path [0] && scheme) { char *menu_uri; menu_uri = g_strconcat (scheme, ":", menu_path, NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "menu_path"); mateconf_client_set_string (client, key, menu_uri, NULL); g_free (menu_uri); } if (tooltip && tooltip [0]) { key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip"); mateconf_client_set_string (client, key, tooltip, NULL); } panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); g_free (id); return TRUE; }
gboolean panel_menu_button_create (PanelToplevel *toplevel, int position, const char *filename, const char *menu_path, gboolean use_menu_path, const char *tooltip) { GSettings *settings; gchar *path; const char *scheme; char *id; id = panel_profile_prepare_object (PANEL_OBJECT_MENU, toplevel, position, FALSE); path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); g_settings_set_boolean (settings, PANEL_OBJECT_USE_MENU_PATH_KEY, use_menu_path); scheme = panel_menu_filename_to_scheme (filename); if (filename && !scheme) { g_warning ("Failed to find menu scheme for %s\n", filename); g_free (id); g_free (path); g_object_unref (settings); return FALSE; } if (use_menu_path && menu_path && menu_path [0] && scheme) { char *menu_uri; menu_uri = g_strconcat (scheme, ":", menu_path, NULL); g_settings_set_string (settings, PANEL_OBJECT_MENU_PATH_KEY, menu_uri); g_free (menu_uri); } if (tooltip && tooltip [0]) { g_settings_set_string (settings, PANEL_OBJECT_TOOLTIP_KEY, tooltip); } panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (id); g_free (path); g_object_unref (settings); return TRUE; }