static void setup_options (void) { MateComponent_ServerInfoList *applets; CORBA_Environment env; int i; char *prefs_dir; char *unique_key; ComboItem *applet_items; int applet_nb; CORBA_exception_init (&env); applets = matecomponent_activation_query ( "has (repo_ids, 'IDL:MATE/Vertigo/MatePanelAppletShell:1.0')", NULL, &env); if (MATECOMPONENT_EX (&env)) g_error (_("query returned exception %s\n"), MATECOMPONENT_EX_REPOID (&env)); CORBA_exception_free (&env); applet_nb = applets->_length; applet_items = g_new0 (ComboItem, applet_nb); for (i = 0; i < applet_nb; i++) { MateComponent_ServerInfo *info; info = &applets->_buffer [i]; applet_items[i].name = info->iid; applet_items[i].value = info->iid; } setup_combo (applet_combo, applet_items, NULL, applet_nb, TRUE); g_free (applet_items); CORBA_free (applets); setup_combo (size_combo, size_items, "Size", G_N_ELEMENTS (size_items), FALSE); setup_combo (orient_combo, orient_items, "Orientation", G_N_ELEMENTS (orient_items), FALSE); unique_key = mateconf_unique_key (); prefs_dir = g_strdup_printf ("/tmp/%s", unique_key); g_free (unique_key); gtk_entry_set_text (GTK_ENTRY (prefs_dir_entry), prefs_dir); g_free (prefs_dir); }
static void setup_options (void) { MatePanelAppletsManager *manager; GList *applet_list, *l; int i; int j; char *prefs_path = NULL; char *unique_key = NULL; gboolean unique_key_found = FALSE; gchar **dconf_paths; GtkListStore *model; GtkTreeIter iter; GtkCellRenderer *renderer; model = gtk_list_store_new (NUMBER_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); gtk_combo_box_set_model (GTK_COMBO_BOX (applet_combo), GTK_TREE_MODEL (model)); manager = g_object_new (PANEL_TYPE_APPLETS_MANAGER_DBUS, NULL); applet_list = MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applets (manager); for (l = applet_list, i = 1; l; l = g_list_next (l), i++) { MatePanelAppletInfo *info = (MatePanelAppletInfo *)l->data; gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, COLUMN_TEXT, g_strdup (mate_panel_applet_info_get_name (info)), COLUMN_ITEM, g_strdup (mate_panel_applet_info_get_iid (info)), -1); } g_list_free (applet_list); g_object_unref (manager); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (applet_combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (applet_combo), renderer, "text", COLUMN_TEXT, NULL); gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo), 0); setup_combo (size_combo, size_items, "Size", G_N_ELEMENTS (size_items)); setup_combo (orient_combo, orient_items, "Orientation", G_N_ELEMENTS (orient_items)); for (i = 0; !unique_key_found; i++) { g_free (unique_key); unique_key = g_strdup_printf ("mate-panel-test-applet-%d", i); unique_key_found = TRUE; dconf_paths = mate_dconf_list_subdirs ("/tmp/", TRUE); for (j = 0; dconf_paths[j] != NULL; j++) { if (g_strcmp0(unique_key, dconf_paths[j]) == 0) { unique_key_found = FALSE; break; } } if (dconf_paths) g_strfreev (dconf_paths); } prefs_path = g_strdup_printf ("/tmp/%s/", unique_key); if (unique_key) g_free (unique_key); gtk_entry_set_text (GTK_ENTRY (prefs_path_entry), prefs_path); g_free (prefs_path); }
/** * vinagre_connect: * @window: A Window * * Return value: (allow-none) (transfer full): */ VinagreConnection * vinagre_connect (VinagreWindow *window) { VinagreConnection *conn = NULL; gint result; VinagreConnectDialog dialog; dialog.xml = vinagre_utils_get_builder (); if (!dialog.xml) return NULL; dialog.dialog = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "connect_dialog")); gtk_window_set_transient_for (GTK_WINDOW (dialog.dialog), GTK_WINDOW (window)); dialog.protocol_combo = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "protocol_combo")); dialog.protocol_description_label = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "protocol_description_label")); dialog.host_entry = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "host_entry")); dialog.find_button = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "find_button")); dialog.fullscreen_check = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "fullscreen_check")); dialog.plugin_box = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "plugin_options_connect_vbox")); dialog.connect_button = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "connect_button")); setup_protocol (&dialog); setup_combo (&dialog); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog.fullscreen_check), vinagre_cache_prefs_get_boolean ("connection", "fullscreen", FALSE)); #ifdef VINAGRE_HAVE_AVAHI g_signal_connect (dialog.find_button, "clicked", G_CALLBACK (vinagre_connect_find_button_cb), &dialog); #else gtk_widget_hide (dialog.find_button); gtk_widget_set_no_show_all (dialog.find_button, TRUE); #endif gtk_widget_show_all (dialog.dialog); result = gtk_dialog_run (GTK_DIALOG (dialog.dialog)); if (result == GTK_RESPONSE_HELP) { vinagre_utils_show_help (GTK_WINDOW (window), "connect"); } else if (result == GTK_RESPONSE_OK) { gchar *host = NULL, *error_msg = NULL, *protocol = NULL, *actual_host; gint port; GtkWidget *options; GtkTreeIter iter; VinagreProtocol *ext; host = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (dialog.host_entry)); gtk_widget_hide (GTK_WIDGET (dialog.dialog)); if (!host || !g_strcmp0 (host, "")) goto fail; save_history (dialog.host_entry); if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog.protocol_combo), &iter)) { g_warning (_("Could not get the active protocol from the protocol list.")); goto fail; } gtk_tree_model_get (GTK_TREE_MODEL (dialog.protocol_store), &iter, PROTOCOL_NAME, &protocol, PROTOCOL_OPTIONS, &options, PROTOCOL_PLUGIN, &ext, -1); vinagre_cache_prefs_set_string ("connection", "last-protocol", protocol); g_free (protocol); vinagre_cache_prefs_set_boolean ("connection", "fullscreen", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog.fullscreen_check))); conn = vinagre_protocol_new_connection (ext); if (vinagre_connection_split_string (host, vinagre_connection_get_protocol (conn), &protocol, &actual_host, &port, &error_msg)) { g_object_set (conn, "host", actual_host, "port", port, "fullscreen", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog.fullscreen_check)), NULL); if (options) vinagre_connection_parse_options_widget (conn, options); g_free (protocol); g_free (actual_host); } else { vinagre_utils_show_error_dialog (NULL, error_msg ? error_msg : _("Unknown error"), GTK_WINDOW (window)); } g_object_unref (ext); if (options) g_object_unref (options); fail: g_free (host); g_free (error_msg); } gtk_widget_destroy (dialog.dialog); g_object_unref (dialog.xml); return conn; }