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; }
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; }
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); }
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; 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); panel_menu_button_load (menu_path, use_menu_path, custom_icon, use_custom_icon, tooltip, panel, locked, position, exactpos, id); g_free (menu_path); g_free (custom_icon); g_free (tooltip); }
void panel_compatiblity_migrate_settings_menu_button (MateConfClient *client, const char *id) { const char *key; panel_profile_remove_from_list (PANEL_MATECONF_OBJECTS, id); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "launcher_location"); mateconf_client_set_string (client, key, "mate-control-center.desktop", NULL); key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "object_type"); mateconf_client_set_string (client, key, "launcher-object", NULL); panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); }
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); }
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); }
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); }
AppletInfo * mate_panel_applet_register (GtkWidget *applet, gpointer data, GDestroyNotify data_destroy, PanelWidget *panel, gboolean locked, gint pos, gboolean exactpos, PanelObjectType type, const char *id) { AppletInfo *info; const char *key; g_return_val_if_fail (applet != NULL && panel != NULL, NULL); if (gtk_widget_get_has_window (applet)) gtk_widget_set_events (applet, (gtk_widget_get_events (applet) | APPLET_EVENT_MASK) & ~( GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK)); info = g_new0 (AppletInfo, 1); info->type = type; info->widget = applet; info->menu = NULL; info->data = data; info->data_destroy = data_destroy; info->user_menu = NULL; info->move_item = NULL; info->id = g_strdup (id); g_object_set_data (G_OBJECT (applet), "applet_info", info); if (type != PANEL_OBJECT_APPLET) panel_lockdown_notify_add (G_CALLBACK (mate_panel_applet_recreate_menu), info); key = panel_mateconf_full_key ((type == PANEL_OBJECT_APPLET) ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS, id, "locked"); panel_mateconf_notify_add_while_alive (key, (MateConfClientNotifyFunc) mate_panel_applet_locked_change_notify, G_OBJECT (applet)); if (type == PANEL_OBJECT_DRAWER) { Drawer *drawer = data; PanelWidget *assoc_panel; assoc_panel = panel_toplevel_get_panel_widget (drawer->toplevel); g_object_set_data (G_OBJECT (applet), MATE_PANEL_APPLET_ASSOC_PANEL_KEY, assoc_panel); assoc_panel->master_widget = applet; g_object_add_weak_pointer ( G_OBJECT (applet), (gpointer *) &assoc_panel->master_widget); } g_object_set_data (G_OBJECT (applet), MATE_PANEL_APPLET_FORBIDDEN_PANELS, NULL); registered_applets = g_slist_append (registered_applets, info); if (panel_widget_add (panel, applet, locked, pos, exactpos) == -1 && panel_widget_add (panel, applet, locked, 0, TRUE) == -1) { GSList *l; for (l = panels; l; l = l->next) { panel = PANEL_WIDGET (l->data); if (panel_widget_add (panel, applet, locked, 0, TRUE) != -1) break; } if (!l) { g_warning (_("Cannot find an empty spot")); panel_profile_delete_object (info); return NULL; } } if (BUTTON_IS_WIDGET (applet) || gtk_widget_get_has_window (applet)) { g_signal_connect (applet, "button_press_event", G_CALLBACK (applet_button_press), info); g_signal_connect (applet, "popup_menu", G_CALLBACK (applet_popup_menu), info); } g_signal_connect (applet, "destroy", G_CALLBACK (mate_panel_applet_destroy), info); mate_panel_applet_set_dnd_enabled (info, !locked); gtk_widget_show_all (applet); orientation_change (info, panel); size_change (info, panel); back_change (info, panel); if (type != PANEL_OBJECT_APPLET) gtk_widget_grab_focus (applet); else gtk_widget_child_focus (applet, GTK_DIR_TAB_FORWARD); return info; }
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); }
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); }