void remmina_ftp_client_set_dir(RemminaFTPClient *client, const gchar *dir) { RemminaFTPClientPriv *priv = (RemminaFTPClientPriv*) client->priv; GtkTreeModel *model; GtkTreeIter iter; gboolean ret; gchar *t; if (priv->current_directory && g_strcmp0(priv->current_directory, dir) == 0) return; model = gtk_combo_box_get_model(GTK_COMBO_BOX(priv->directory_combo)); for (ret = gtk_tree_model_get_iter_first(model, &iter); ret; ret = gtk_tree_model_iter_next(model, &iter)) { gtk_tree_model_get(model, &iter, 0, &t, -1); if (g_strcmp0(t, dir) == 0) { gtk_list_store_remove(GTK_LIST_STORE(model), &iter); g_free(t); break; } g_free(t); } gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(priv->directory_combo), dir); gtk_combo_box_set_active(GTK_COMBO_BOX(priv->directory_combo), 0); g_free(priv->current_directory); priv->current_directory = g_strdup(dir); }
//if viewing or editing, this will to fill in the extra data void UnderGradAppPage::fillInData(Application* app,WindowApp *theApp) { theApp->uGradAppPage->edit = true; UndergradApp *editApp = dynamic_cast<UndergradApp*>(app); theApp->editUApp = editApp; gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(theApp->uGradAppPage->form->combo), (editApp->getCourse()).c_str()); gtk_combo_box_set_active(GTK_COMBO_BOX(theApp->uGradAppPage->form->combo),0); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->fName), (editApp->getStuFirst()).c_str()); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->lName), (editApp->getStuLast()).c_str()); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->email), (editApp->getStuEmail()).c_str()); int nu = editApp->getStuMGPA(); string mgpa = static_cast<ostringstream*>( &(ostringstream() << nu) )->str(); int ni = editApp->getStuCGPA(); string gpa = static_cast<ostringstream*>( &(ostringstream() << ni) )->str(); int yr = editApp->getStuYrStanding(); string year = static_cast<ostringstream*>( &(ostringstream() << yr) )->str(); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->cgpa), (gpa.c_str()) ); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->gpa), (mgpa.c_str()) ); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->major), (editApp->getStuMajor()).c_str()); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->year), (year.c_str())); gtk_entry_set_text(GTK_ENTRY(theApp->uGradAppPage->form->stuNum), (editApp->getStuID()).c_str()); UnderGradAppPage::fillInRelated(theApp); }
static VALUE rg_prepend_text(VALUE self, VALUE text) { gtk_combo_box_text_prepend_text(_SELF(self), RVAL2CSTR(text)); return self; }
void combo_box_prepend_text (gpointer p, const gchar *s) { #if GTK_MAJOR_VERSION >= 3 gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(p), s); #else gtk_combo_box_prepend_text(GTK_COMBO_BOX(p), s); #endif }
GtkWidget* remmina_public_create_combo_entry(const gchar *text, const gchar *def, gboolean descending) { GtkWidget *combo; gboolean found; gchar *buf, *ptr1, *ptr2; gint i; combo = gtk_combo_box_text_new_with_entry(); found = FALSE; if (text && text[0] != '\0') { buf = g_strdup(text); ptr1 = buf; i = 0; while (ptr1 && *ptr1 != '\0') { ptr2 = strchr(ptr1, STRING_DELIMITOR); if (ptr2) *ptr2++ = '\0'; if (descending) { gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(combo), ptr1); if (!found && g_strcmp0(ptr1, def) == 0) { gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); found = TRUE; } } else { gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), ptr1); if (!found && g_strcmp0(ptr1, def) == 0) { gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i); found = TRUE; } } ptr1 = ptr2; i++; } g_free(buf); } if (!found && def && def[0] != '\0') { gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), def); } return combo; }
static void _set_active_combo_item (GtkComboBox *combo, const char *item, const char *combo_item, int combo_idx) { GtkWidget *entry; if (item) { /* set active item */ gtk_combo_box_set_active (combo, combo_idx); if (!combo_item) gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (combo), item); entry = gtk_bin_get_child (GTK_BIN (combo)); if (entry) gtk_entry_set_text (GTK_ENTRY (entry), combo_item ? combo_item : item); } }
static void populate_ui (CEPageWired *self) { CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self); NMSettingWired *setting = priv->setting; const char *port; const char *duplex; int port_idx = PORT_DEFAULT; int speed_idx; int mtu_def; char **mac_list, **iter; const GByteArray *s_mac; char *s_mac_str; char *active_mac = NULL; GtkWidget *entry; /* Port */ port = nm_setting_wired_get_port (setting); if (port) { if (!strcmp (port, "tp")) port_idx = PORT_TP; else if (!strcmp (port, "aui")) port_idx = PORT_AUI; else if (!strcmp (port, "bnc")) port_idx = PORT_BNC; else if (!strcmp (port, "mii")) port_idx = PORT_MII; } gtk_combo_box_set_active (priv->port, port_idx); /* Speed */ switch (nm_setting_wired_get_speed (setting)) { case 10: speed_idx = SPEED_10; break; case 100: speed_idx = SPEED_100; break; case 1000: speed_idx = SPEED_1000; break; case 10000: speed_idx = SPEED_10000; break; default: speed_idx = SPEED_DEFAULT; break; } gtk_combo_box_set_active (priv->speed, speed_idx); /* Duplex */ duplex = nm_setting_wired_get_duplex (setting); if (duplex && !strcmp (duplex, "half")) gtk_toggle_button_set_active (priv->duplex, FALSE); else gtk_toggle_button_set_active (priv->duplex, TRUE); /* Autonegotiate */ gtk_toggle_button_set_active (priv->autonegotiate, nm_setting_wired_get_auto_negotiate (setting)); /* Device MAC address */ mac_list = ce_page_get_mac_list (CE_PAGE (self)); s_mac = nm_setting_wired_get_mac_address (setting); s_mac_str = s_mac ? g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", s_mac->data[0], s_mac->data[1], s_mac->data[2], s_mac->data[3], s_mac->data[4], s_mac->data[5]): NULL; for (iter = mac_list; iter && *iter; iter++) { #if GTK_CHECK_VERSION (2,24,0) gtk_combo_box_text_append_text (priv->device_mac, *iter); #else gtk_combo_box_append_text (GTK_COMBO_BOX (priv->device_mac), *iter); #endif if (s_mac_str && g_ascii_strncasecmp (*iter, s_mac_str, 17) == 0) active_mac = *iter; } if (s_mac_str) { if (!active_mac) { #if GTK_CHECK_VERSION (2,24,0) gtk_combo_box_text_prepend_text (priv->device_mac, s_mac_str); #else gtk_combo_box_prepend_text (GTK_COMBO_BOX (priv->device_mac), s_mac_str); #endif } entry = gtk_bin_get_child (GTK_BIN (priv->device_mac)); if (entry) gtk_entry_set_text (GTK_ENTRY (entry), active_mac ? active_mac : s_mac_str); } g_strfreev (mac_list); g_signal_connect (priv->device_mac, "changed", G_CALLBACK (stuff_changed), self); /* Cloned MAC address */ ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (setting), priv->cloned_mac); g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self); /* MTU */ mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU); g_signal_connect (priv->mtu, "output", G_CALLBACK (ce_spin_output_with_default), GINT_TO_POINTER (mtu_def)); gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting)); }
GtkWidget * entry_create_widget (GtkWidget * dlg) { GtkWidget *c, *l = NULL, *w = NULL; #if !GTK_CHECK_VERSION(3,0,0) w = gtk_hbox_new (FALSE, 5); #else w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); #endif if (options.entry_data.entry_label) { l = gtk_label_new (NULL); if (options.data.no_markup) gtk_label_set_text_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label); else gtk_label_set_markup_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label); gtk_widget_set_name (l, "yad-entry-label"); gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 1); } if (options.entry_data.numeric) { gdouble min, max, step, val; guint prec; min = 0.0; max = 65535.0; step = 1.0; prec = 0; if (options.extra_data && options.extra_data[0]) { min = g_ascii_strtod (options.extra_data[0], NULL); if (options.extra_data[1]) max = g_ascii_strtod (options.extra_data[1], NULL); if (options.extra_data[2]) step = g_ascii_strtod (options.extra_data[2], NULL); if (options.extra_data[3]) { prec = (guint) g_ascii_strtoull (options.extra_data[3], NULL, 0); if (prec > 20) prec = 20; } } c = entry = gtk_spin_button_new_with_range (min, max, step); gtk_entry_set_alignment (GTK_ENTRY (c), 1.0); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c), prec); gtk_widget_set_name (entry, "yad-entry-spin"); if (options.entry_data.entry_text) { val = g_ascii_strtod (options.entry_data.entry_text, NULL); if (min >= max) { g_printerr (_("Maximum value must be greater than minimum value.\n")); min = 0.0; max = 65535.0; } if (val < min) { g_printerr (_("Initial value less than minimal.\n")); val = min; } else if (val > max) { g_printerr (_("Initial value greater than maximum.\n")); val = max; } gtk_spin_button_set_value (GTK_SPIN_BUTTON (c), val); } } else if (!options.entry_data.completion && options.extra_data && *options.extra_data) { gint active, i; if (options.common_data.editable || settings.combo_always_editable) { #if GTK_CHECK_VERSION(2,24,0) c = gtk_combo_box_text_new_with_entry (); #else c = gtk_combo_box_entry_new_text (); #endif gtk_widget_set_name (c, "yad-entry-edit-combo"); entry = gtk_bin_get_child (GTK_BIN (c)); if (options.entry_data.licon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb); } if (options.entry_data.ricon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb); } } else { #if GTK_CHECK_VERSION(2,24,0) c = entry = gtk_combo_box_text_new (); #else c = entry = gtk_combo_box_new_text (); #endif gtk_widget_set_name (c, "yad-entry-combo"); is_combo = TRUE; } i = 0; active = -1; while (options.extra_data[i] != NULL) { if (options.entry_data.entry_text && g_ascii_strcasecmp (options.extra_data[i], options.entry_data.entry_text) == 0) active = i; #if GTK_CHECK_VERSION(2,24,0) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (c), options.extra_data[i]); #else gtk_combo_box_append_text (GTK_COMBO_BOX (c), options.extra_data[i]); #endif i++; } if (options.entry_data.entry_text && active == -1) { #if GTK_CHECK_VERSION(2,24,0) gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (c), options.entry_data.entry_text); #else gtk_combo_box_prepend_text (GTK_COMBO_BOX (c), options.entry_data.entry_text); #endif } /* set first iter active */ if (!options.common_data.editable) gtk_combo_box_set_active (GTK_COMBO_BOX (c), (active != -1 ? active : 0)); } else { c = entry = gtk_entry_new (); gtk_widget_set_name (c, "yad-entry-widget"); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); if (options.entry_data.entry_text) gtk_entry_set_text (GTK_ENTRY (entry), options.entry_data.entry_text); if (options.entry_data.hide_text) g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); if (options.entry_data.completion) { GtkEntryCompletion *completion; GtkTreeModel *completion_model; completion = gtk_entry_completion_new (); gtk_entry_set_completion (GTK_ENTRY (entry), completion); completion_model = create_completion_model (); gtk_entry_completion_set_model (completion, completion_model); g_object_unref (completion_model); gtk_entry_completion_set_text_column (completion, 0); g_object_unref (completion); } if (options.entry_data.licon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb); } if (options.entry_data.ricon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb); } } if (l) gtk_label_set_mnemonic_widget (GTK_LABEL (l), entry); if (!is_combo) g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (entry_activate_cb), dlg); else g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK (combo_activate_cb), dlg); if (options.entry_data.licon || options.entry_data.ricon) g_signal_connect (G_OBJECT (entry), "icon-press", G_CALLBACK (icon_cb), NULL); gtk_box_pack_start (GTK_BOX (w), c, TRUE, TRUE, 1); return w; }
void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { GtkBuilder *builder = NULL; GtkWidget *dialog; GtkWidget *button; GObject *text; GSList *entries = NULL; GSList *tmp; GObject *vbox; builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } gtk_builder_connect_signals (builder, NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_entry_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } text = gtk_builder_get_object (builder, "zenity_entry_text"); if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); vbox = gtk_builder_get_object (builder, "vbox4"); zenity_entry_fill_entries(&entries, entry_data->data); n_entries = g_slist_length (entries); if (n_entries > 1) { entry = gtk_combo_box_text_new_with_entry (); for (tmp = entries; tmp; tmp = tmp->next) { gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); } if (entry_data->entry_text) { gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); } g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate", G_CALLBACK (zenity_entry_combo_activate_default), GTK_WINDOW (dialog)); } else { entry = gtk_entry_new(); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); if (entry_data->hide_text) g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); } gtk_widget_show (entry); gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); g_object_unref (builder); zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); }
void matedialog_entry (MateDialogData *data, MateDialogEntryData *entry_data) { GtkBuilder *builder = NULL; GtkWidget *dialog; GObject *text; GSList *entries = NULL; GSList *tmp; GObject *vbox; builder = matedialog_util_load_ui_file ("matedialog_entry_dialog", NULL); if (builder == NULL) { data->exit_code = matedialog_util_return_exit_code (MATEDIALOG_ERROR); return; } gtk_builder_connect_signals (builder, NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "matedialog_entry_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (matedialog_entry_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); matedialog_util_set_window_icon (dialog, data->window_icon, MATEDIALOG_IMAGE_FULLPATH ("matedialog-entry.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = gtk_builder_get_object (builder, "matedialog_entry_text"); if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); vbox = gtk_builder_get_object (builder, "vbox4"); matedialog_entry_fill_entries(&entries, entry_data->data); n_entries = g_slist_length (entries); if (n_entries > 1) { #if GTK_CHECK_VERSION(2,24,0) entry = gtk_combo_box_text_new_with_entry (); #else entry = gtk_combo_box_entry_new_text (); #endif for (tmp = entries; tmp; tmp = tmp->next) { #if GTK_CHECK_VERSION(2,24,0) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); #else gtk_combo_box_append_text (GTK_COMBO_BOX (entry), tmp->data); #endif } if (entry_data->entry_text) { #if GTK_CHECK_VERSION(2,24,0) gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); #else gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); #endif gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); } g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate", G_CALLBACK (matedialog_entry_combo_activate_default), GTK_WINDOW (dialog)); } else { entry = gtk_entry_new(); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); if (entry_data->hide_text) g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); } gtk_widget_show (entry); gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); g_object_unref (builder); matedialog_util_show_dialog (dialog); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) matedialog_util_timeout_handle, NULL); } gtk_main (); }