void panel_action_button_load_from_mateconf (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, const char *id) { int type; const char *key; char *action_type; key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type"); action_type = mateconf_client_get_string (panel_mateconf_get_client (), key, NULL); if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type)) { g_warning ("Unkown action type '%s' from %s", action_type, key); g_free (action_type); return; } g_free (action_type); /* compatibility: migrate from MATE < 2.13.90 */ if (type == PANEL_ACTION_SCREENSHOT) panel_compatibility_migrate_screenshot_action (panel_mateconf_get_client (), id); else panel_action_button_load (type, panel, locked, position, exactpos, id, FALSE); }
void panel_action_button_load_from_mateconf (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, const char *id) { int type; const char *key; char *action_type; key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type"); action_type = mateconf_client_get_string (panel_mateconf_get_client (), key, NULL); if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type)) { g_warning ("Unkown action type '%s' from %s", action_type, key); g_free (action_type); return; } g_free (action_type); panel_action_button_load (type, panel, locked, position, exactpos, id); }
gboolean mate_panel_applet_can_freely_move (AppletInfo *applet) { MateConfClient *client; PanelMateConfKeyType key_type; const char *key; if (panel_lockdown_get_locked_down ()) return FALSE; client = panel_mateconf_get_client (); key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; key = panel_mateconf_full_key (key_type, applet->id, "position"); if (!mateconf_client_key_is_writable (client, key, NULL)) return FALSE; key = panel_mateconf_full_key (key_type, applet->id, "toplevel_id"); if (!mateconf_client_key_is_writable (client, key, NULL)) return FALSE; key = panel_mateconf_full_key (key_type, applet->id, "panel_right_stick"); if (!mateconf_client_key_is_writable (client, key, NULL)) return FALSE; return TRUE; }
static char * panel_util_get_file_display_for_common_files (GFile *file) { GFile *compare; compare = g_file_new_for_path (g_get_home_dir ()); if (g_file_equal (file, compare)) { char *mateconf_name; g_object_unref (compare); mateconf_name = mateconf_client_get_string (panel_mateconf_get_client (), HOME_NAME_KEY, NULL); if (PANEL_GLIB_STR_EMPTY (mateconf_name)) { g_free (mateconf_name); return g_strdup (_("Home Folder")); } else { return mateconf_name; } } g_object_unref (compare); compare = g_file_new_for_path ("/"); if (g_file_equal (file, compare)) { g_object_unref (compare); /* Translators: this is the same string as the one found in * caja */ return g_strdup (_("File System")); } g_object_unref (compare); return NULL; }
static void panel_addto_dialog_free (PanelAddtoDialog *dialog) { MateConfClient *client; GSList *item; client = panel_mateconf_get_client (); if (dialog->name_notify) mateconf_client_notify_remove (client, dialog->name_notify); dialog->name_notify = 0; if (dialog->search_text) g_free (dialog->search_text); dialog->search_text = NULL; if (dialog->applet_search_text) g_free (dialog->applet_search_text); dialog->applet_search_text = NULL; if (dialog->addto_dialog) gtk_widget_destroy (dialog->addto_dialog); dialog->addto_dialog = NULL; for (item = dialog->applet_list; item != NULL; item = item->next) { PanelAddtoItemInfo *applet; applet = (PanelAddtoItemInfo *) item->data; if (!applet->static_data) { panel_addto_dialog_free_item_info (applet); g_free (applet); } } g_slist_free (dialog->applet_list); panel_addto_dialog_free_application_list (dialog->application_list); panel_addto_dialog_free_application_list (dialog->settings_list); if (dialog->filter_applet_model) g_object_unref (dialog->filter_applet_model); dialog->filter_applet_model = NULL; if (dialog->applet_model) g_object_unref (dialog->applet_model); dialog->applet_model = NULL; if (dialog->filter_application_model) g_object_unref (dialog->filter_application_model); dialog->filter_application_model = NULL; if (dialog->application_model) g_object_unref (dialog->application_model); dialog->application_model = NULL; if (dialog->menu_tree) matemenu_tree_unref (dialog->menu_tree); dialog->menu_tree = NULL; g_free (dialog); }
void panel_menu_button_load_from_mateconf (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, const char *id) { MateConfClient *client; const char *key; char *menu_path; char *custom_icon; char *tooltip; gboolean use_menu_path; gboolean use_custom_icon; gboolean has_arrow; client = panel_mateconf_get_client (); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "menu_path"); menu_path = mateconf_client_get_string (client, key, NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "custom_icon"); custom_icon = mateconf_client_get_string (client, key, NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip"); tooltip = mateconf_client_get_string (client, key, NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_menu_path"); use_menu_path = mateconf_client_get_bool (client, key, NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_custom_icon"); use_custom_icon = mateconf_client_get_bool (client, key, NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "has_arrow"); has_arrow = mateconf_client_get_bool (client, key, NULL); panel_menu_button_load (menu_path, use_menu_path, custom_icon, use_custom_icon, tooltip, panel, locked, position, exactpos, has_arrow, id); g_free (menu_path); g_free (custom_icon); g_free (tooltip); }
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; }
static void panel_action_button_connect_to_mateconf (PanelActionButton *button) { const char *key; key = panel_mateconf_full_key ( PANEL_MATECONF_OBJECTS, button->priv->info->id, "action_type"); button->priv->mateconf_notify = mateconf_client_notify_add (panel_mateconf_get_client (), key, (MateConfClientNotifyFunc) panel_action_button_type_changed, button, NULL, NULL); panel_lockdown_notify_add (G_CALLBACK (panel_action_button_update_sensitivity), button); }
static void panel_menu_button_connect_to_mateconf (PanelMenuButton *button) { MateConfClient *client; const char *key; client = panel_mateconf_get_client (); key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/objects/%s", button->priv->applet_id); mateconf_client_add_dir (client, key, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); button->priv->mateconf_notify = mateconf_client_notify_add (client, key, (MateConfClientNotifyFunc) panel_menu_button_mateconf_notify, button, NULL, NULL); }
static void panel_action_button_finalize (GObject *object) { PanelActionButton *button = PANEL_ACTION_BUTTON (object); button->priv->info = NULL; button->priv->type = PANEL_ACTION_NONE; panel_lockdown_notify_remove (G_CALLBACK (panel_action_button_update_sensitivity), button); mateconf_client_notify_remove (panel_mateconf_get_client (), button->priv->mateconf_notify); button->priv->mateconf_notify = 0; G_OBJECT_CLASS (panel_action_button_parent_class)->finalize (object); }
gboolean mate_panel_applet_lockable (AppletInfo *applet) { MateConfClient *client; PanelMateConfKeyType key_type; const char *key; if (panel_lockdown_get_locked_down ()) return FALSE; client = panel_mateconf_get_client (); key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; key = panel_mateconf_full_key (key_type, applet->id, "locked"); return mateconf_client_key_is_writable (client, key, NULL); }
static void panel_menu_button_disconnect_from_mateconf (PanelMenuButton *button) { MateConfClient *client; const char *key; if (!button->priv->mateconf_notify) return; client = panel_mateconf_get_client (); key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/objects/%s", button->priv->applet_id); mateconf_client_notify_remove (client, button->priv->mateconf_notify); button->priv->mateconf_notify = 0; mateconf_client_remove_dir (client, key, NULL); }
void panel_action_button_create (PanelToplevel *toplevel, int position, PanelActionButtonType type) { MateConfClient *client; const char *key; char *id; client = panel_mateconf_get_client (); id = panel_profile_prepare_object (PANEL_OBJECT_ACTION, toplevel, position, FALSE); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type"); mateconf_client_set_string (client, key, mateconf_enum_to_string (panel_action_type_map, type), NULL); panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); g_free (id); }
/* Log Out */ static void panel_action_logout (GtkWidget *widget) { PanelSessionManager *manager; gboolean not_prompt; not_prompt = mateconf_client_get_bool (panel_mateconf_get_client (), LOGOUT_PROMPT_KEY, NULL); /* this avoids handling errors from mateconf since prompting is * safer */ not_prompt = !not_prompt; manager = panel_session_manager_get (); if (not_prompt) panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NO_CONFIRMATION); else /* FIXME: we need to use widget to get the screen for the * confirmation dialog, see * http://bugzilla.gnome.org/show_bug.cgi?id=536914 */ panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL); }
gchar * panel_compatibility_get_applet_iid (const gchar *id) { MateConfClient *client = panel_mateconf_get_client (); MatePanelAppletInfo *info; const char *key; gchar *applet_iid; gboolean needs_migration; const char *iid; /* * There are two compatibility steps here: * * 1) we need to migrate from bonobo_iid to applet_iid if there's no * value in the applet_iid key. Always. * * 2) we need to try to migrate the iid to a new iid. We can't assume * that the fact that the applet_iid key was used mean anything * since the value there could well be a bonobo iid. * The reason we really have to try to migrate first is this case: * if an applet was added with the bonobo iid but gets ported later * to dbus, then the reference to the bonobo iid will only be valid * as an old reference. * And if migration fails, we just use the iid as it is. */ needs_migration = FALSE; key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid"); applet_iid = mateconf_client_get_string (client, key, NULL); if (!applet_iid || !applet_iid[0]) { needs_migration = TRUE; key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "bonobo_iid"); applet_iid = mateconf_client_get_string (client, key, NULL); if (!applet_iid || !applet_iid[0]) return NULL; } info = mate_panel_applets_manager_get_applet_info_from_old_id (applet_iid); if (!info) info = mate_panel_applets_manager_get_applet_info (applet_iid); if (!info) return NULL; iid = mate_panel_applet_info_get_iid (info); /* migrate if the iid in the configuration is different than the real * iid that will get used */ if (!g_str_equal (iid, applet_iid)) needs_migration = TRUE; g_free (applet_iid); if (needs_migration) { key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid"); mateconf_client_set_string (client, key, iid, NULL); } return g_strdup (iid); }
int main (int argc, char **argv) { char *desktopfile; GOptionContext *context; GError *error; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* We will register explicitly when we're ready -- see panel-session.c */ egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED); g_set_prgname ("mate-panel"); desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop"); if (desktopfile) { egg_set_desktop_file (desktopfile); g_free (desktopfile); } context = g_option_context_new (""); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); gtk_init (&argc, &argv); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); /* reset the configuration and exit. */ if (reset == TRUE) { panel_reset(); return 0; } if (!egg_get_desktop_file ()) { g_set_application_name (_("Panel")); gtk_window_set_default_icon_name (PANEL_ICON_PANEL); } if (!panel_shell_register (replace)) { panel_cleanup_do (); return -1; } panel_action_protocol_init (); panel_multiscreen_init (); panel_init_stock_icons_and_items (); mateconf_client_add_dir (panel_mateconf_get_client (), "/desktop/mate/interface", MATECONF_CLIENT_PRELOAD_NONE, NULL); panel_global_config_load (); panel_lockdown_init (); panel_profile_load (); /*add forbidden lists to ALL panels*/ g_slist_foreach (panels, (GFunc)panel_widget_add_forbidden, NULL); xstuff_init (); /* Flush to make sure our struts are seen by everyone starting * immediate after (eg, the caja desktop). */ gdk_flush (); /* Do this at the end, to be sure that we're really ready when * connecting to the session manager */ panel_session_init (); gtk_main (); panel_lockdown_finalize (); mateconf_client_remove_dir (panel_mateconf_get_client (), "/desktop/mate/interface", NULL); panel_cleanup_do (); return 0; }
void mate_panel_applet_save_position (AppletInfo *applet_info, const char *id, gboolean immediate) { PanelMateConfKeyType key_type; MateConfClient *client; PanelWidget *panel_widget; const char *key; const char *toplevel_id; char *old_toplevel_id; gboolean right_stick; gboolean locked; int position; g_return_if_fail (applet_info != NULL); if (!immediate) { if (!queued_position_source) queued_position_source = g_timeout_add_seconds (1, (GSourceFunc) mate_panel_applet_position_save_timeout, NULL); if (!g_slist_find (queued_position_saves, applet_info)) queued_position_saves = g_slist_prepend (queued_position_saves, applet_info); return; } if (!(toplevel_id = mate_panel_applet_get_toplevel_id (applet_info))) return; client = panel_mateconf_get_client (); key_type = applet_info->type == PANEL_OBJECT_APPLET ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; panel_widget = mate_panel_applet_get_panel_widget (applet_info); /* FIXME: Instead of getting keys, comparing and setting, there should be a dirty flag */ key = panel_mateconf_full_key (key_type, id, "toplevel_id"); old_toplevel_id = mateconf_client_get_string (client, key, NULL); if (old_toplevel_id == NULL || strcmp (old_toplevel_id, toplevel_id) != 0) mateconf_client_set_string (client, key, toplevel_id, NULL); g_free (old_toplevel_id); /* Note: changing some properties of the panel that may not be locked down (e.g. background) can change the state of the "panel_right_stick" and "position" properties of an applet that may in fact be locked down. So check if these are writable before attempting to write them */ right_stick = panel_is_applet_right_stick (applet_info->widget) ? 1 : 0; key = panel_mateconf_full_key ( key_type, id, "panel_right_stick"); if (mateconf_client_key_is_writable (client, key, NULL) && (mateconf_client_get_bool (client, key, NULL) ? 1 : 0) != right_stick) mateconf_client_set_bool (client, key, right_stick, NULL); position = mate_panel_applet_get_position (applet_info); if (right_stick && !panel_widget->packed) position = panel_widget->size - position; key = panel_mateconf_full_key (key_type, id, "position"); if (mateconf_client_key_is_writable (client, key, NULL) && mateconf_client_get_int (client, key, NULL) != position) mateconf_client_set_int (client, key, position, NULL); locked = panel_widget_get_applet_locked (panel_widget, applet_info->widget) ? 1 : 0; key = panel_mateconf_full_key (key_type, id, "locked"); if (mateconf_client_get_bool (client, key, NULL) ? 1 : 0 != locked) mateconf_client_set_bool (client, key, locked, NULL); }