static GObject * gtk_combo_box_text_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { GObject *object; const gint text_column = 0; object = G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructor (type, n_construct_properties, construct_properties); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object), text_column); gtk_combo_box_set_id_column (GTK_COMBO_BOX (object), 1); if (!gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object))) { GtkCellRenderer *cell; cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell, "text", text_column, NULL); } return object; }
static GtkWidget* get_provider_combo (TTXWindow *self) { GtkWidget *combo; GtkListStore *model; GtkCellRenderer *render; model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); ttx_provider_mgr_foreach (self->priv->prov_mgr, (TTXProviderForeachFunc)each_prov, model); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(model)); g_object_unref (model); gtk_combo_box_set_id_column (GTK_COMBO_BOX(combo), COL_PROVIDER_ID); render = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), render, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), render, "text", COL_PROVIDER_NAME, NULL ); g_signal_connect (G_OBJECT(combo), "changed", G_CALLBACK(on_combo_changed), self); return combo; }
static void gtk_combo_box_text_constructed (GObject *object) { const gint text_column = 0; G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructed (object); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object), text_column); gtk_combo_box_set_id_column (GTK_COMBO_BOX (object), 1); if (!gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object))) { GtkCellRenderer *cell; cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell, "text", text_column, NULL); } }
static void init_encodings_combo (GtkWidget *widget) { GtkCellRenderer *renderer; GHashTableIter ht_iter; gpointer key, value; gs_unref_object GtkListStore *store; store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); g_hash_table_iter_init (&ht_iter, terminal_app_get_encodings (terminal_app_get ())); while (g_hash_table_iter_next (&ht_iter, &key, &value)) { TerminalEncoding *encoding = value; GtkTreeIter iter; gs_free char *name; name = g_markup_printf_escaped ("%s <span size=\"small\">%s</span>", terminal_encoding_get_charset (encoding), encoding->name); gtk_list_store_insert_with_values (store, &iter, -1, ENCODINGS_COLUMN_MARKUP, name, ENCODINGS_COLUMN_ID, terminal_encoding_get_charset (encoding), -1); } /* Now turn on sorting */ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), ENCODINGS_COLUMN_MARKUP, GTK_SORT_ASCENDING); gtk_combo_box_set_id_column (GTK_COMBO_BOX (widget), ENCODINGS_COLUMN_ID); gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store)); /* Cell renderer */ renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "markup", ENCODINGS_COLUMN_MARKUP, NULL); }
static GtkWidget * nimf_settings_page_key_build_string (NimfSettingsPageKey *page_key, const gchar *schema_id, GList *key_list) { GtkListStore *store; GtkWidget *combo; GtkWidget *hbox; gchar *detailed_signal; GtkTreeIter iter; store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); combo = gtk_combo_box_text_new (); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store)); g_object_unref (store); gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), 1); gtk_tree_model_get_iter_first ((GtkTreeModel *) store, &iter); if (g_strcmp0 (schema_id, "org.nimf.engines") == 0 && g_strcmp0 (page_key->key, "default-engine") == 0) { GSettingsSchemaSource *schema_source; GList *schema_list = NULL; gchar **non_relocatable; gchar *id1; gint i; id1 = g_settings_get_string (page_key->gsettings, page_key->key); schema_source = g_settings_schema_source_get_default (); g_settings_schema_source_list_schemas (schema_source, TRUE, &non_relocatable, NULL); for (i = 0; non_relocatable[i] != NULL; i++) if (g_str_has_prefix (non_relocatable[i], "org.nimf.engines.")) schema_list = g_list_prepend (schema_list, non_relocatable[i]); for (schema_list = g_list_sort (schema_list, (GCompareFunc) on_comparison); schema_list != NULL; schema_list = schema_list->next) { GSettingsSchema *schema; GSettings *gsettings; gchar *name; const gchar *id2; schema = g_settings_schema_source_lookup (schema_source, schema_list->data, TRUE); gsettings = g_settings_new (schema_list->data); name = g_settings_get_string (gsettings, "hidden-schema-name"); id2 = schema_list->data + strlen ("org.nimf.engines."); if (g_settings_schema_has_key (schema, "active") == FALSE || g_settings_get_boolean (gsettings, "active")) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, name, 1, id2, -1); } if (g_settings_schema_has_key (schema, "active")) g_signal_connect (gsettings, "changed::active", G_CALLBACK (on_gsettings_changed_active), combo); g_settings_schema_unref (schema); g_free (name); /*g_object_unref (gsettings);*/ /*** FIXME ***/ } if (gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), id1) == FALSE) { g_settings_set_string (page_key->gsettings, "default-engine", "nimf-system-keyboard"); gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), "nimf-system-keyboard"); } g_strfreev (non_relocatable); g_list_free (schema_list); g_free (id1); } else if (g_str_has_prefix (page_key->key, "hidden-") == FALSE) { gchar *id1; GList *list; id1 = g_settings_get_string (page_key->gsettings, page_key->key); for (list = key_list; list != NULL; list = list->next) { gchar *key2; gchar *prefix; key2 = list->data; prefix = g_strdup_printf ("hidden-%s-", page_key->key); if (g_str_has_prefix (key2, prefix)) { gchar *val; const gchar *id2 = key2 + strlen (prefix); val = g_settings_get_string (page_key->gsettings, key2); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, val, 1, id2, -1); if (g_strcmp0 (id1, id2) == 0) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter); g_free (val); } g_free (prefix); } g_free (id1); } hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15); gtk_box_pack_start (GTK_BOX (hbox), page_key->label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), combo, FALSE, FALSE, 0); detailed_signal = g_strdup_printf ("changed::%s", page_key->key); g_signal_connect (combo, "changed", G_CALLBACK (on_combo_box_changed), page_key); g_signal_connect (page_key->gsettings, detailed_signal, G_CALLBACK (on_gsettings_changed), combo); g_free (detailed_signal); return hbox; }
static void power_manager_plugin_configure (XfcePanelPlugin *plugin, PowerManagerPlugin *power_manager_plugin) { GtkWidget *dialog; GtkWidget *grid, *combo, *label; gint show_panel_label; XfconfChannel *channel; GtkListStore *list_store; GtkTreeIter iter, active_iter; GtkCellRenderer *cell; gint i; gchar *options[] = { _("None"), _("Percentage"), _("Remaining time"), _("Percentage and remaining time") }; channel = xfconf_channel_get (XFPM_CHANNEL); /* block the plugin menu */ xfce_panel_plugin_block_menu (plugin); /* create the dialog */ dialog = xfce_titled_dialog_new_with_buttons (_("Power Manager Plugin Settings"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-help", GTK_RESPONSE_HELP, "gtk-close", GTK_RESPONSE_OK, NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-power-manager-settings"); gtk_widget_show (dialog); /* Set up the main grid for all settings */ grid = gtk_grid_new (); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_grid_set_column_spacing (GTK_GRID (grid), 12); gtk_widget_set_margin_start (grid, 12); gtk_widget_set_margin_end (grid, 12); gtk_widget_set_margin_top (grid, 12); gtk_widget_set_margin_bottom (grid, 12); gtk_container_add_with_properties (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), grid, "expand", TRUE, "fill", TRUE, NULL); /* show-panel-label setting */ label = gtk_label_new (_("Show label:")); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (label), 0, 0, 1, 1); show_panel_label = xfconf_channel_get_int (channel, XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL, -1); list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_STRING); for (i = 0; i < 4; i++) { gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, COLUMN_INT, i, COLUMN_STRING, options[i], -1); if (i == show_panel_label) active_iter = iter; } combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store)); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE ); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, "text", COLUMN_STRING, NULL); gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), COLUMN_STRING); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &active_iter); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (combo), 1, 0, 1, 1); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (power_manager_plugin_combo_changed), channel); g_signal_connect (G_OBJECT (channel), "property-changed::" XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL, G_CALLBACK (power_manager_plugin_panel_label_changed), combo); /* link the dialog to the plugin, so we can destroy it when the plugin * is closed, but the dialog is still open */ g_object_set_data (G_OBJECT (plugin), "dialog", dialog); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK(power_manager_plugin_configure_response), power_manager_plugin); gtk_widget_show_all (grid); }
static void DropboxFPS( GtkComboBox *widget, gpointer data ) { gtk_combo_box_set_id_column (widget,0); const gchar *pTEMP=gtk_combo_box_get_active_id (widget); (( Gst* )data)->gtkVars->fps = atoi( pTEMP ); }