Ejemplo n.º 1
0
static void
action_combo_box_constructed (GObject *object)
{
	GtkComboBox *combo_box;
	GtkCellRenderer *renderer;

	combo_box = GTK_COMBO_BOX (object);

	/* This needs to happen after constructor properties are set
	 * so that GtkCellLayout.get_area() returns something valid. */

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_cell_layout_pack_start (
		GTK_CELL_LAYOUT (combo_box), renderer, FALSE);
	gtk_cell_layout_set_cell_data_func (
		GTK_CELL_LAYOUT (combo_box), renderer,
		(GtkCellLayoutDataFunc) action_combo_box_render_pixbuf,
		combo_box, NULL);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (
		GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
	gtk_cell_layout_set_cell_data_func (
		GTK_CELL_LAYOUT (combo_box), renderer,
		(GtkCellLayoutDataFunc) action_combo_box_render_text,
		combo_box, NULL);

	gtk_combo_box_set_row_separator_func (
		combo_box, (GtkTreeViewRowSeparatorFunc)
		action_combo_box_is_row_separator, NULL, NULL);
}
Ejemplo n.º 2
0
static GtkWidget *
get_contacts_widget (NstPlugin *plugin)
{
	GtkWidget *cb;
	GtkCellRenderer *renderer;
	GtkTreeStore *store;
	GtkTreeModel *model;
	GtkTreeIter *iter, *iter2;

	iter = g_malloc (sizeof(GtkTreeIter));
	iter2 = g_malloc (sizeof(GtkTreeIter));
	store = gtk_tree_store_new (NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING);
	add_pidgin_contacts_to_model (store, iter, iter2);
	model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), COL_ALIAS,
					      GTK_SORT_ASCENDING);
	cb = gtk_combo_box_new_with_model (model);

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb),
				    renderer,
				    FALSE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cb),
					renderer,
					"pixbuf", COL_ICON,
					NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cb), renderer,
					    customize,
					    (gboolean *)FALSE, NULL);
	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb),
				    renderer,
				    TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cb),
					renderer,
					"text", COL_ALIAS,
					NULL);
	g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cb), renderer,
					    customize,
					    (gboolean *)TRUE, NULL);

	gtk_combo_box_set_active (GTK_COMBO_BOX (cb), 0);
	gtk_combo_box_get_active_iter (GTK_COMBO_BOX(cb), iter);
	if (gtk_tree_model_iter_has_child (model, iter)) {
		GtkTreePath *path = gtk_tree_path_new_from_indices (0, 0, -1);
		gtk_tree_model_get_iter (model, iter2, path);
		gtk_tree_path_free (path);
		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cb), iter2);
	}

	g_free (iter);
	g_free (iter2);
	return cb;
}
Ejemplo n.º 3
0
static VALUE
rg_set_cell_data_func(VALUE self, VALUE cell)
{
    if (rb_block_given_p()) {
        VALUE func = rb_block_proc();
        G_RELATIVE(self, func);
        gtk_cell_layout_set_cell_data_func(_SELF(self), RVAL2RENDERER(cell),
                                           (GtkCellLayoutDataFunc)layout_data_func, 
                                           (gpointer)func, NULL);
    } else {
        gtk_cell_layout_set_cell_data_func(_SELF(self), RVAL2RENDERER(cell),
                                           NULL, (gpointer)NULL, NULL);
    }
    return self;
}
Ejemplo n.º 4
0
static void
cg_combo_flags_sync_cells (CgComboFlags *combo,
                           GtkCellLayout *cell_layout)
{
	CgComboFlagsPrivate *priv;
	CgComboFlagsCellInfo *info;
	GSList *j;
	GSList *k;

	priv = CG_COMBO_FLAGS_PRIVATE (combo);
	for (k = priv->cells; k != NULL; k = k->next)
	{
		info = (CgComboFlagsCellInfo *) k->data;

		if (info->pack == GTK_PACK_START)
			gtk_cell_layout_pack_start (cell_layout, info->cell, info->expand);
		else if (info->pack == GTK_PACK_END)
			gtk_cell_layout_pack_end (cell_layout, info->cell, info->expand);

		gtk_cell_layout_set_cell_data_func (cell_layout, info->cell,
		                                    cg_combo_flags_cell_data_func,
		                                    info, NULL);

		for (j = info->attributes; j != NULL; j = j->next->next)
		{
			gtk_cell_layout_add_attribute (cell_layout, info->cell, j->data,
			                               GPOINTER_TO_INT (j->next->data));
		}
	}
}
Ejemplo n.º 5
0
static void fm_places_view_init(FmPlacesView *self)
{
    GtkTreeViewColumn* col;
    GtkCellRenderer* renderer;
    GtkTargetList* targets;
    GdkPixbuf* pix;
    guint handler;

    if(G_UNLIKELY(!model))
    {
        model = fm_places_model_new();
        g_object_add_weak_pointer(G_OBJECT(model), &model);
    }
    else
        g_object_ref(model);

    gtk_tree_view_set_model(GTK_TREE_VIEW(self), model);
    g_object_unref(model);

    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(self), FALSE);
    gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(self), (GtkTreeViewRowSeparatorFunc)sep_func, NULL, NULL );

    col = gtk_tree_view_column_new();
    renderer = fm_cell_renderer_pixbuf_new();
    handler = g_signal_connect(fm_config, "changed::pane_icon_size", G_CALLBACK(on_renderer_icon_size_changed), renderer);
    g_object_weak_ref(G_OBJECT(renderer), (GDestroyNotify)on_cell_renderer_pixbuf_destroy, GUINT_TO_POINTER(handler));
    fm_cell_renderer_pixbuf_set_fixed_size(FM_CELL_RENDERER_PIXBUF(renderer), fm_config->pane_icon_size, fm_config->pane_icon_size);

    gtk_tree_view_column_pack_start( col, renderer, FALSE );
    gtk_tree_view_column_set_attributes( col, renderer,
                                         "pixbuf", FM_PLACES_MODEL_COL_ICON, NULL );

    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start( col, renderer, TRUE );
    g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
    gtk_tree_view_column_set_attributes( col, renderer,
                                         "text", FM_PLACES_MODEL_COL_LABEL, NULL );

    renderer = gtk_cell_renderer_pixbuf_new();
    self->mount_indicator_renderer = renderer;
    gtk_tree_view_column_pack_start( col, renderer, FALSE );
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(col), renderer,
                                       fm_places_model_mount_indicator_cell_data_func,
                                       NULL, NULL);

    gtk_tree_view_append_column ( GTK_TREE_VIEW(self), col );

    gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(self), GDK_BUTTON1_MASK,
                      dnd_src_targets, G_N_ELEMENTS(dnd_src_targets), GDK_ACTION_MOVE);

    gtk_drag_dest_set(self, 0,
            fm_default_dnd_dest_targets, N_FM_DND_DEST_DEFAULT_TARGETS,
            GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
    targets = gtk_drag_dest_get_target_list((GtkWidget*)self);
    /* add our own targets */
    gtk_target_list_add_table(targets, dnd_dest_targets, G_N_ELEMENTS(dnd_dest_targets));

    self->dnd_dest = fm_dnd_dest_new((GtkWidget*)self);
    g_signal_connect(self->dnd_dest, "files_dropped", G_CALLBACK(on_dnd_dest_files_dropped), self);
}
Ejemplo n.º 6
0
static void
fm_path_entry_init(FmPathEntry *entry)
{
    FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry);
    GtkEntryCompletion* completion = gtk_entry_completion_new();
    GtkCellRenderer* render;

    priv->model = NULL;
    priv->completion_model = NULL;
    priv->completion_len = 0;
    priv->in_change = FALSE;
    priv->completion = completion;
    priv->highlight_completion_match = TRUE;
    priv->common_suffix_append_idle_id = -1;
    priv->common_suffix[0] = 0;
    gtk_entry_completion_set_minimum_key_length(completion, 1);
    gtk_entry_completion_set_match_func(completion, fm_path_entry_match_func, NULL, NULL);
    g_signal_connect(G_OBJECT(completion), "match-selected", G_CALLBACK(fm_path_entry_match_selected), (gpointer)NULL);
    g_object_set(completion, "text-column", COL_FILE_NAME, NULL);
    render = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE );
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion), render, fm_path_entry_completion_render_func, entry, NULL);
    gtk_entry_completion_set_inline_completion(completion, TRUE);
    gtk_entry_completion_set_popup_set_width(completion, TRUE);
    g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(fm_path_entry_key_press), NULL);
    gtk_entry_set_completion(GTK_ENTRY(entry), completion);
}
Ejemplo n.º 7
0
static void
scheme_combo_init (GtkComboBox *combo)
{
    GtkListStore *store;
    MooLangMgr *mgr;
    GSList *list, *l;
    GtkCellRenderer *cell;

    mgr = moo_lang_mgr_default ();
    list = moo_lang_mgr_list_schemes (mgr);
    g_return_if_fail (list != NULL);

    store = gtk_list_store_new (1, MOO_TYPE_TEXT_STYLE_SCHEME);

    for (l = list; l != NULL; l = l->next)
    {
        GtkTreeIter iter;
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter, 0, l->data, -1);
    }

    gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));

    cell = gtk_cell_renderer_text_new ();
    gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), cell,
                                        (GtkCellLayoutDataFunc) scheme_combo_data_func,
                                        NULL, NULL);

    g_object_unref (store);
    g_slist_foreach (list, (GFunc) g_object_unref, NULL);
    g_slist_free (list);
}
Ejemplo n.º 8
0
GtkWidget *
gnc_main_window_summary_new (void)
{
    GNCMainSummary  * retval = g_new0(GNCMainSummary, 1);
    GtkCellRenderer *textRenderer;
    int i;

    retval->datamodel = gtk_list_store_new (N_COLUMNS,
                                            G_TYPE_STRING,
                                            G_TYPE_STRING,
                                            G_TYPE_STRING,
                                            G_TYPE_STRING,
                                            G_TYPE_STRING);

    retval->hbox         = gtk_hbox_new (FALSE, 5);
    retval->totals_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (retval->datamodel));
    g_object_unref (retval->datamodel);

    retval->component_id = gnc_register_gui_component (WINDOW_SUMMARYBAR_CM_CLASS,
                           summarybar_refresh_handler,
                           NULL, retval);
    gnc_gui_component_watch_entity_type (retval->component_id,
                                         GNC_ID_ACCOUNT,
                                         QOF_EVENT_DESTROY
                                         | GNC_EVENT_ITEM_CHANGED);

    // Allows you to get when the popup menu is present
    g_signal_connect (retval->totals_combo, "notify::popup-shown",G_CALLBACK (summary_combo_popped), retval);

    retval->combo_popped = FALSE;

    for (i = 0; i <= N_COLUMNS; i += 2)
    {
        textRenderer = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());

        gtk_cell_renderer_set_fixed_size (textRenderer, 50, -1);

        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, TRUE);

        g_object_set_data (G_OBJECT(textRenderer), "view_column", GINT_TO_POINTER (i));
        gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, cdf, retval, NULL);
    }

    gtk_container_set_border_width (GTK_CONTAINER (retval->hbox), 2);
    gtk_box_pack_start (GTK_BOX(retval->hbox), retval->totals_combo, TRUE, TRUE, 5);
    gtk_widget_show (retval->totals_combo);
    gtk_widget_show (retval->hbox);

    g_signal_connect_swapped (G_OBJECT (retval->hbox), "destroy",
                              G_CALLBACK (gnc_main_window_summary_destroy_cb),
                              retval);

    gnc_main_window_summary_refresh(retval);

    retval->cnxn_id =  gnc_prefs_register_cb (GNC_PREFS_GROUP, NULL,
                       prefs_changed_cb, retval);

    return retval->hbox;
}
Ejemplo n.º 9
0
static void
math_converter_init(MathConverter *converter)
{
    GtkWidget *hbox, *label, *swap_button;
    GtkCellRenderer *renderer;

    converter->priv = G_TYPE_INSTANCE_GET_PRIVATE(converter, math_converter_get_type(), MathConverterPrivate);

    gtk_box_set_spacing(GTK_BOX(converter), 6);

    hbox = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox);
    gtk_box_pack_start(GTK_BOX(converter), hbox, FALSE, TRUE, 0);

    converter->priv->from_combo = gtk_combo_box_new ();

    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(converter->priv->from_combo), renderer, TRUE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(converter->priv->from_combo), renderer, "text", 0);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(converter->priv->from_combo),
                                       renderer,
                                       from_cell_data_func,
                                       NULL, NULL);
    g_signal_connect(converter->priv->from_combo, "changed", G_CALLBACK(from_combobox_changed_cb), converter);
    gtk_widget_show(converter->priv->from_combo);
    gtk_box_pack_start(GTK_BOX(hbox), converter->priv->from_combo, FALSE, TRUE, 0);

    label = gtk_label_new(/* Label that is displayed between the two conversion combo boxes, e.g. "[degrees] in [radians]" */
                          _(" in "));
    gtk_widget_show(label);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 5);

    converter->priv->to_combo = gtk_combo_box_new();
    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(converter->priv->to_combo), renderer, TRUE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(converter->priv->to_combo), renderer, "text", 0);
    g_signal_connect(converter->priv->to_combo, "changed", G_CALLBACK(to_combobox_changed_cb), converter);
    gtk_widget_show(converter->priv->to_combo);
    gtk_box_pack_start(GTK_BOX(hbox), converter->priv->to_combo, FALSE, TRUE, 0);

    swap_button = gtk_button_new_with_label ("⇆");
    gtk_widget_set_tooltip_text (swap_button,
                                 /* Tooltip for swap conversion button */
                                 _("Switch conversion units"));
    gtk_button_set_relief (GTK_BUTTON (swap_button), GTK_RELIEF_NONE);
    g_signal_connect (swap_button, "clicked", G_CALLBACK (swap_button_clicked_cb), converter);
    gtk_widget_show(swap_button);
    gtk_box_pack_start(GTK_BOX(hbox), swap_button, FALSE, TRUE, 0);

    converter->priv->result_label = gtk_label_new("");
    gtk_misc_set_alignment(GTK_MISC(converter->priv->result_label), 1.0, 0.5);
    gtk_widget_set_sensitive(converter->priv->result_label, FALSE);
    gtk_widget_show(converter->priv->result_label);
    gtk_box_pack_start(GTK_BOX(converter), converter->priv->result_label, TRUE, TRUE, 0);

    g_signal_connect(currency_manager_get_default(), "updated", G_CALLBACK(currency_updated_cb), converter);
}
Ejemplo n.º 10
0
static void
update_contact_methods(ChatView *self)
{
    g_return_if_fail(IS_CHAT_VIEW(self));
    ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(self);

    g_return_if_fail(priv->person);

    /* model for the combobox for the choice of ContactMethods */
    auto cm_model = gtk_list_store_new(
        1, G_TYPE_POINTER
    );

    auto cms = priv->person->phoneNumbers();
    for (int i = 0; i < cms.size(); ++i) {
        GtkTreeIter iter;
        gtk_list_store_append(cm_model, &iter);
        gtk_list_store_set(cm_model, &iter,
                           0, cms.at(i),
                           -1);
    }

    gtk_combo_box_set_model(GTK_COMBO_BOX(priv->combobox_cm), GTK_TREE_MODEL(cm_model));
    g_object_unref(cm_model);

    auto renderer = gtk_cell_renderer_text_new();
    g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->combobox_cm), renderer, FALSE);
    gtk_cell_layout_set_cell_data_func(
        GTK_CELL_LAYOUT(priv->combobox_cm),
        renderer,
        (GtkCellLayoutDataFunc)render_contact_method,
        nullptr, nullptr);

    /* select the last used cm */
    if (!cms.isEmpty()) {
        auto last_used_cm = cms.at(0);
        int last_used_cm_idx = 0;
        for (int i = 1; i < cms.size(); ++i) {
            auto new_cm = cms.at(i);
            if (difftime(new_cm->lastUsed(), last_used_cm->lastUsed()) > 0) {
                last_used_cm = new_cm;
                last_used_cm_idx = i;
            }
        }

        gtk_combo_box_set_active(GTK_COMBO_BOX(priv->combobox_cm), last_used_cm_idx);
    }

    /* show the combo box if there is more than one cm to choose from */
    if (cms.size() > 1)
        gtk_widget_show_all(priv->combobox_cm);
    else
        gtk_widget_hide(priv->combobox_cm);
}
Ejemplo n.º 11
0
static void
connection_pppoe_combo_init (GtkComboBox *combo)
{
  GtkCellRenderer *renderer;

  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);

  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer,
				      pppoe_combo_cell_func, NULL, NULL);
}
static void
subtitle_encoding_combo_render (GtkComboBox * combo)
{
  GtkCellRenderer *renderer;

  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
      "text", NAME_COL, NULL);
  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
      renderer, is_encoding_sensitive, NULL, NULL);
}
Ejemplo n.º 13
0
static void
hito_group_combo_init (HitoGroupCombo *self)
{
  GtkCellRenderer *renderer;
  
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), renderer, TRUE);
  gtk_cell_layout_set_cell_data_func  (GTK_CELL_LAYOUT (self), renderer,
                                       group_name_data_func, NULL, NULL);

  gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
                                        is_separator_func, NULL, NULL);
}
Ejemplo n.º 14
0
Archivo: main.c Proyecto: ravishi/bline
static void
bline_main_setup_filter_selector (GtkWindow *self)
{
  ChData            *chdata;
  GtkWidget         *combo;
  GtkListStore      *store;
  GtkCellRenderer   *cell;

  chdata = bline_main_get_chdata (self);

  combo = chdata->combo;

  store = gtk_list_store_new (1, G_TYPE_OBJECT);

  gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));

  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
                                      cell,
                                      bline_main_cell_layout,
                                      NULL,
                                      NULL);

  g_signal_connect (G_OBJECT (combo),
                    "changed",
                    G_CALLBACK (bline_main_combo_box_on_changed),
                    (gpointer) self);

  gtk_widget_set_sensitive (GTK_WIDGET (combo), FALSE);

  /* add all filters */
  bline_main_add_filter (self,
    BLINE_FILTER (bline_simple_filter_new_with_title ("Sobel", 2, (const int *) SOBEL_MASK)));

  bline_main_add_filter (self,
    BLINE_FILTER (bline_simple_filter_new_with_title ("Sobel (horizontal)", 1, (const int *) SOBEL_MASK)));

  bline_main_add_filter (self,
    BLINE_FILTER (bline_simple_filter_new_with_title ("Sobel (vertical)", 1, (const int *) &SOBEL_MASK[1])));

  bline_main_add_filter (self,
    BLINE_FILTER (bline_simple_filter_new_with_title ("Scharr", 2, (const int *) SCHARR_MASK)));

  bline_main_add_filter (self,
    BLINE_FILTER (bline_simple_filter_new_with_title ("Robinson", 8, (const int *) ROBINSON_MASK)));

  bline_main_add_filter (self,
    BLINE_FILTER (bline_simple_filter_new_with_title ("Kirsch", 8, (const int *) KIRSCH_MASK)));
}
Ejemplo n.º 15
0
static void
gweather_timezone_menu_init (GWeatherTimezoneMenu *menu)
{
    GtkCellRenderer *renderer;

    gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (menu),
					  row_separator_func, NULL, NULL);

    renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (menu), renderer, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (menu), renderer,
				    "markup", 0,
				    NULL);
    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (menu),
					renderer, is_sensitive, NULL, NULL);
}
Ejemplo n.º 16
0
/**
 * gwy_enum_combo_box_new:
 * @entries: An enum with choices.
 * @nentries: The number of items in @entries, may be -1 when @entries is
 *            terminated with %NULL enum name.
 * @callback: A callback called when a new choice is selected (may be %NULL).
 *            If you want to just update an integer, you can use
 *            gwy_enum_combo_box_update_int() here.
 * @cbdata: User data passed to the callback.
 * @active: The enum value to show as currently selected.  If it isn't equal to
 *          any @entries value, first item is selected.
 * @translate: Whether to apply translation function (gwy_sgettext()) to item
 *             names.
 *
 * Creates a combo box with choices from a enum.
 *
 * The array @entries must exist during the whole lifetime of the combo box
 * because it is used directly as the model.
 *
 * Returns: A newly created combo box as #GtkWidget.
 **/
GtkWidget*
gwy_enum_combo_box_new(const GwyEnum *entries,
                       gint nentries,
                       GCallback callback,
                       gpointer cbdata,
                       gint active,
                       gboolean translate)
{
    GtkWidget *combo;
    GwyInventory *inventory;
    GwyInventoryStore *store;
    GtkCellRenderer *renderer;
    GtkCellLayout *layout;
    GtkTreeModel *model;

    inventory = gwy_enum_inventory_new(entries, nentries);
    store = gwy_inventory_store_new(inventory);
    g_object_unref(inventory);
    model = GTK_TREE_MODEL(store);
    combo = gtk_combo_box_new_with_model(model);
    gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 1);
    g_object_unref(store);

    g_assert(gwy_inventory_store_get_column_by_name(store, "name") == 1);
    g_assert(gwy_inventory_store_get_column_by_name(store, "value") == 2);

    layout = GTK_CELL_LAYOUT(combo);
    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(layout, renderer, FALSE);
    if (translate)
        gtk_cell_layout_set_cell_data_func(layout, renderer,
                                           cell_translate_func, &gwy_sgettext,
                                           NULL);
    else
        gtk_cell_layout_add_attribute(layout, renderer, "markup", 1);

    if (!gwy_enum_combo_box_try_set_active(GTK_COMBO_BOX(combo), active))
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
    if (callback)
        g_signal_connect(combo, "changed", callback, cbdata);

    return combo;
}
Ejemplo n.º 17
0
static void
fm_path_entry_init(FmPathEntry *entry)
{
    FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry);
    GtkEntryCompletion* completion = gtk_entry_completion_new();
    GtkCellRenderer* render;

    priv->model = fm_path_entry_model_new(entry);
    priv->completion = completion;
    priv->cancellable = g_cancellable_new();
    priv->highlight_completion_match = TRUE;
    gtk_entry_completion_set_minimum_key_length(completion, 1);

    gtk_entry_completion_set_match_func(completion, fm_path_entry_match_func, NULL, NULL);
    g_object_set(completion, "text_column", COL_FULL_PATH, NULL);
    gtk_entry_completion_set_model(completion, priv->model);

    render = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE );
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion), render, fm_path_entry_completion_render_func, entry, NULL);

    /* NOTE: this is to avoid a bug of gtk+.
     * The inline selection provided by GtkEntry is buggy.
     * If we change the content of the entry, it still stores
     * the old prefix sometimes so things don't work as expected.
     * So, unfortunately, we're not able to use this nice feature.
     *
     * Please see gtk_entry_completion_key_press() of gtk/gtkentry.c
     * and look for completion->priv->completion_prefix.
     */
    gtk_entry_completion_set_inline_selection(completion, FALSE);

    gtk_entry_completion_set_inline_completion(completion, TRUE);
    gtk_entry_completion_set_popup_set_width(completion, TRUE);
    /* gtk_entry_completion_set_popup_single_match(completion, FALSE); */

    /* connect to these signals rather than overriding default handlers since
     * we want to invoke our handlers before the default ones provided by Gtk. */
    g_signal_connect(entry, "key-press-event", G_CALLBACK(fm_path_entry_key_press), NULL);
    g_signal_connect(entry, "activate", G_CALLBACK(fm_path_entry_on_activate), NULL);
    g_signal_connect(entry, "populate-popup", G_CALLBACK(fm_path_entry_populate_popup), NULL);
}
Ejemplo n.º 18
0
/**
 * ide_fancy_tree_view_set_data_func:
 * @self: a #IdeFancyTreeView
 * @func: (closure func_data) (scope async) (nullable): a callback
 * @func_data: data for @func
 * @func_data_destroy: destroy notify for @func_data
 *
 * Sets the data func to use to update the text for the
 * #IdeCellRendererFancy cell renderer.
 *
 * Since: 3.32
 */
void
ide_fancy_tree_view_set_data_func (IdeFancyTreeView      *self,
                                   GtkCellLayoutDataFunc  func,
                                   gpointer               func_data,
                                   GDestroyNotify         func_data_destroy)
{
  GtkTreeViewColumn *column;
  GList *cells;

  g_return_if_fail (IDE_IS_FANCY_TREE_VIEW (self));

  column = gtk_tree_view_get_column (GTK_TREE_VIEW (self), 0);
  cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));

  if (cells->data != NULL)
    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), cells->data,
                                        func, func_data, func_data_destroy);

  g_list_free (cells);
}
Ejemplo n.º 19
0
Archivo: gnac-ui.c Proyecto: GNOME/gnac
static GtkWidget *
gnac_ui_file_chooser_new(void)
{
  gnac_file_chooser = gnac_ui_get_widget("gnac_file_chooser");
  GtkTreeModel *model = gnac_ui_file_chooser_get_filters_model();
  GtkWidget *combo = gnac_ui_get_widget("filters_combo");
  gtk_combo_box_set_model(GTK_COMBO_BOX(combo), model);

  GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
  gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(combo), renderer,
      (GtkCellLayoutDataFunc) gnac_ui_file_chooser_cell_data_func,
      NULL, NULL);

  last_used_folder = g_get_current_dir();

  gnac_ui_reset_file_filter();

  return gnac_file_chooser;
}
Ejemplo n.º 20
0
static void site_setup(AWeatherGui *self)
{
	GtkTreeIter state, city;
	GtkTreeStore *store = GTK_TREE_STORE(aweather_gui_get_object(self, "sites"));
	gtk_tree_store_append(store, &state, NULL);
	gtk_tree_store_set   (store, &state, 0, "", 1, "None", -1);
	for (int i = 0; cities[i].type; i++) {
		if (cities[i].type == LOCATION_STATE) {
			gtk_tree_store_append(store, &state, NULL);
			gtk_tree_store_set   (store, &state, 0, cities[i].code,
					                     1, cities[i].name, -1);
		} else if (cities[i].type == LOCATION_CITY) {
			gtk_tree_store_append(store, &city, &state);
			gtk_tree_store_set   (store, &city, 0, cities[i].code,
				                            1, cities[i].name, -1);
		}
	}

	GtkWidget *combo    = aweather_gui_get_widget(self, "prefs_general_site");
	GObject   *renderer = aweather_gui_get_object(self, "prefs_general_site_rend");
	gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(combo),
			GTK_CELL_RENDERER(renderer), combo_sensitive, NULL, NULL);
}
Ejemplo n.º 21
0
static void
cg_combo_flags_cell_layout_set_cell_data_func (GtkCellLayout *layout,
                                               GtkCellRenderer *cell,
                                               GtkCellLayoutDataFunc func,
                                               gpointer func_data,
                                               GDestroyNotify destroy)
{
	CgComboFlags *combo;
	CgComboFlagsPrivate *priv;
	CgComboFlagsCellInfo *info;
	GDestroyNotify old_destroy;

	combo = CG_COMBO_FLAGS (layout);
	priv = CG_COMBO_FLAGS_PRIVATE (combo);
	info = cg_combo_flags_get_cell_info (combo, cell);
	g_return_if_fail (info != NULL);

	if (info->destroy)
	{
		old_destroy = info->destroy;

		info->destroy = NULL;
		old_destroy (info->func_data);
	}

	info->func = func;
	info->func_data = func_data;
	info->destroy = destroy;

	if (priv->column != NULL)
	{
    	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->column),
    	                                    cell, func, func_data, NULL);
	}

	gtk_widget_queue_resize (GTK_WIDGET (combo));
}
Ejemplo n.º 22
0
static void
lang_combo_init (GtkComboBox   *combo,
                 MooPrefsPage  *page,
                 PrefsLangsXml *gxml)
{
    GtkTreeModel *model;
    GtkCellRenderer *cell;
    MooTreeHelper *helper;

    fix_style (GTK_WIDGET (combo));

    model = page_get_lang_model (page);
    g_return_if_fail (model != NULL);

    cell = gtk_cell_renderer_text_new ();
    gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
                                    "text", COLUMN_NAME, NULL);
    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), cell,
                                        set_sensitive, NULL, NULL);

    gtk_combo_box_set_model (combo, model);

    _moo_combo_box_select_first (combo);
    helper = _moo_tree_helper_new (GTK_WIDGET (combo), NULL, NULL, NULL, NULL);
    g_return_if_fail (helper != NULL);

    g_object_set_data_full (G_OBJECT (page), "moo-tree-helper",
                            helper, g_object_unref);
    g_signal_connect_swapped (helper, "update-widgets",
                              G_CALLBACK (helper_update_widgets), gxml);
    g_signal_connect_swapped (helper, "update-model",
                              G_CALLBACK (helper_update_model), gxml);
    _moo_tree_helper_update_widgets (helper);
}
static void
fill_model_combo (GtkWidget *combo, const char *mount_path)
{
	GHashTable *models;
	Itdb_Device *device;
	GtkTreeStore *store;
	const Itdb_IpodInfo *ipod_info;
	GtkCellRenderer *renderer;
	struct FillModelContext ctx;

	device = itdb_device_new ();
	itdb_device_set_mountpoint (device, mount_path);
	itdb_device_read_sysinfo (device);
	ipod_info = itdb_device_get_ipod_info (device);
	itdb_device_free (device);

	store = gtk_tree_store_new (1, G_TYPE_POINTER);
	gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));

	ctx.combo = combo;
	ctx.store = store;
	ctx.ipod_info = ipod_info;
	models = build_model_table (mount_path);
	g_hash_table_foreach (models, fill_one_generation, &ctx);
	g_hash_table_destroy (models);
	g_object_unref (store);

	gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
					    renderer,
					    set_cell,
					    NULL, NULL);
}
Ejemplo n.º 24
0
GtkWidget *
do_combobox (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;
  GtkWidget *vbox, *frame, *box, *combo;
  GtkTreeModel *model;
  GtkCellRenderer *renderer;
  GtkTreePath *path;
  GtkTreeIter iter;

  if (!window)
  {
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_screen (GTK_WINDOW (window),
                           gtk_widget_get_screen (do_widget));
    gtk_window_set_title (GTK_WINDOW (window), "Combo boxes");
   
    g_signal_connect (window, "destroy",
                      G_CALLBACK (gtk_widget_destroyed),
                      &window);
    
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

    vbox = gtk_vbox_new (FALSE, 2);
    gtk_container_add (GTK_CONTAINER (window), vbox);

    /* A combobox demonstrating cell renderers, separators and
     *  insensitive rows 
     */
    frame = gtk_frame_new ("Some stock icons");
    gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
    
    box = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (box), 5);
    gtk_container_add (GTK_CONTAINER (frame), box);
    
    model = create_stock_icon_store ();
    combo = gtk_combo_box_new_with_model (model);
    g_object_unref (model);
    gtk_container_add (GTK_CONTAINER (box), combo);
    
    renderer = gtk_cell_renderer_pixbuf_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
				    "pixbuf", PIXBUF_COL, 
				    NULL);

    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
					renderer,
					set_sensitive,
					NULL, NULL);
    
    renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
				    "text", TEXT_COL,
				    NULL);

    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
					renderer,
					set_sensitive,
					NULL, NULL);

    gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo), 
					  is_separator, NULL, NULL);
    
    gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
    
    /* A combobox demonstrating trees.
     */
    frame = gtk_frame_new ("Where are we ?");
    gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

    box = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (box), 5);
    gtk_container_add (GTK_CONTAINER (frame), box);
    
    model = create_capital_store ();
    combo = gtk_combo_box_new_with_model (model);
    g_object_unref (model);
    gtk_container_add (GTK_CONTAINER (box), combo);

    renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
				    "text", 0,
				    NULL);
    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
					renderer,
					is_capital_sensitive,
					NULL, NULL);

    path = gtk_tree_path_new_from_indices (0, 8, -1);
    gtk_tree_model_get_iter (model, &iter, path);
    gtk_tree_path_free (path);
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);

    /* A GtkComboBoxEntry 
     */
    frame = gtk_frame_new ("Editable");
    gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
    
    box = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (box), 5);
    gtk_container_add (GTK_CONTAINER (frame), box);
    
    combo = gtk_combo_box_entry_new_text ();
    fill_combo_entry (combo);
    gtk_container_add (GTK_CONTAINER (box), combo);
    
  }

  if (!GTK_WIDGET_VISIBLE (window))
    {
      gtk_widget_show_all (window);
    }
  else
    {    
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
void
desktop_init (AppearanceData *data,
	      const gchar **uris)
{
  GtkWidget *add_button, *w;
  GtkCellRenderer *cr;
  char *url;

  data->wp_update_settings = TRUE;

  data->wp_uris = NULL;
  if (uris != NULL) {
    while (*uris != NULL) {
      data->wp_uris = g_slist_append (data->wp_uris, g_strdup (*uris));
      uris++;
    }
  }

  w = appearance_capplet_get_widget (data, "more_backgrounds_linkbutton");
  url = g_settings_get_string (data->settings, MORE_BACKGROUNDS_URL_KEY);
  if (url != NULL && url[0] != '\0') {
    gtk_link_button_set_uri (GTK_LINK_BUTTON (w), url);
    gtk_widget_show (w);
  } else {
    gtk_widget_hide (w);
  }
  g_free (url);

  data->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);

  g_signal_connect (data->wp_settings,
                           "changed::" WP_FILE_KEY,
                           G_CALLBACK (wp_file_changed),
                           data);
  g_signal_connect (data->wp_settings,
                           "changed::" WP_OPTIONS_KEY,
                           G_CALLBACK (wp_options_changed),
                           data);
  g_signal_connect (data->wp_settings,
                           "changed::" WP_SHADING_KEY,
                           G_CALLBACK (wp_shading_changed),
                           data);
  g_signal_connect (data->wp_settings,
                           "changed::" WP_PCOLOR_KEY,
                           G_CALLBACK (wp_color1_changed),
                           data);
  g_signal_connect (data->wp_settings,
                           "changed::" WP_SCOLOR_KEY,
                           G_CALLBACK (wp_color2_changed),
                           data);

  data->wp_model = GTK_TREE_MODEL (gtk_list_store_new (2, GDK_TYPE_PIXBUF,
                                                       G_TYPE_POINTER));

  data->wp_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "wp_view"));
  gtk_icon_view_set_model (data->wp_view, GTK_TREE_MODEL (data->wp_model));

  g_signal_connect_after (data->wp_view, "realize",
                          (GCallback) wp_select_after_realize, data);

  gtk_cell_layout_clear (GTK_CELL_LAYOUT (data->wp_view));

  cr = gtk_cell_renderer_pixbuf_new ();
  g_object_set (cr, "xpad", 5, "ypad", 5, NULL);

  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->wp_view), cr, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->wp_view), cr,
                                  "pixbuf", 0,
                                  NULL);

  cr = gtk_cell_renderer_pixbuf_new ();
  create_button_images (data);
  g_object_set (cr,
                "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
                "pixbuf", buttons[0],
                NULL);
  g_object_set_data (G_OBJECT (cr), "buttons", GINT_TO_POINTER (TRUE));

  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->wp_view), cr, FALSE);
  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (data->wp_view), cr,
                                      buttons_cell_data_func, data, NULL);
  g_signal_connect (data->wp_view, "selection-changed",
                    (GCallback) wp_selected_changed_cb, data);
  g_signal_connect (data->wp_view, "button-press-event",
                    G_CALLBACK (wp_button_press_cb), data);

  data->frame = -1;

  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (data->wp_model), 1,
                                   (GtkTreeIterCompareFunc) wp_list_sort,
                                   data, NULL);

  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->wp_model),
                                        1, GTK_SORT_ASCENDING);

  gtk_drag_dest_set (GTK_WIDGET (data->wp_view), GTK_DEST_DEFAULT_ALL, drop_types,
                     G_N_ELEMENTS (drop_types), GDK_ACTION_COPY | GDK_ACTION_MOVE);
  g_signal_connect (data->wp_view, "drag_data_received",
                    (GCallback) wp_drag_received, data);

  gtk_drag_source_set (GTK_WIDGET (data->wp_view), GDK_BUTTON1_MASK,
                       drag_types, G_N_ELEMENTS (drag_types), GDK_ACTION_COPY);
  g_signal_connect (data->wp_view, "drag-data-get",
		    (GCallback) wp_drag_get_data, data);

  data->wp_style_menu = appearance_capplet_get_widget (data, "wp_style_menu");

  g_signal_connect (data->wp_style_menu, "changed",
                    (GCallback) wp_scale_type_changed, data);

  data->wp_color_menu = appearance_capplet_get_widget (data, "wp_color_menu");

  g_signal_connect (data->wp_color_menu, "changed",
                    (GCallback) wp_shade_type_changed, data);

  data->wp_scpicker = appearance_capplet_get_widget (data, "wp_scpicker");

  g_signal_connect (data->wp_scpicker, "color-set",
                    (GCallback) wp_scolor_changed, data);

  data->wp_pcpicker = appearance_capplet_get_widget (data, "wp_pcpicker");

  g_signal_connect (data->wp_pcpicker, "color-set",
                    (GCallback) wp_scolor_changed, data);

  add_button = appearance_capplet_get_widget (data, "wp_add_button");
  gtk_button_set_image (GTK_BUTTON (add_button),
                        gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON));

  g_signal_connect (add_button, "clicked",
                    (GCallback) wp_file_open_dialog, data);

  data->wp_rem_button = appearance_capplet_get_widget (data, "wp_rem_button");

  g_signal_connect (data->wp_rem_button, "clicked",
                    (GCallback) wp_remove_wallpaper, data);
  data->screen_monitors_handler = g_signal_connect (gtk_widget_get_screen (GTK_WIDGET (data->wp_view)),
                                                    "monitors-changed",
                                                    G_CALLBACK (screen_monitors_changed),
                                                    data);
  data->screen_size_handler = g_signal_connect (gtk_widget_get_screen (GTK_WIDGET (data->wp_view)),
                                                    "size-changed",
                                                    G_CALLBACK (screen_monitors_changed),
                                                    data);

  g_signal_connect (data->wp_view, "selection-changed",
                    (GCallback) wp_props_wp_selected, data);
  g_signal_connect (data->wp_view, "query-tooltip",
                    (GCallback) wp_view_tooltip_cb, data);
  gtk_widget_set_has_tooltip (GTK_WIDGET (data->wp_view), TRUE);

  wp_set_sensitivities (data);

  /* create the file selector later to save time on startup */
  data->wp_filesel = NULL;

}
Ejemplo n.º 26
0
SteadyflowFileListController* steadyflow_file_list_controller_construct (GType object_type, GtkTreeView* tree) {
	SteadyflowFileListController * self = NULL;
	GtkTreeView* _tmp0_;
	GtkTreeView* _tmp1_;
	GtkTreeView* _tmp2_;
	GtkTreeSelection* _tmp3_ = NULL;
	GTimer* _tmp4_;
	GTimer* _tmp5_;
	GtkTreeViewColumn* _tmp6_;
	GtkTreeViewColumn* _tmp7_;
	GtkTreeViewColumn* column;
	GtkTreeViewColumn* _tmp8_;
	GtkTreeViewColumn* _tmp9_;
	SteadyflowUIDownloadCellRenderer* _tmp10_;
	GtkCellRenderer* _tmp11_;
	GtkCellRenderer* renderer;
	GtkTreeViewColumn* _tmp12_;
	GtkCellRenderer* _tmp13_;
	GtkTreeViewColumn* _tmp14_;
	GtkCellRenderer* _tmp15_;
	GType* _tmp16_ = NULL;
	GType* _tmp17_;
	gint _tmp17__length1;
	GtkListStore* _tmp18_;
	GtkTreeView* _tmp19_;
	GtkListStore* _tmp20_;
	GtkTreeView* _tmp21_;
	GtkTreeViewColumn* _tmp22_;
	SteadyflowCoreIDownloadService* _tmp37_;
	SteadyflowCoreIDownloadService* _tmp38_;
	SteadyflowCoreIDownloadService* _tmp39_;
	SteadyflowCoreIDownloadService* _tmp40_;
	GtkTreeView* _tmp41_;
	GtkTreeSelection* _tmp42_ = NULL;
	g_return_val_if_fail (tree != NULL, NULL);
	self = (SteadyflowFileListController*) g_object_new (object_type, NULL);
	_tmp0_ = tree;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->tree);
	self->priv->tree = _tmp1_;
	_tmp2_ = tree;
	_tmp3_ = gtk_tree_view_get_selection (_tmp2_);
	gtk_tree_selection_set_mode (_tmp3_, GTK_SELECTION_MULTIPLE);
	_tmp4_ = g_timer_new ();
	_g_timer_destroy0 (self->priv->redraw_timer);
	self->priv->redraw_timer = _tmp4_;
	_tmp5_ = self->priv->redraw_timer;
	g_timer_start (_tmp5_);
	_tmp6_ = gtk_tree_view_column_new ();
	_tmp7_ = g_object_ref_sink (_tmp6_);
	column = _tmp7_;
	_tmp8_ = column;
	gtk_tree_view_column_set_expand (_tmp8_, TRUE);
	_tmp9_ = column;
	gtk_tree_view_column_set_clickable (_tmp9_, FALSE);
	_tmp10_ = steadyflow_ui_download_cell_renderer_new ();
	_tmp11_ = (GtkCellRenderer*) g_object_ref_sink (_tmp10_);
	renderer = _tmp11_;
	_tmp12_ = column;
	_tmp13_ = renderer;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp12_, _tmp13_, TRUE);
	_tmp14_ = column;
	_tmp15_ = renderer;
	gtk_cell_layout_set_cell_data_func ((GtkCellLayout*) _tmp14_, _tmp15_, _steadyflow_file_list_controller_set_cell_data_gtk_cell_layout_data_func, g_object_ref (self), g_object_unref);
	_tmp16_ = g_new0 (GType, 1);
	_tmp16_[0] = STEADYFLOW_CORE_TYPE_IDOWNLOAD_FILE;
	_tmp17_ = _tmp16_;
	_tmp17__length1 = 1;
	_tmp18_ = gtk_list_store_newv (1, _tmp17_);
	_g_object_unref0 (self->priv->model);
	self->priv->model = _tmp18_;
	_tmp17_ = (g_free (_tmp17_), NULL);
	_tmp19_ = tree;
	_tmp20_ = self->priv->model;
	gtk_tree_view_set_model (_tmp19_, (GtkTreeModel*) _tmp20_);
	_tmp21_ = tree;
	_tmp22_ = column;
	gtk_tree_view_append_column (_tmp21_, _tmp22_);
	{
		SteadyflowCoreIDownloadService* _tmp23_;
		SteadyflowCoreIDownloadService* _tmp24_;
		GeeList* _tmp25_;
		GeeList* _tmp26_;
		GeeList* _file_list;
		GeeList* _tmp27_;
		gint _tmp28_;
		gint _tmp29_;
		gint _file_size;
		gint _file_index;
		_tmp23_ = steadyflow_services_get_download ();
		_tmp24_ = _tmp23_;
		_tmp25_ = steadyflow_core_idownload_service_get_files (_tmp24_);
		_tmp26_ = _tmp25_;
		_file_list = _tmp26_;
		_tmp27_ = _file_list;
		_tmp28_ = gee_collection_get_size ((GeeCollection*) _tmp27_);
		_tmp29_ = _tmp28_;
		_file_size = _tmp29_;
		_file_index = -1;
		while (TRUE) {
			gint _tmp30_;
			gint _tmp31_;
			gint _tmp32_;
			GeeList* _tmp33_;
			gint _tmp34_;
			gpointer _tmp35_ = NULL;
			SteadyflowCoreIDownloadFile* file;
			SteadyflowCoreIDownloadFile* _tmp36_;
			_tmp30_ = _file_index;
			_file_index = _tmp30_ + 1;
			_tmp31_ = _file_index;
			_tmp32_ = _file_size;
			if (!(_tmp31_ < _tmp32_)) {
				break;
			}
			_tmp33_ = _file_list;
			_tmp34_ = _file_index;
			_tmp35_ = gee_list_get (_tmp33_, _tmp34_);
			file = (SteadyflowCoreIDownloadFile*) _tmp35_;
			_tmp36_ = file;
			steadyflow_file_list_controller_connect_file_signals (self, _tmp36_);
			_g_object_unref0 (file);
		}
		_g_object_unref0 (_file_list);
	}
	steadyflow_file_list_controller_update_model (self);
	_tmp37_ = steadyflow_services_get_download ();
	_tmp38_ = _tmp37_;
	g_signal_connect_object (_tmp38_, "file-added", (GCallback) ___lambda26__steadyflow_core_idownload_service_file_added, self, 0);
	_tmp39_ = steadyflow_services_get_download ();
	_tmp40_ = _tmp39_;
	g_signal_connect_object (_tmp40_, "file-removed", (GCallback) ___lambda27__steadyflow_core_idownload_service_file_removed, self, 0);
	_tmp41_ = tree;
	_tmp42_ = gtk_tree_view_get_selection (_tmp41_);
	g_signal_connect_object (_tmp42_, "changed", (GCallback) ___lambda28__gtk_tree_selection_changed, self, 0);
	_g_object_unref0 (renderer);
	_g_object_unref0 (column);
	return self;
}
static void
create_user_combobox (PolkitMateAuthenticationDialog *dialog)
{
  int n;
  GtkComboBox *combo;
  GtkTreeIter iter;
  GtkCellRenderer *renderer;

  /* if we've already built the list of admin users once, then avoid
   * doing it again.. (this is mainly used when the user entered the
   * wrong password and the dialog is recycled)
   */
  if (dialog->priv->store != NULL)
    return;

  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);

  gtk_list_store_append (dialog->priv->store, &iter);
  gtk_list_store_set (dialog->priv->store, &iter,
                      PIXBUF_COL, NULL,
                      TEXT_COL, _("Select user..."),
                      USERNAME_COL, NULL,
                      -1);


  /* For each user */
  for (n = 0; dialog->priv->users[n] != NULL; n++)
    {
      gchar *gecos;
      gchar *real_name;
      GdkPixbuf *pixbuf;
      struct passwd *passwd;

      /* we're single threaded so this is fine */
      errno = 0;
      passwd = getpwnam (dialog->priv->users[n]);
      if (passwd == NULL)
        {
          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
          continue;
        }

      if (passwd->pw_gecos != NULL)
        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
      else
        gecos = NULL;

      if (gecos != NULL && strlen (gecos) > 0)
        {
          gchar *first_comma;
          first_comma = strchr (gecos, ',');
          if (first_comma != NULL)
            *first_comma = '\0';
        }
      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
       else
         real_name = g_strdup (dialog->priv->users[n]);
      g_free (gecos);

      /* Load users face */
      pixbuf = NULL;
      if (passwd->pw_dir != NULL)
        {
          gchar *path;
          path = g_strdup_printf ("%s/.face", passwd->pw_dir);
          /* TODO: we probably shouldn't hard-code the size to 16x16 */
          pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
          g_free (path);
        }

      /* fall back to stock_person icon */
      if (pixbuf == NULL)
        {
          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                             "stock_person",
                                             GTK_ICON_SIZE_MENU,
                                             0,
                                             NULL);
        }

      gtk_list_store_append (dialog->priv->store, &iter);
      gtk_list_store_set (dialog->priv->store, &iter,
                          PIXBUF_COL, pixbuf,
                          TEXT_COL, real_name,
                          USERNAME_COL, dialog->priv->users[n],
                          -1);

      g_free (real_name);
      g_object_unref (pixbuf);
    }

  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));

  renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
                                  renderer,
                                  "pixbuf", PIXBUF_COL,
                                  NULL);
  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
                                      renderer,
                                      user_combobox_set_sensitive,
                                      NULL, NULL);

  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
                                  renderer,
                                  "text", TEXT_COL,
                                  NULL);
  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
                                      renderer,
                                      user_combobox_set_sensitive,
                                      NULL, NULL);

  /* Initially select the "Select user..." ... */
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

  /* Listen when a new user is selected */
  g_signal_connect (GTK_WIDGET (combo),
                    "changed",
                    G_CALLBACK (user_combobox_changed),
                    dialog);
}
Ejemplo n.º 28
0
static void dev_set_options(GtkAction *action, GtkWindow *parent)
{
	(void)action;

	struct sr_dev *dev = g_object_get_data(G_OBJECT(parent), "dev");
	if (!dev)
		return;

	GtkWidget *dialog = gtk_dialog_new_with_buttons("Device Properties",
					parent, GTK_DIALOG_MODAL,
					GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
					NULL);
	GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_widget_set_size_request(sw, 300, 200);
	GtkWidget *tv = gtk_tree_view_new();
	gtk_container_add(GTK_CONTAINER(sw), tv);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw,
				TRUE, TRUE, 0);

	/* Populate list store with config options */
	GtkListStore *props = gtk_list_store_new(MAX_DEV_PROP, 
					G_TYPE_INT, G_TYPE_INT,
					G_TYPE_STRING, G_TYPE_STRING,
					G_TYPE_BOOLEAN, G_TYPE_STRING,
					G_TYPE_BOOLEAN);
	gtk_tree_view_set_model(GTK_TREE_VIEW(tv), GTK_TREE_MODEL(props));
	int *hwcaps = dev->driver->hwcap_get_all();
	int cap;
	GtkTreeIter iter;
	for (cap = 0; hwcaps[cap]; cap++) {
		struct sr_hwcap_option *hwo;
		if (!(hwo = sr_hw_hwcap_get(hwcaps[cap])))
			continue;
		gtk_list_store_append(props, &iter);
		gtk_list_store_set(props, &iter, 
					DEV_PROP_HWCAP, hwcaps[cap],
					DEV_PROP_TYPE, hwo->type,
					DEV_PROP_SHORTNAME, hwo->shortname,
					DEV_PROP_DESCRIPTION, hwo->description,
					DEV_PROP_IS_TEXT, hwo->type != SR_T_BOOL,
					-1);
	}

	/* Popup tooltop containing description if mouse hovers */
	gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(tv), 
					DEV_PROP_DESCRIPTION);

	/* Save device with list so that property can be set by edited
	 * handler. */
	g_object_set_data(G_OBJECT(props), "dev", dev);

	/* Add columns to the tree view */
	GtkTreeViewColumn *col;
	col = gtk_tree_view_column_new_with_attributes("Property",
				gtk_cell_renderer_text_new(),
				"text", DEV_PROP_SHORTNAME, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tv), col);
	/* We pack both a text and toggle renderer.  Only one will be visible.
	 * depending on type.
	 */
	GtkCellRenderer *cel = gtk_cell_renderer_text_new();
	g_object_set(cel, "editable", TRUE, NULL);
	g_signal_connect(cel, "edited", G_CALLBACK(prop_edited), props);
	col = gtk_tree_view_column_new_with_attributes("Value",
				cel, "text", DEV_PROP_TEXTVALUE, 
				"visible", DEV_PROP_IS_TEXT, NULL);
	cel = gtk_cell_renderer_toggle_new();
	g_signal_connect(cel, "toggled", G_CALLBACK(prop_toggled), props);
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(col), cel, TRUE);
	gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(col), cel, 
				dev_prop_bool_data_func, NULL, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tv), col);


	gtk_widget_show_all(dialog);
	gtk_dialog_run(GTK_DIALOG(dialog));

	gtk_widget_destroy(dialog);
}
Ejemplo n.º 29
0
void _fcitx_main_window_add_addon_page(FcitxMainWindow* self)
{
    FcitxAddon* addon;
    utarray_new(self->addons, &addonicd);
    FcitxAddonsLoad(self->addons);

    GtkWidget* vbox = gtk_vbox_new(FALSE, 0);

    GtkListStore *store;
    store = gtk_list_store_new(N_COLUMNS, G_TYPE_POINTER);

    GtkWidget* swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
    g_object_set(swin, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
    self->addonview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
    g_object_set(self->addonview, "headers-visible", FALSE, NULL);
    gtk_container_add(GTK_CONTAINER(swin), self->addonview);
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    renderer = gtk_cell_renderer_toggle_new();
    column = gtk_tree_view_column_new_with_attributes("Enable", renderer, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), column);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(column),
                                       renderer,
                                       _fcitx_main_window_enabled_data_func,
                                       self->addonview,
                                       NULL);
    g_signal_connect(G_OBJECT(renderer), "toggled",
                     G_CALLBACK(_fcitx_main_window_toggled_cb), GTK_TREE_MODEL(store));

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes("Name", renderer, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), column);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(column),
                                       renderer,
                                       _fcitx_main_window_name_data_func,
                                       self->addonview,
                                       NULL);

    gtk_tree_view_set_model(GTK_TREE_VIEW(self->addonview),
                            GTK_TREE_MODEL(store));

    g_object_unref(store);

    for (addon = (FcitxAddon *) utarray_front(self->addons);
            addon != NULL;
            addon = (FcitxAddon *) utarray_next(self->addons, addon)) {
        GtkTreeIter iter;
        store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(self->addonview)));
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, LIST_ADDON, addon, -1);
    }

    GtkWidget* hbuttonbox = gtk_hbutton_box_new();
    gtk_box_pack_start(GTK_BOX(vbox), hbuttonbox, FALSE, TRUE, 0);

    self->button = gtk_button_new_with_label(_("Configure"));
    gtk_widget_set_sensitive(self->button, FALSE);
    gtk_button_set_image(GTK_BUTTON(self->button), gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start(GTK_BOX(hbuttonbox), self->button, TRUE, TRUE, 0);
    g_signal_connect(G_OBJECT(self->button), "clicked", G_CALLBACK(_fcitx_main_window_configure_button_clicked), self);

    GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self->addonview));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
    g_signal_connect(G_OBJECT(selection), "changed",
                     G_CALLBACK(_fcitx_main_window_addon_selection_changed), self);

    g_signal_connect(G_OBJECT(self->addonview),
                     "row-activated",
                     G_CALLBACK(_fcitx_main_window_addon_row_activated), self);

    self->addonpage = _fcitx_main_window_add_page(self, _("Addon"), vbox, GTK_STOCK_ADD);
}
static void
finish_setup (CEPageSecurity *page)
{
        NMConnection *connection = CE_PAGE (page)->connection;
        NMSettingWireless *sw;
        NMSettingWirelessSecurity *sws;
        gboolean is_adhoc = FALSE;
        GtkListStore *sec_model;
        GtkTreeIter iter;
        const gchar *mode;
        const gchar *security;
        guint32 dev_caps = 0;
        NMUtilsSecurityType default_type = NMU_SEC_NONE;
        int active = -1;
        int item = 0;
        GtkComboBox *combo;
        GtkCellRenderer *renderer;

        sw = nm_connection_get_setting_wireless (connection);
        g_assert (sw);

        page->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

        page->security_heading = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "heading_sec"));
        page->security_combo = combo = GTK_COMBO_BOX (gtk_builder_get_object (CE_PAGE (page)->builder, "combo_sec"));

        dev_caps =   NM_WIFI_DEVICE_CAP_CIPHER_WEP40
                   | NM_WIFI_DEVICE_CAP_CIPHER_WEP104
                   | NM_WIFI_DEVICE_CAP_CIPHER_TKIP
                   | NM_WIFI_DEVICE_CAP_CIPHER_CCMP
                   | NM_WIFI_DEVICE_CAP_WPA
                   | NM_WIFI_DEVICE_CAP_RSN;

        mode = nm_setting_wireless_get_mode (sw);
        if (mode && !strcmp (mode, "adhoc"))
                is_adhoc = TRUE;
        page->adhoc = is_adhoc;

        sws = nm_connection_get_setting_wireless_security (connection);
        security = nm_setting_wireless_get_security (sw);
        if (!security || strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) != 0)
                sws = NULL;
        if (sws)
                default_type = get_default_type_for_security (sws);

        sec_model = gtk_list_store_new (3, G_TYPE_STRING, wireless_security_get_g_type (), G_TYPE_BOOLEAN);

        if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
                gtk_list_store_insert_with_values (sec_model, &iter, -1,
                                                   S_NAME_COLUMN, C_("Wi-Fi/Ethernet security", "None"),
                                                   S_ADHOC_VALID_COLUMN, TRUE,
                                                   -1);
                if (default_type == NMU_SEC_NONE)
                        active = item;
                item++;
        }

        if (nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
                WirelessSecurityWEPKey *ws_wep;
                NMWepKeyType wep_type = NM_WEP_KEY_TYPE_KEY;

                if (default_type == NMU_SEC_STATIC_WEP) {
                        sws = nm_connection_get_setting_wireless_security (connection);
                        if (sws)
                                wep_type = nm_setting_wireless_security_get_wep_key_type (sws);
                        if (wep_type == NM_WEP_KEY_TYPE_UNKNOWN)
                                wep_type = NM_WEP_KEY_TYPE_KEY;
                }

                ws_wep = ws_wep_key_new (connection, NM_WEP_KEY_TYPE_KEY, FALSE, FALSE);
                if (ws_wep) {
                        add_security_item (page, WIRELESS_SECURITY (ws_wep), sec_model,
                                           &iter, _("WEP 40/128-bit Key (Hex or ASCII)"),
                                           TRUE);
                        if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_KEY))
                                active = item;
                        item++;
                }

                ws_wep = ws_wep_key_new (connection, NM_WEP_KEY_TYPE_PASSPHRASE, FALSE, FALSE);
                if (ws_wep) {
                        add_security_item (page, WIRELESS_SECURITY (ws_wep), sec_model,
                                           &iter, _("WEP 128-bit Passphrase"), TRUE);
                        if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE))
                                active = item;
                        item++;
                }
        }

        if (nm_utils_security_valid (NMU_SEC_LEAP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
                WirelessSecurityLEAP *ws_leap;

                ws_leap = ws_leap_new (connection, FALSE);
                if (ws_leap) {
                        add_security_item (page, WIRELESS_SECURITY (ws_leap), sec_model,
                                           &iter, _("LEAP"), FALSE);
                        if ((active < 0) && (default_type == NMU_SEC_LEAP))
                                active = item;
                        item++;
                }
        }

        if (nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
                WirelessSecurityDynamicWEP *ws_dynamic_wep;

                ws_dynamic_wep = ws_dynamic_wep_new (connection, TRUE, FALSE);
                if (ws_dynamic_wep) {
                        add_security_item (page, WIRELESS_SECURITY (ws_dynamic_wep), sec_model,
                                           &iter, _("Dynamic WEP (802.1x)"), FALSE);
                        if ((active < 0) && (default_type == NMU_SEC_DYNAMIC_WEP))
                                active = item;
                        item++;
                }
        }

        if (nm_utils_security_valid (NMU_SEC_WPA_PSK, dev_caps, FALSE, is_adhoc, 0, 0, 0) ||
            nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
                WirelessSecurityWPAPSK *ws_wpa_psk;

                ws_wpa_psk = ws_wpa_psk_new (connection, FALSE);
                if (ws_wpa_psk) {
                        add_security_item (page, WIRELESS_SECURITY (ws_wpa_psk), sec_model,
                                           &iter, _("WPA & WPA2 Personal"), FALSE);
                        if ((active < 0) && ((default_type == NMU_SEC_WPA_PSK) || (default_type == NMU_SEC_WPA2_PSK)))
                                active = item;
                        item++;
                }
        }

        if (nm_utils_security_valid (NMU_SEC_WPA_ENTERPRISE, dev_caps, FALSE, is_adhoc, 0, 0, 0) ||
            nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
                WirelessSecurityWPAEAP *ws_wpa_eap;

                ws_wpa_eap = ws_wpa_eap_new (connection, TRUE, FALSE);
                if (ws_wpa_eap) {
                        add_security_item (page, WIRELESS_SECURITY (ws_wpa_eap), sec_model,
                                           &iter, _("WPA & WPA2 Enterprise"), FALSE);
                        if ((active < 0) && ((default_type == NMU_SEC_WPA_ENTERPRISE) || (default_type == NMU_SEC_WPA2_ENTERPRISE)))
                                active = item;
                        item++;
                }
        }

        gtk_combo_box_set_model (combo, GTK_TREE_MODEL (sec_model));
        gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", S_NAME_COLUMN, NULL);
        gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer, set_sensitive, &page->adhoc, NULL);

        gtk_combo_box_set_active (combo, active < 0 ? 0 : (guint32) active);
        g_object_unref (G_OBJECT (sec_model));

        page->security_combo = combo;

        security_combo_changed (combo, page);
        g_signal_connect (combo, "changed",
                          G_CALLBACK (security_combo_changed), page);
}