static void item_new_dialog (GeditCollaborationWindowHelper *helper, gboolean newfile) { GtkWidget *dialog; ItemNew *item; GtkTreeIter iter; GtkTreeIter selected; InfcBrowser *browser; InfcBrowserIter *node; GtkWidget *label; GtkWidget *entry; GtkWidget *hbox; if (!inf_gtk_browser_view_get_selected (INF_GTK_BROWSER_VIEW (helper->priv->browser_view), &selected)) { return; } gtk_tree_model_sort_convert_iter_to_child_iter ( GTK_TREE_MODEL_SORT ( gtk_tree_view_get_model ( GTK_TREE_VIEW (helper->priv->browser_view) ) ), &iter, &selected ); dialog = gtk_dialog_new_with_buttons (newfile ? _("New File") : _("New Folder"), GTK_WINDOW (helper->priv->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (newfile ? _("File _name:") : _("Folder _name:")); gtk_widget_show (label); entry = gtk_entry_new (); gtk_widget_show (entry); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, FALSE, 0); gtk_tree_model_get (GTK_TREE_MODEL (helper->priv->browser_store), &iter, INF_GTK_BROWSER_MODEL_COL_BROWSER, &browser, INF_GTK_BROWSER_MODEL_COL_NODE, &node, -1); item = g_slice_new (ItemNew); item->helper = helper; item->iter = *node; item->browser = browser; item->newfile = newfile; item->entry = GTK_ENTRY (entry); infc_browser_iter_free (node); g_signal_connect (dialog, "response", G_CALLBACK (on_item_new_response), item); gtk_widget_show (dialog); }
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; }
static void photos_properties_dialog_constructed (GObject *object) { PhotosPropertiesDialog *self = PHOTOS_PROPERTIES_DIALOG (object); PhotosPropertiesDialogPrivate *priv = self->priv; GDateTime *date_modified; GtkStyleContext *context; GtkWidget *author_w = NULL; GtkWidget *content_area; GtkWidget *date_created_w = NULL; GtkWidget *date_modified_data; GtkWidget *date_modified_w; GtkWidget *exposure_time_w = NULL; GtkWidget *flash_w = NULL; GtkWidget *fnumber_w = NULL; GtkWidget *focal_length_w = NULL; GtkWidget *height_w = NULL; GtkWidget *iso_speed_w = NULL; GtkWidget *item_type; GtkWidget *item_type_data; GtkWidget *source; GtkWidget *source_data; GtkWidget *title; GtkWidget *width_w = NULL; GQuark equipment; GQuark flash; PhotosBaseItem *item; const gchar *author; const gchar *name; const gchar *type_description; gchar *date_created_str = NULL; gchar *date_modified_str; gdouble exposure_time; gdouble fnumber; gdouble focal_length; gdouble iso_speed; gint64 ctime; gint64 height; gint64 mtime; gint64 width; G_OBJECT_CLASS (photos_properties_dialog_parent_class)->constructed (object); item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, priv->urn)); mtime = photos_base_item_get_mtime (item); date_modified = g_date_time_new_from_unix_local (mtime); date_modified_str = g_date_time_format (date_modified, "%c"); g_date_time_unref (date_modified); ctime = photos_base_item_get_date_created (item); if (ctime != -1) { GDateTime *date_created; date_created = g_date_time_new_from_unix_local (ctime); date_created_str = g_date_time_format (date_created, "%c"); g_date_time_unref (date_created); } priv->grid = gtk_grid_new (); gtk_widget_set_halign (priv->grid, GTK_ALIGN_CENTER); gtk_widget_set_margin_start (priv->grid, 24); gtk_widget_set_margin_end (priv->grid, 24); gtk_widget_set_margin_bottom (priv->grid, 12); gtk_widget_set_margin_top (priv->grid, 12); gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->grid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_column_homogeneous (GTK_GRID (priv->grid), TRUE); gtk_grid_set_column_spacing (GTK_GRID (priv->grid), 24); gtk_grid_set_row_homogeneous (GTK_GRID (priv->grid), TRUE); gtk_grid_set_row_spacing (GTK_GRID (priv->grid), 6); content_area = gtk_dialog_get_content_area (GTK_DIALOG (self)); gtk_box_pack_start (GTK_BOX (content_area), priv->grid, TRUE, TRUE, 2); /* Translators: this is the label next to the photo title in the * properties dialog */ title = gtk_label_new (C_("Document Title", "Title")); gtk_widget_set_halign (title, GTK_ALIGN_END); context = gtk_widget_get_style_context (title); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), title); author = photos_base_item_get_author (item); if (author != NULL && author[0] != '\0') { /* Translators: this is the label next to the photo author in * the properties dialog */ author_w = gtk_label_new (C_("Document Author", "Author")); gtk_widget_set_halign (author_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (author_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), author_w); } source = gtk_label_new (_("Source")); gtk_widget_set_halign (source, GTK_ALIGN_END); context = gtk_widget_get_style_context (source); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), source); date_modified_w = gtk_label_new (_("Date Modified")); gtk_widget_set_halign (date_modified_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (date_modified_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), date_modified_w); if (date_created_str != NULL) { date_created_w = gtk_label_new (_("Date Created")); gtk_widget_set_halign (date_created_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (date_created_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), date_created_w); } /* Translators: this is the label next to the photo type in the * properties dialog */ item_type = gtk_label_new (C_("Document Type", "Type")); gtk_widget_set_halign (item_type, GTK_ALIGN_END); context = gtk_widget_get_style_context (item_type); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), item_type); width = photos_base_item_get_width (item); if (width > 0) { width_w = gtk_label_new (_("Width")); gtk_widget_set_halign (width_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (width_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), width_w); } height = photos_base_item_get_height (item); if (height > 0) { height_w = gtk_label_new (_("Height")); gtk_widget_set_halign (height_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (height_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), height_w); } equipment = photos_base_item_get_equipment (item); photos_camera_cache_get_camera_async (priv->camera_cache, equipment, priv->cancellable, photos_properties_dialog_get_camera, self); if (equipment != 0) { priv->camera_w = gtk_label_new (_("Camera")); gtk_widget_set_halign (priv->camera_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (priv->camera_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), priv->camera_w); } exposure_time = photos_base_item_get_exposure_time (item); if (exposure_time > 0.0) { exposure_time_w = gtk_label_new (_("Exposure")); gtk_widget_set_halign (exposure_time_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (exposure_time_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), exposure_time_w); } fnumber = photos_base_item_get_fnumber (item); if (fnumber > 0.0) { fnumber_w = gtk_label_new (_("Aperture")); gtk_widget_set_halign (fnumber_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (fnumber_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), fnumber_w); } focal_length = photos_base_item_get_focal_length (item); if (focal_length > 0.0) { focal_length_w = gtk_label_new (_("Focal Length")); gtk_widget_set_halign (focal_length_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (focal_length_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), focal_length_w); } iso_speed = photos_base_item_get_iso_speed (item); if (iso_speed > 0.0) { iso_speed_w = gtk_label_new (_("ISO Speed")); gtk_widget_set_halign (iso_speed_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (iso_speed_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), iso_speed_w); } flash = photos_base_item_get_flash (item); if (flash != 0) { flash_w = gtk_label_new (_("Flash")); gtk_widget_set_halign (flash_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (flash_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), flash_w); } name = photos_base_item_get_name (item); if (PHOTOS_IS_LOCAL_ITEM (item)) { priv->title_entry = gtk_entry_new (); gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START); gtk_widget_set_hexpand (priv->title_entry, TRUE); gtk_entry_set_activates_default (GTK_ENTRY (priv->title_entry), TRUE); gtk_entry_set_text (GTK_ENTRY (priv->title_entry), name); gtk_entry_set_width_chars (GTK_ENTRY (priv->title_entry), 40); gtk_editable_set_editable (GTK_EDITABLE (priv->title_entry), TRUE); g_signal_connect (priv->title_entry, "changed", G_CALLBACK (photos_properties_dialog_title_entry_changed), self); } else { priv->title_entry = gtk_label_new (name); gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START); } gtk_grid_attach_next_to (GTK_GRID (priv->grid), priv->title_entry, title, GTK_POS_RIGHT, 2, 1); if (author_w != NULL) { GtkWidget *author_data; author_data = gtk_label_new (author); gtk_widget_set_halign (author_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), author_data, author_w, GTK_POS_RIGHT, 2, 1); } if (PHOTOS_IS_FACEBOOK_ITEM (item)) { const gchar *source_name; source_name = photos_base_item_get_source_name (item); source_data = gtk_link_button_new_with_label ("https://www.facebook.com/", source_name); gtk_widget_set_halign (source_data, GTK_ALIGN_START); } else if (PHOTOS_IS_FLICKR_ITEM (item)) { const gchar *source_name; source_name = photos_base_item_get_source_name (item); source_data = gtk_link_button_new_with_label ("https://www.flickr.com/", source_name); gtk_widget_set_halign (source_data, GTK_ALIGN_START); } else /* local item */ { if (photos_base_item_is_collection (item)) { const gchar *source_name; source_name = photos_base_item_get_source_name (item); source_data = gtk_label_new (source_name); gtk_widget_set_halign (source_data, GTK_ALIGN_START); } else { GFile *file; GFile *source_link; GtkWidget *label; const gchar *uri; gchar *source_path; gchar *source_uri; uri = photos_base_item_get_uri (item); file = g_file_new_for_uri (uri); source_link = g_file_get_parent (file); source_path = g_file_get_path (source_link); source_uri = g_file_get_uri (source_link); source_data = gtk_link_button_new_with_label (source_uri, source_path); gtk_widget_set_halign (source_data, GTK_ALIGN_START); label = gtk_bin_get_child (GTK_BIN (source_data)); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); g_object_unref (source_link); g_object_unref (file); } } gtk_grid_attach_next_to (GTK_GRID (priv->grid), source_data, source, GTK_POS_RIGHT, 2, 1); date_modified_data = gtk_label_new (date_modified_str); gtk_widget_set_halign (date_modified_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), date_modified_data, date_modified_w, GTK_POS_RIGHT, 2, 1); if (date_created_w != NULL) { GtkWidget *date_created_data; date_created_data = gtk_label_new (date_created_str); gtk_widget_set_halign (date_created_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), date_created_data, date_created_w, GTK_POS_RIGHT, 2, 1); } type_description = photos_base_item_get_type_description (item); item_type_data = gtk_label_new (type_description); gtk_widget_set_halign (item_type_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), item_type_data, item_type, GTK_POS_RIGHT, 2, 1); if (width_w != NULL) { GtkWidget *width_data; gchar *width_str; width_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", width); width_data = gtk_label_new (width_str); gtk_widget_set_halign (width_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), width_data, width_w, GTK_POS_RIGHT, 2, 1); g_free (width_str); } if (height_w != NULL) { GtkWidget *height_data; gchar *height_str; height_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", height); height_data = gtk_label_new (height_str); gtk_widget_set_halign (height_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), height_data, height_w, GTK_POS_RIGHT, 2, 1); g_free (height_str); } if (exposure_time_w != NULL) { GtkWidget *exposure_time_data; gchar *exposure_time_str; exposure_time_str = g_strdup_printf ("%.3lf sec", exposure_time); exposure_time_data = gtk_label_new (exposure_time_str); gtk_widget_set_halign (exposure_time_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), exposure_time_data, exposure_time_w, GTK_POS_RIGHT, 2, 1); g_free (exposure_time_str); } if (fnumber_w != NULL) { GtkWidget *fnumber_data; gchar *fnumber_str; fnumber_str = g_strdup_printf ("f/%.1lf", fnumber); fnumber_data = gtk_label_new (fnumber_str); gtk_widget_set_halign (fnumber_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), fnumber_data, fnumber_w, GTK_POS_RIGHT, 2, 1); g_free (fnumber_str); } if (focal_length_w != NULL) { GtkWidget *focal_length_data; gchar *focal_length_str; focal_length_str = g_strdup_printf ("%.0lf mm", focal_length); focal_length_data = gtk_label_new (focal_length_str); gtk_widget_set_halign (focal_length_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), focal_length_data, focal_length_w, GTK_POS_RIGHT, 2, 1); g_free (focal_length_str); } if (iso_speed_w != NULL) { GtkWidget *iso_speed_data; gchar *iso_speed_str; iso_speed_str = g_strdup_printf ("%.0lf", iso_speed); iso_speed_data = gtk_label_new (iso_speed_str); gtk_widget_set_halign (iso_speed_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), iso_speed_data, iso_speed_w, GTK_POS_RIGHT, 2, 1); g_free (iso_speed_str); } if (flash_w != NULL) { GtkWidget *flash_data; gchar *flash_str; if (flash == PHOTOS_FLASH_OFF) flash_str = g_strdup (_("Off, did not fire")); else if (flash == PHOTOS_FLASH_ON) flash_str = g_strdup (_("On, fired")); else g_assert_not_reached (); flash_data = gtk_label_new (flash_str); gtk_widget_set_halign (flash_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), flash_data, flash_w, GTK_POS_RIGHT, 2, 1); g_free (flash_str); } g_free (date_created_str); g_free (date_modified_str); }
static void thunar_sbr_number_renamer_init (ThunarSbrNumberRenamer *number_renamer) { AtkRelationSet *relations; AtkRelation *relation; GEnumClass *klass; AtkObject *object; GtkWidget *combo; GtkWidget *entry; GtkWidget *label; GtkWidget *hbox; guint n; hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (number_renamer), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("_Number Format:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); combo = gtk_combo_box_new_text (); klass = g_type_class_ref (THUNAR_SBR_TYPE_NUMBER_MODE); for (n = 0; n < klass->n_values; ++n) gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick)); exo_mutual_binding_new (G_OBJECT (number_renamer), "mode", G_OBJECT (combo), "active"); gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); g_type_class_unref (klass); gtk_widget_show (combo); /* set Atk label relation for the combo */ object = gtk_widget_get_accessible (combo); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); number_renamer->start_entry = gtk_entry_new (); gtk_entry_set_max_length (GTK_ENTRY (number_renamer->start_entry), 4); gtk_entry_set_width_chars (GTK_ENTRY (number_renamer->start_entry), 3); gtk_entry_set_alignment (GTK_ENTRY (number_renamer->start_entry), 1.0f); gtk_entry_set_activates_default (GTK_ENTRY (number_renamer->start_entry), TRUE); exo_mutual_binding_new (G_OBJECT (number_renamer->start_entry), "text", G_OBJECT (number_renamer), "start"); gtk_box_pack_end (GTK_BOX (hbox), number_renamer->start_entry, TRUE, TRUE, 0); gtk_widget_show (number_renamer->start_entry); label = gtk_label_new_with_mnemonic (_("_Start With:")); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (label), number_renamer->start_entry); gtk_widget_show (label); /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (number_renamer->start_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_end (GTK_BOX (number_renamer), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Text _Format:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); combo = gtk_combo_box_new_text (); klass = g_type_class_ref (THUNAR_SBR_TYPE_TEXT_MODE); for (n = 0; n < klass->n_values; ++n) gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick)); exo_mutual_binding_new (G_OBJECT (number_renamer), "text-mode", G_OBJECT (combo), "active"); gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); g_type_class_unref (klass); gtk_widget_show (combo); /* set Atk label relation for the combo */ object = gtk_widget_get_accessible (combo); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); entry = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (entry), 4); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); exo_mutual_binding_new (G_OBJECT (entry), "text", G_OBJECT (number_renamer), "text"); gtk_box_pack_end (GTK_BOX (hbox), entry, TRUE, TRUE, 0); gtk_widget_show (entry); label = gtk_label_new_with_mnemonic (_("_Text:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); gtk_widget_show (label); /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); }
/*! \brief Create the slot entry dialog * \par Function Description * This function creates the slot edit dialog. */ void slot_edit_dialog (GschemToplevel *w_current, const char *count, const char *string) { GtkWidget *label[2]; GtkWidget *table; GtkWidget *vbox; GtkWidget *widget[2]; if (!w_current->sewindow) { w_current->sewindow = gschem_dialog_new_with_buttons(_("Edit slot number"), GTK_WINDOW(w_current->main_window), GTK_DIALOG_MODAL, "slot-edit", w_current, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); /* Set the alternative button order (ok, cancel, help) for other systems */ gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->sewindow), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_REJECT, -1); gtk_window_set_position (GTK_WINDOW (w_current->sewindow), GTK_WIN_POS_MOUSE); gtk_dialog_set_default_response (GTK_DIALOG (w_current->sewindow), GTK_RESPONSE_ACCEPT); g_signal_connect (G_OBJECT (w_current->sewindow), "response", G_CALLBACK (slot_edit_dialog_response), w_current); gtk_container_set_border_width (GTK_CONTAINER (w_current->sewindow), DIALOG_BORDER_SPACING); vbox = GTK_DIALOG(w_current->sewindow)->vbox; gtk_box_set_spacing(GTK_BOX(vbox), DIALOG_V_SPACING); label[0] = gschem_dialog_misc_create_property_label (_("Number of Slots:")); label[1] = gschem_dialog_misc_create_property_label (_("Slot Number:")); widget[0] = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(widget[0]), 80); gtk_editable_set_editable (GTK_EDITABLE(widget[0]), FALSE); gtk_widget_set_sensitive (GTK_WIDGET(widget[0]), FALSE); widget[1] = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(widget[1]), 80); gtk_entry_set_activates_default (GTK_ENTRY(widget[1]),TRUE); table = gschem_dialog_misc_create_property_table(label, widget, 2); gtk_box_pack_start (GTK_BOX (vbox), /* box */ table, /* child */ FALSE, /* expand */ FALSE, /* fill */ 0); /* padding */ GLADE_HOOKUP_OBJECT(w_current->sewindow, widget[0], "countentry"); GLADE_HOOKUP_OBJECT(w_current->sewindow, widget[1], "textentry"); gtk_widget_show_all (w_current->sewindow); } else { /* dialog already created */ gtk_window_present (GTK_WINDOW(w_current->sewindow)); } if (count != NULL) { widget[0] = GTK_WIDGET (g_object_get_data (G_OBJECT (w_current->sewindow), "countentry")); gtk_entry_set_text(GTK_ENTRY(widget[0]), count); } /* always set the current text and select the number of the slot */ if (string != NULL) { widget[1] = GTK_WIDGET (g_object_get_data (G_OBJECT (w_current->sewindow), "textentry")); gtk_entry_set_text(GTK_ENTRY(widget[1]), string); gtk_editable_select_region (GTK_EDITABLE(widget[1]), 0, -1); } }
static void ugtk_download_form_init_page1 (UgtkDownloadForm* dform, UgtkProxyForm* proxy) { GtkWidget* widget; GtkGrid* top_grid; GtkGrid* grid; GtkWidget* frame; GtkBox* top_vbox; GtkWidget* vbox; GtkWidget* hbox; dform->page1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); top_vbox = (GtkBox*) dform->page1; gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 2); top_grid = (GtkGrid*) gtk_grid_new (); gtk_box_pack_start (top_vbox, (GtkWidget*) top_grid, FALSE, FALSE, 0); // URL - entry widget = gtk_entry_new (); // gtk_entry_set_width_chars (GTK_ENTRY (widget), 20); // remove for GTK+ 3.12 gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin-left", 1, "margin-right", 1, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); g_object_set (widget, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 0, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_uri_entry_changed), dform); dform->uri_entry = widget; // URL - label widget = gtk_label_new_with_mnemonic (_("_URI:")); gtk_label_set_mnemonic_widget (GTK_LABEL(widget), dform->uri_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (top_grid, widget, 0, 0, 1, 1); dform->uri_label = widget; // Mirrors - entry widget = gtk_entry_new (); // gtk_entry_set_width_chars (GTK_ENTRY (widget), 20); // remove for GTK+ 3.12 gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin-left", 1, "margin-right", 1, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); g_object_set (widget, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 1, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_uri_entry_changed), dform); dform->mirrors_entry = widget; // Mirrors - label widget = gtk_label_new_with_mnemonic (_("Mirrors:")); gtk_label_set_mnemonic_widget (GTK_LABEL(widget), dform->mirrors_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (top_grid, widget, 0, 1, 1, 1); dform->mirrors_label = widget; // File - entry widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 2, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); dform->file_entry = widget; // File - label widget = gtk_label_new_with_mnemonic (_("File:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->file_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (top_grid, widget, 0, 2, 1, 1); dform->file_label = widget; // Folder - combo entry + icon dform->folder_combo = gtk_combo_box_text_new_with_entry (); dform->folder_entry = gtk_bin_get_child (GTK_BIN (dform->folder_combo)); widget = dform->folder_entry; gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); #if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 10 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, "folder"); #else gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIRECTORY); #endif gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, _("Select Folder")); g_object_set (dform->folder_combo, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, dform->folder_combo, 1, 3, 1, 1); g_signal_connect (widget, "icon-release", G_CALLBACK (on_select_folder), dform); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); // Folder - label widget = gtk_label_new_with_mnemonic (_("_Folder:")); gtk_label_set_mnemonic_widget(GTK_LABEL (widget), dform->folder_combo); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (top_grid, widget, 0, 3, 1, 1); // Referrer - entry widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 4, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->referrer_entry = widget; // Referrer - label widget = gtk_label_new_with_mnemonic (_("Referrer:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->referrer_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (top_grid, widget, 0, 4, 1, 1); // dform->referrer_label = widget; // ---------------------------------------------------- // Connections // HBox for Connections hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (top_vbox, hbox, FALSE, FALSE, 2); // connections - label // widget = gtk_label_new (_("connections")); // gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 2); // dform->label_connections = widget; // connections - spin button widget = gtk_spin_button_new_with_range (1.0, 16.0, 1.0); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); // gtk_entry_set_width_chars (GTK_ENTRY (widget), 3); // remove for GTK+ 3.12 gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 2); dform->spin_connections = widget; // "Max Connections:" - title label widget = gtk_label_new_with_mnemonic (_("_Max Connections:")); gtk_label_set_mnemonic_widget ((GtkLabel*)widget, dform->spin_connections); gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 2); dform->title_connections = widget; // ---------------------------------------------------- // HBox for "Status" and "Login" hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (top_vbox, hbox, FALSE, FALSE, 2); // ---------------------------------------------------- // frame for Status (start mode) frame = gtk_frame_new (_("Status")); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); dform->radio_runnable = gtk_radio_button_new_with_mnemonic (NULL, _("_Runnable")); dform->radio_pause = gtk_radio_button_new_with_mnemonic_from_widget ( (GtkRadioButton*)dform->radio_runnable, _("P_ause")); gtk_box_pack_start (GTK_BOX (vbox), dform->radio_runnable, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), dform->radio_pause, FALSE, FALSE, 0); // ---------------------------------------------------- // frame for login frame = gtk_frame_new (_("Login")); grid = (GtkGrid*) gtk_grid_new (); gtk_container_set_border_width (GTK_CONTAINER (grid), 2); gtk_container_add (GTK_CONTAINER (frame), (GtkWidget*) grid); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 2); // User - entry widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 0, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); dform->username_entry = widget; // User - label widget = gtk_label_new (_("User:"******"margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); // dform->username_label = widget; // Password - entry widget = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 1, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); dform->password_entry = widget; // Password - label widget = gtk_label_new (_("Password:"******"margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); // dform->password_label = widget; // ---------------------------------------------------- // proxy // ug_proxy_widget_init (&dform->proxy_dform); if (proxy) { widget = proxy->self; gtk_box_pack_start (top_vbox, widget, FALSE, FALSE, 2); } }
void gm_audio_profiles_edit_new_profile (GMAudioProfilesEdit *dialog, GtkWindow *transient_parent) { GtkWindow *old_transient_parent; GtkWidget *create_button; gint response; GError *error = NULL; if (dialog->priv->new_profile_dialog == NULL) { GtkBuilder *builder; GtkWidget *w, *wl; GtkWidget *create_button; GtkSizeGroup *size_group, *size_group_labels; builder = gmp_util_load_builder_file ("mate-audio-profile-new.ui", transient_parent, &error); if (error != NULL) { g_warning (error->message); g_error_free (error); return; } dialog->priv->new_profile_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-dialog")); g_signal_connect (G_OBJECT (dialog->priv->new_profile_dialog), "response", G_CALLBACK (new_profile_response_callback), dialog); g_object_add_weak_pointer (G_OBJECT (dialog->priv->new_profile_dialog), (void**) &dialog->priv->new_profile_dialog); create_button = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-create-button")); g_object_set_data (G_OBJECT (dialog->priv->new_profile_dialog), "create_button", create_button); gtk_widget_set_sensitive (create_button, FALSE); size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /* the name entry */ w = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-name-entry")); g_object_set_data (G_OBJECT (dialog->priv->new_profile_dialog), "name_entry", w); g_signal_connect (G_OBJECT (w), "changed", G_CALLBACK (new_profile_name_entry_changed_callback), create_button); gtk_entry_set_activates_default (GTK_ENTRY (w), TRUE); gtk_widget_grab_focus (w); // FIXME terminal_util_set_atk_name_description (w, _("Enter profile name"), NULL); gtk_size_group_add_widget (size_group, w); wl = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-name-label")); gtk_label_set_mnemonic_widget (GTK_LABEL (wl), w); // FIXME terminal_util_set_labelled_by (w, GTK_LABEL (wl)); gtk_size_group_add_widget (size_group_labels, wl); #ifdef BASE /* the base profile option menu */ w = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-base-option-menu")); g_object_set_data (G_OBJECT (dialog->priv->new_profile_dialog), "base_option_menu", w); // FIXME terminal_util_set_atk_name_description (w, _("Choose base profile"), NULL); //FIXME profile_optionmenu_refill (w); gtk_size_group_add_widget (size_group, w); wl = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-base-label")); gtk_label_set_mnemonic_widget (GTK_LABEL (wl), w); // FIXME terminal_util_set_labelled_by (w, GTK_LABEL (wl)); gtk_size_group_add_widget (size_group_labels, wl); #endif gtk_window_set_transient_for (GTK_WINDOW (dialog->priv->new_profile_dialog), transient_parent); /* gtk_dialog_set_default_response (GTK_DIALOG (dialog->priv->new_profile_dialog), GTK_RESPONSE_CREATE); */ g_object_unref (G_OBJECT (size_group)); g_object_unref (G_OBJECT (size_group_labels)); g_object_unref (G_OBJECT (builder)); } old_transient_parent = gtk_window_get_transient_for (GTK_WINDOW (dialog->priv->new_profile_dialog)); if (old_transient_parent != transient_parent) { gtk_window_set_transient_for (GTK_WINDOW (dialog->priv->new_profile_dialog), transient_parent); gtk_widget_hide (dialog->priv->new_profile_dialog); /* re-show the window on its new parent */ } create_button = g_object_get_data (G_OBJECT (dialog->priv->new_profile_dialog), "create_button"); gtk_widget_set_sensitive (create_button, FALSE); gtk_window_set_modal (GTK_WINDOW (dialog->priv->new_profile_dialog), TRUE); gtk_widget_show_all (dialog->priv->new_profile_dialog); gtk_window_present (GTK_WINDOW (dialog->priv->new_profile_dialog)); //keep running the dialog until the response is GTK_RESPONSE_NONE do { response = gtk_dialog_run (GTK_DIALOG (dialog->priv->new_profile_dialog)); } while (response != GTK_RESPONSE_NONE); }
static void contact_widget_contact_setup (EmpathyContactWidget *information) { /* Setup label_status as a KludgeLabel */ information->label_status = empathy_kludge_label_new (""); gtk_label_set_line_wrap_mode (GTK_LABEL (information->label_status), PANGO_WRAP_WORD_CHAR); gtk_label_set_line_wrap (GTK_LABEL (information->label_status), TRUE); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) gtk_label_set_selectable (GTK_LABEL (information->label_status), TRUE); gtk_box_pack_start (GTK_BOX (information->hbox_presence), information->label_status, TRUE, TRUE, 0); gtk_widget_show (information->label_status); /* Setup account label/chooser */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { information->widget_account = empathy_account_chooser_new (); g_signal_connect_swapped (information->widget_account, "changed", G_CALLBACK (contact_widget_change_contact), information); } else { /* Pack the protocol icon with the account name in an hbox */ information->widget_account = gtk_hbox_new (FALSE, 6); information->label_account = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->label_account), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->label_account), 0, 0.5); gtk_widget_show (information->label_account); information->image_account = gtk_image_new (); gtk_widget_show (information->image_account); gtk_box_pack_start (GTK_BOX (information->widget_account), information->image_account, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (information->widget_account), information->label_account, FALSE, TRUE, 0); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_account, 1, 2, 0, 1); gtk_widget_show (information->widget_account); /* Set up avatar chooser/display */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) { information->widget_avatar = empathy_avatar_chooser_new (); g_signal_connect (information->widget_avatar, "changed", G_CALLBACK (contact_widget_avatar_changed_cb), information); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { g_signal_connect (information->widget_account, "changed", G_CALLBACK (update_avatar_chooser_account_cb), information->widget_avatar); update_avatar_chooser_account_cb ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), EMPATHY_AVATAR_CHOOSER (information->widget_avatar)); } } else { information->widget_avatar = empathy_avatar_image_new (); g_signal_connect (information->widget_avatar, "popup-menu", G_CALLBACK (widget_avatar_popup_menu_cb), information); g_signal_connect (information->widget_avatar, "button-press-event", G_CALLBACK (widget_avatar_button_press_event_cb), information); } gtk_box_pack_start (GTK_BOX (information->vbox_avatar), information->widget_avatar, FALSE, FALSE, 6); gtk_widget_show (information->widget_avatar); /* Setup id label/entry */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { information->widget_id = gtk_entry_new (); g_signal_connect (information->widget_id, "focus-out-event", G_CALLBACK (contact_widget_id_focus_out_cb), information); g_signal_connect (information->widget_id, "changed", G_CALLBACK (contact_widget_id_changed_cb), information); } else { information->widget_id = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_id, 1, 2, 1, 2); gtk_widget_show (information->widget_id); /* Setup alias label/entry */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS) { information->widget_alias = gtk_entry_new (); if (!(information->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS)) g_signal_connect (information->widget_alias, "focus-out-event", G_CALLBACK (contact_widget_entry_alias_focus_event_cb), information); /* Make return activate the window default (the Close button) */ gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias), TRUE); } else { information->widget_alias = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_alias, 1, 2, 2, 3); if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) { gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE); } gtk_widget_show (information->widget_alias); #if HAVE_FAVOURITE_CONTACTS /* Favorite */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE) { information->favourite_checkbox = gtk_check_button_new_with_label ( _("Favorite")); g_signal_connect (information->favourite_checkbox, "toggled", G_CALLBACK (favourite_toggled_cb), information); gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->favourite_checkbox, 0, 2, 3, 4); information->fav_sig_id = g_signal_connect (information->manager, "favourites-changed", G_CALLBACK (contact_widget_favourites_changed_cb), information); gtk_widget_show (information->favourite_checkbox); } #endif }
gint run_dialog_search(GtkWidget *textview, gint mode) { GtkWidget *dialog; GtkWidget *table; GtkWidget *label_find, *label_replace; GtkWidget *entry_find, *entry_replace = NULL; GtkWidget *check_case, *check_all; gint res; if (mode) dialog = gtk_dialog_new_with_buttons(_("Replace"), GTK_WINDOW(gtk_widget_get_toplevel(textview)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_FIND_AND_REPLACE, GTK_RESPONSE_OK, NULL); else dialog = gtk_dialog_new_with_buttons(_("Find"), GTK_WINDOW(gtk_widget_get_toplevel(textview)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); table = gtk_table_new(mode + 2, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 8); gtk_table_set_col_spacings(GTK_TABLE(table), 8); gtk_container_set_border_width(GTK_CONTAINER(table), 8); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, FALSE, FALSE, 0); label_find = gtk_label_new_with_mnemonic(_("Fi_nd what:")); gtk_misc_set_alignment(GTK_MISC(label_find), 0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label_find, 0, 1, 0, 1); entry_find = gtk_entry_new(); gtk_table_attach_defaults(GTK_TABLE(table), entry_find, 1, 2, 0, 1); gtk_label_set_mnemonic_widget(GTK_LABEL(label_find), entry_find); gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, FALSE); entry_len = 0; g_signal_connect(G_OBJECT(entry_find), "insert-text", G_CALLBACK(toggle_sensitivity), NULL); g_signal_connect(G_OBJECT(entry_find), "delete-text", G_CALLBACK(toggle_sensitivity), NULL); if (string_find) { gtk_entry_set_text(GTK_ENTRY(entry_find), string_find); gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, TRUE); } if (mode) { label_replace = gtk_label_new_with_mnemonic(_("Re_place with:")); gtk_misc_set_alignment(GTK_MISC(label_replace), 0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label_replace, 0, 1, 1, 2); entry_replace = gtk_entry_new(); gtk_table_attach_defaults(GTK_TABLE(table), entry_replace, 1, 2, 1, 2); gtk_label_set_mnemonic_widget(GTK_LABEL(label_replace), entry_replace); if (string_replace) gtk_entry_set_text(GTK_ENTRY(entry_replace), string_replace); } gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gtk_entry_set_activates_default(GTK_ENTRY(entry_find), TRUE); if (mode) gtk_entry_set_activates_default(GTK_ENTRY(entry_replace), TRUE); check_case = gtk_check_button_new_with_mnemonic(_("_Match case")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_case), match_case); g_signal_connect(GTK_OBJECT(check_case), "toggled", G_CALLBACK(toggle_check_case), NULL); gtk_table_attach_defaults (GTK_TABLE(table), check_case, 0, 2, 1 + mode, 2 + mode); if (mode) { check_all = gtk_check_button_new_with_mnemonic(_("Replace _all at once")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_all), replace_all); g_signal_connect(GTK_OBJECT(check_all), "toggled", G_CALLBACK(toggle_check_all), NULL); gtk_table_attach_defaults(GTK_TABLE(table), check_all, 0, 2, 2 + mode, 3 + mode); } gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_widget_show_all(table); res = gtk_dialog_run(GTK_DIALOG(dialog)); if (res == GTK_RESPONSE_OK) { g_free(string_find); string_find = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_find))); if (mode) { g_free(string_replace); string_replace = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_replace))); } } gtk_widget_destroy(dialog); if (res == GTK_RESPONSE_OK) { if (strlen(string_find)) { if (mode) document_replace_real(textview); else document_search_real(textview, 0); } } return res; }
static void ep_ask_password (EPassMsg *msg) { GtkWidget *widget; GtkWidget *container; GtkWidget *action_area; GtkWidget *content_area; gint type = msg->flags & E_PASSWORDS_REMEMBER_MASK; guint noreply = msg->noreply; gboolean visible; AtkObject *a11y; msg->noreply = 1; widget = gtk_dialog_new_with_buttons ( msg->title, msg->parent, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response ( GTK_DIALOG (widget), GTK_RESPONSE_OK); gtk_window_set_resizable (GTK_WINDOW (widget), FALSE); gtk_window_set_transient_for (GTK_WINDOW (widget), msg->parent); gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_CENTER_ON_PARENT); gtk_container_set_border_width (GTK_CONTAINER (widget), 12); password_dialog = GTK_DIALOG (widget); action_area = gtk_dialog_get_action_area (password_dialog); content_area = gtk_dialog_get_content_area (password_dialog); /* Override GtkDialog defaults */ gtk_box_set_spacing (GTK_BOX (action_area), 12); gtk_container_set_border_width (GTK_CONTAINER (action_area), 0); gtk_box_set_spacing (GTK_BOX (content_area), 12); gtk_container_set_border_width (GTK_CONTAINER (content_area), 0); /* Table */ container = gtk_table_new (2, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (container), 12); gtk_table_set_row_spacings (GTK_TABLE (container), 6); gtk_table_set_row_spacing (GTK_TABLE (container), 0, 12); gtk_table_set_row_spacing (GTK_TABLE (container), 1, 0); gtk_widget_show (container); gtk_box_pack_start ( GTK_BOX (content_area), container, FALSE, TRUE, 0); /* Password Image */ widget = gtk_image_new_from_icon_name ( "dialog-password", GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0); gtk_widget_show (widget); gtk_table_attach ( GTK_TABLE (container), widget, 0, 1, 0, 3, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); /* Password Label */ widget = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); gtk_label_set_markup (GTK_LABEL (widget), msg->prompt); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); gtk_widget_show (widget); gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); /* Password Entry */ widget = gtk_entry_new (); a11y = gtk_widget_get_accessible (widget); visible = !(msg->flags & E_PASSWORDS_SECRET); atk_object_set_description (a11y, msg->prompt); gtk_entry_set_visibility (GTK_ENTRY (widget), visible); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_widget_grab_focus (widget); gtk_widget_show (widget); msg->entry = widget; if ((msg->flags & E_PASSWORDS_REPROMPT)) { ep_get_password (msg); if (msg->password != NULL) { gtk_entry_set_text (GTK_ENTRY (widget), msg->password); g_free (msg->password); msg->password = NULL; } } gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); /* Caps Lock Label */ widget = gtk_label_new (NULL); gtk_widget_show (widget); gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect ( password_dialog, "key-release-event", G_CALLBACK (update_capslock_state), widget); g_signal_connect ( password_dialog, "focus-in-event", G_CALLBACK (update_capslock_state), widget); /* static password, shouldn't be remembered between sessions, * but will be remembered within the session beyond our control */ if (type != E_PASSWORDS_REMEMBER_NEVER) { if (msg->flags & E_PASSWORDS_PASSPHRASE) { widget = gtk_check_button_new_with_mnemonic ( (type == E_PASSWORDS_REMEMBER_FOREVER) ? _("_Remember this passphrase") : _("_Remember this passphrase for" " the remainder of this session")); } else { widget = gtk_check_button_new_with_mnemonic ( (type == E_PASSWORDS_REMEMBER_FOREVER) ? _("_Remember this password") : _("_Remember this password for" " the remainder of this session")); } gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (widget), *msg->remember); if (msg->flags & E_PASSWORDS_DISABLE_REMEMBER) gtk_widget_set_sensitive (widget, FALSE); gtk_widget_show (widget); msg->check = widget; gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); } msg->noreply = noreply; g_signal_connect ( password_dialog, "response", G_CALLBACK (pass_response), msg); if (msg->parent) { gtk_dialog_run (GTK_DIALOG (password_dialog)); } else { gtk_window_present (GTK_WINDOW (password_dialog)); /* workaround GTK+ bug (see Gnome's bugzilla bug #624229) */ gtk_grab_add (GTK_WIDGET (password_dialog)); } }
static void create_bistable_properties_dialog (bistable_properties_D *dialog) { if (NULL != dialog->bistable_properties_dialog) return ; dialog->bistable_properties_dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog->bistable_properties_dialog), _("Bistable Options")); gtk_window_set_resizable (GTK_WINDOW (dialog->bistable_properties_dialog), FALSE); gtk_window_set_modal (GTK_WINDOW (dialog->bistable_properties_dialog), TRUE) ; dialog->dialog_vbox1 = GTK_DIALOG (dialog->bistable_properties_dialog)->vbox; gtk_widget_show (dialog->dialog_vbox1); dialog->table = gtk_table_new (7, 2, FALSE); gtk_widget_show (dialog->table); gtk_container_set_border_width (GTK_CONTAINER (dialog->table), 2); gtk_box_pack_start (GTK_BOX (dialog->dialog_vbox1), dialog->table, TRUE, TRUE, 0); dialog->label1 = gtk_label_new (_("Number Of Samples:")); gtk_widget_show (dialog->label1); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label1, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label1), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label1), 1, 0.5); dialog->number_of_samples_entry = gtk_entry_new (); gtk_widget_show (dialog->number_of_samples_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->number_of_samples_entry, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->number_of_samples_entry), TRUE) ; dialog->label2 = gtk_label_new (_("Convergence Tolerance:")); gtk_widget_show (dialog->label2); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label2, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label2), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label2), 1, 0.5); dialog->convergence_tolerance_entry = gtk_entry_new (); gtk_widget_show (dialog->convergence_tolerance_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->convergence_tolerance_entry, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->convergence_tolerance_entry), TRUE) ; dialog->label3 = gtk_label_new (_("Radius of Effect [nm]:")); gtk_widget_show (dialog->label3); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label3, 0, 1, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label3), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label3), 1, 0.5); dialog->radius_of_effect_entry = gtk_entry_new (); gtk_widget_show (dialog->radius_of_effect_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->radius_of_effect_entry, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->radius_of_effect_entry), TRUE) ; dialog->label4 = gtk_label_new (_("Relative Permittivity:")); gtk_widget_show (dialog->label4); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label4, 0, 1, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label4), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label4), 1, 0.5); dialog->epsilonR_entry = gtk_entry_new (); gtk_widget_show (dialog->epsilonR_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->epsilonR_entry, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->epsilonR_entry), TRUE) ; dialog->label5 = gtk_label_new (_("Clock High:")); gtk_widget_show (dialog->label5); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label5, 0, 1, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label5), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label5), 1, 0.5); dialog->clock_high_entry = gtk_entry_new (); gtk_widget_show (dialog->clock_high_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->clock_high_entry, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->clock_high_entry), TRUE) ; dialog->label6 = gtk_label_new (_("Clock Low:")); gtk_widget_show (dialog->label6); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label6, 0, 1, 5, 6, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label6), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label6), 1, 0.5); dialog->clock_low_entry = gtk_entry_new (); gtk_widget_show (dialog->clock_low_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->clock_low_entry, 1, 2, 5, 6, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->clock_low_entry), TRUE) ; dialog->label6 = gtk_label_new (_("Clock Shift:")); gtk_widget_show (dialog->label6); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label6, 0, 1, 6, 7, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label6), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label6), 1, 0.5); dialog->clock_shift_entry = gtk_entry_new (); gtk_widget_show (dialog->clock_shift_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->clock_shift_entry, 1, 2, 6, 7, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->clock_shift_entry), TRUE) ; dialog->label6 = gtk_label_new (_("Clock Amplitude Factor:")); gtk_widget_show (dialog->label6); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label6, 0, 1, 7, 8, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label6), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label6), 1, 0.5); dialog->clock_amplitude_factor_entry = gtk_entry_new (); gtk_widget_show (dialog->clock_amplitude_factor_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->clock_amplitude_factor_entry, 1, 2, 7, 8, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->clock_amplitude_factor_entry), TRUE) ; dialog->label6 = gtk_label_new (_("Layer Separation:")); gtk_widget_show (dialog->label6); gtk_table_attach (GTK_TABLE (dialog->table), dialog->label6, 0, 1, 8, 9, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->label6), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->label6), 1, 0.5); dialog->layer_separation_entry = gtk_entry_new (); gtk_widget_show (dialog->layer_separation_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->layer_separation_entry, 1, 2, 8, 9, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->layer_separation_entry), TRUE) ; dialog->lblMaxIter = gtk_label_new (_("Maximum Iterations Per Sample:")); gtk_widget_show (dialog->lblMaxIter); gtk_table_attach (GTK_TABLE (dialog->table), dialog->lblMaxIter, 0, 1, 9, 10, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_label_set_justify (GTK_LABEL (dialog->lblMaxIter), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (dialog->lblMaxIter), 1, 0.5); dialog->max_iterations_per_sample_entry = gtk_entry_new (); gtk_widget_show (dialog->max_iterations_per_sample_entry); gtk_table_attach (GTK_TABLE (dialog->table), dialog->max_iterations_per_sample_entry, 1, 2, 9, 10, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_entry_set_activates_default (GTK_ENTRY (dialog->max_iterations_per_sample_entry), TRUE) ; dialog->chkRandomizeCells = gtk_check_button_new_with_label (_("Randomize Simulation Order")) ; gtk_widget_show (dialog->chkRandomizeCells) ; gtk_table_attach (GTK_TABLE (dialog->table), dialog->chkRandomizeCells, 0, 2, 11, 12, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); dialog->chkAnimate = gtk_check_button_new_with_label (_("Animate")) ; gtk_widget_show (dialog->chkAnimate) ; gtk_table_attach (GTK_TABLE (dialog->table), dialog->chkAnimate, 0, 2, 12, 13, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 2, 2); gtk_dialog_add_button (GTK_DIALOG (dialog->bistable_properties_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL) ; gtk_dialog_add_button (GTK_DIALOG (dialog->bistable_properties_dialog), GTK_STOCK_OK, GTK_RESPONSE_OK) ; gtk_dialog_set_default_response (GTK_DIALOG (dialog->bistable_properties_dialog), GTK_RESPONSE_OK) ; }
static void create_dialog_find_tag(void) { GtkWidget *label, *vbox, *ebox, *entry; GtkSizeGroup *size_group; if (s_ft_dialog.widget) return; s_ft_dialog.widget = gtk_dialog_new_with_buttons( _("Find Tag"), GTK_WINDOW(geany->main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_dialog_add_button(GTK_DIALOG(s_ft_dialog.widget), "gtk-find", GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response(GTK_DIALOG(s_ft_dialog.widget), GTK_RESPONSE_ACCEPT); vbox = ui_dialog_vbox_new(GTK_DIALOG(s_ft_dialog.widget)); gtk_box_set_spacing(GTK_BOX(vbox), 9); size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); label = gtk_label_new(_("Search for:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_size_group_add_widget(size_group, label); s_ft_dialog.combo = gtk_combo_box_text_new_with_entry(); entry = gtk_bin_get_child(GTK_BIN(s_ft_dialog.combo)); ui_entry_add_clear_icon(GTK_ENTRY(entry)); gtk_entry_set_width_chars(GTK_ENTRY(entry), 40); gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); ui_entry_add_clear_icon(GTK_ENTRY(entry)); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); ebox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ebox), s_ft_dialog.combo, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0); label = gtk_label_new(_("Match type:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_size_group_add_widget(size_group, label); s_ft_dialog.combo_match = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(s_ft_dialog.combo_match), "exact"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(s_ft_dialog.combo_match), "prefix"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(s_ft_dialog.combo_match), "pattern"); gtk_combo_box_set_active(GTK_COMBO_BOX(s_ft_dialog.combo_match), 1); gtk_label_set_mnemonic_widget(GTK_LABEL(label), s_ft_dialog.combo_match); ebox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ebox), s_ft_dialog.combo_match, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0); label = gtk_label_new(_("Search inside:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_size_group_add_widget(size_group, label); s_ft_dialog.dir_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(s_ft_dialog.dir_label), 0, 0.5); ebox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ebox), s_ft_dialog.dir_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0); s_ft_dialog.case_sensitive = gtk_check_button_new_with_mnemonic(_("C_ase sensitive")); gtk_button_set_focus_on_click(GTK_BUTTON(s_ft_dialog.case_sensitive), FALSE); s_ft_dialog.declaration = gtk_check_button_new_with_mnemonic(_("_Declaration")); gtk_button_set_focus_on_click(GTK_BUTTON(s_ft_dialog.declaration), FALSE); g_object_unref(G_OBJECT(size_group)); /* auto destroy the size group */ gtk_container_add(GTK_CONTAINER(vbox), s_ft_dialog.case_sensitive); gtk_container_add(GTK_CONTAINER(vbox), s_ft_dialog.declaration); gtk_widget_show_all(vbox); }
static gint show_dialog_find_file(gchar *path, gchar **pattern, gboolean *case_sensitive, gboolean *full_path) { gint res; GtkWidget *entry; gchar *selection; GtkSizeGroup *size_group; if (!s_fif_dialog.widget) { GtkWidget *label, *vbox, *ebox; s_fif_dialog.widget = gtk_dialog_new_with_buttons( _("Find File"), GTK_WINDOW(geany->main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_dialog_add_button(GTK_DIALOG(s_fif_dialog.widget), "gtk-find", GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response(GTK_DIALOG(s_fif_dialog.widget), GTK_RESPONSE_ACCEPT); vbox = ui_dialog_vbox_new(GTK_DIALOG(s_fif_dialog.widget)); gtk_box_set_spacing(GTK_BOX(vbox), 6); size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); label = gtk_label_new(_("Search for:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_size_group_add_widget(size_group, label); s_fif_dialog.combo = gtk_combo_box_text_new_with_entry(); entry = gtk_bin_get_child(GTK_BIN(s_fif_dialog.combo)); gtk_entry_set_width_chars(GTK_ENTRY(entry), 40); gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); ui_entry_add_clear_icon(GTK_ENTRY(entry)); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); ebox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ebox), s_fif_dialog.combo, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0); label = gtk_label_new(_("Search inside:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_size_group_add_widget(size_group, label); s_fif_dialog.dir_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(s_fif_dialog.dir_label), 0, 0.5); ebox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ebox), s_fif_dialog.dir_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0); s_fif_dialog.case_sensitive = gtk_check_button_new_with_mnemonic(_("C_ase sensitive")); gtk_button_set_focus_on_click(GTK_BUTTON(s_fif_dialog.case_sensitive), FALSE); s_fif_dialog.full_path = gtk_check_button_new_with_mnemonic(_("Search in full path")); gtk_button_set_focus_on_click(GTK_BUTTON(s_fif_dialog.full_path), FALSE); gtk_box_pack_start(GTK_BOX(vbox), s_fif_dialog.case_sensitive, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), s_fif_dialog.full_path, TRUE, FALSE, 0); gtk_widget_show_all(vbox); } if (path) gtk_label_set_text(GTK_LABEL(s_fif_dialog.dir_label), path); else gtk_label_set_text(GTK_LABEL(s_fif_dialog.dir_label), _("project or external directory")); entry = gtk_bin_get_child(GTK_BIN(s_fif_dialog.combo)); selection = get_selection(); if (selection) gtk_entry_set_text(GTK_ENTRY(entry), selection); g_free(selection); gtk_widget_grab_focus(entry); res = gtk_dialog_run(GTK_DIALOG(s_fif_dialog.widget)); if (res == GTK_RESPONSE_ACCEPT) { const gchar *str; str = gtk_entry_get_text(GTK_ENTRY(entry)); *pattern = g_strconcat("*", str, "*", NULL); *case_sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(s_fif_dialog.case_sensitive)); *full_path = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(s_fif_dialog.full_path)); ui_combo_box_add_to_history(GTK_COMBO_BOX_TEXT(s_fif_dialog.combo), str, 0); } gtk_widget_hide(s_fif_dialog.widget); return res; }
static void xmi_msim_gui_layer_dialog_init(XmiMsimGuiLayerDialog *dialog) { gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Ok", GTK_RESPONSE_ACCEPT, "_Cancel", GTK_RESPONSE_REJECT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); gtk_window_set_default_size(GTK_WINDOW(dialog), 200, 200); GtkWidget *contentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); GtkWidget *mainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); gtk_box_set_homogeneous(GTK_BOX(mainVBox), FALSE); gtk_container_set_border_width(GTK_CONTAINER(mainVBox),5); gtk_container_add(GTK_CONTAINER(contentArea), mainVBox); GtkListStore *store = gtk_list_store_new(N_COLUMNS_LAYER, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INT); //construct tree GtkWidget *HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); GtkWidget *compositionTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_renderer_set_alignment(renderer, 0.5, 0.5); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Element", renderer, "text", SYMBOL_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_alignment(column, 0.5); gtk_tree_view_append_column(GTK_TREE_VIEW(compositionTreeView), column); renderer = gtk_cell_renderer_text_new(); gtk_cell_renderer_set_alignment(renderer, 0.5, 0.5); column = gtk_tree_view_column_new_with_attributes("Weight fraction (%)", renderer, "text", WEIGHT_COLUMN, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_alignment(column, 0.5); gtk_tree_view_append_column(GTK_TREE_VIEW(compositionTreeView), column); GtkWidget *scrolledWindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request(scrolledWindow, 220, 150); gtk_container_add(GTK_CONTAINER(scrolledWindow), compositionTreeView); GtkWidget *frame = gtk_frame_new(NULL); gtk_container_add(GTK_CONTAINER(frame), scrolledWindow); gtk_box_pack_start(GTK_BOX(HBox), frame, FALSE, FALSE, 3); //selections GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(compositionTreeView)); gtk_tree_selection_set_mode(select, GTK_SELECTION_MULTIPLE); g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(element_selection_changed), (gpointer) dialog); //add/edit/remove GtkWidget *VBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); gtk_box_set_homogeneous(GTK_BOX(VBox), FALSE); GtkWidget *addButton = gtk_button_new_with_mnemonic("_Add"); GtkWidget *editButton = gtk_button_new_with_mnemonic("_Edit"); GtkWidget *removeButton = gtk_button_new_with_mnemonic("_Remove"); GtkWidget *predefButton = gtk_button_new_with_label("Load from catalog"); GtkWidget *addToCatalogButton = gtk_button_new_with_label("Add to catalog"); gtk_widget_set_sensitive(addButton, TRUE); gtk_widget_set_sensitive(editButton, FALSE); gtk_widget_set_sensitive(removeButton, FALSE); gtk_widget_set_sensitive(predefButton, TRUE); gtk_widget_set_sensitive(addToCatalogButton, FALSE); gtk_box_pack_start(GTK_BOX(VBox), addButton, TRUE, FALSE, 3); gtk_box_pack_start(GTK_BOX(VBox), editButton, TRUE, FALSE, 3); gtk_box_pack_start(GTK_BOX(VBox), removeButton, TRUE, FALSE, 3); gtk_box_pack_start(GTK_BOX(VBox), predefButton, TRUE, FALSE, 3); gtk_box_pack_start(GTK_BOX(VBox), addToCatalogButton, TRUE, FALSE, 3); gtk_box_pack_start(GTK_BOX(HBox),VBox, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); g_signal_connect(G_OBJECT(addButton), "clicked", G_CALLBACK(add_button_clicked), (gpointer) dialog); g_signal_connect(G_OBJECT(editButton), "clicked", G_CALLBACK(edit_button_clicked), (gpointer) dialog); g_signal_connect(G_OBJECT(removeButton), "clicked", G_CALLBACK(remove_button_clicked), (gpointer) dialog); g_signal_connect(G_OBJECT(predefButton), "clicked", G_CALLBACK(predef_button_clicked), (gpointer) dialog); g_signal_connect(G_OBJECT(addToCatalogButton), "clicked", G_CALLBACK(add_to_catalog_button_clicked), (gpointer) dialog); g_signal_connect(G_OBJECT(compositionTreeView), "row-activated", G_CALLBACK(element_row_activated), (gpointer) dialog); //Sum and normalize HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); GtkWidget *label = gtk_label_new("Weights sum (%)"); GtkWidget *sumLabel = gtk_label_new(""); gtk_label_set_justify(GTK_LABEL(sumLabel), GTK_JUSTIFY_CENTER); GtkWidget *normalizeButton = gtk_button_new_with_label("Normalize"); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(HBox), sumLabel, TRUE, TRUE, 2); gtk_box_pack_start(GTK_BOX(HBox), normalizeButton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); g_signal_connect(G_OBJECT(normalizeButton), "clicked", G_CALLBACK(normalize_button_clicked), (gpointer) dialog); //separator GtkWidget *separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start(GTK_BOX(mainVBox), separator, FALSE, FALSE, 3); //Density and thickness HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label),"Density (g/cm<sup>3</sup>)"); GtkWidget *densityEntry = gtk_entry_new(); gtk_widget_set_name(densityEntry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(densityEntry), TRUE); gulong density_changed = g_signal_connect(G_OBJECT(densityEntry), "changed", G_CALLBACK(density_thickness_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), densityEntry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Thickness (cm)"); GtkWidget *thicknessEntry = gtk_entry_new(); gtk_widget_set_name(thicknessEntry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(thicknessEntry), TRUE); gulong thickness_changed = g_signal_connect(G_OBJECT(thicknessEntry), "changed", G_CALLBACK(density_thickness_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), thicknessEntry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); dialog->addButton = addButton; dialog->editButton = editButton; dialog->removeButton = removeButton; dialog->predefButton = predefButton; dialog->addToCatalogButton = addToCatalogButton; dialog->normalizeButton = normalizeButton; dialog->sumLabel = sumLabel; dialog->densityEntry = densityEntry; dialog->thicknessEntry = thicknessEntry; dialog->compositionTreeView = compositionTreeView; dialog->density_changed = density_changed; dialog->thickness_changed = thickness_changed; g_signal_connect(G_OBJECT(compositionTreeView), "key-press-event", G_CALLBACK(backspace_key_clicked), (gpointer) dialog); gtk_widget_show_all(contentArea); }
static void thunar_sbr_insert_renamer_init (ThunarSbrInsertRenamer *insert_renamer) { AtkRelationSet *relations; GtkAdjustment *adjustment; AtkRelation *relation; GEnumClass *klass; AtkObject *object; GtkWidget *spinner; GtkWidget *combo; GtkWidget *entry; GtkWidget *label; GtkWidget *table; GtkWidget *hbox; guint n; table = gtk_table_new (2, 3, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_box_pack_start (GTK_BOX (insert_renamer), table, TRUE, TRUE, 0); gtk_widget_show (table); combo = gtk_combo_box_text_new (); klass = g_type_class_ref (THUNAR_SBR_TYPE_INSERT_MODE); for (n = 0; n < klass->n_values; ++n) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _(klass->values[n].value_nick)); exo_mutual_binding_new (G_OBJECT (insert_renamer), "mode", G_OBJECT (combo), "active"); gtk_table_attach (GTK_TABLE (table), combo, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); g_type_class_unref (klass); gtk_widget_show (combo); label = gtk_label_new_with_mnemonic (_("_Text:")); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); gtk_widget_show (label); entry = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); exo_mutual_binding_new (G_OBJECT (entry), "text", G_OBJECT (insert_renamer), "text"); gtk_table_attach (GTK_TABLE (table), entry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); gtk_widget_show (entry); /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); label = gtk_label_new_with_mnemonic (_("_At position:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f); gtk_table_attach (GTK_TABLE (table), label, 0, 2, 1, 2, GTK_FILL, 0, 0, 0); gtk_widget_show (label); hbox = gtk_hbox_new (FALSE, 12); gtk_table_attach (GTK_TABLE (table), hbox, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); gtk_widget_show (hbox); spinner = gtk_spin_button_new_with_range (0u, G_MAXUINT, 1u); gtk_entry_set_width_chars (GTK_ENTRY (spinner), 4); gtk_entry_set_alignment (GTK_ENTRY (spinner), 1.0f); gtk_entry_set_activates_default (GTK_ENTRY (spinner), TRUE); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner), 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE); gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spinner), TRUE); gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner); gtk_widget_show (spinner); adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinner)); exo_mutual_binding_new (G_OBJECT (insert_renamer), "offset", G_OBJECT (adjustment), "value"); /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (spinner); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); combo = gtk_combo_box_text_new (); klass = g_type_class_ref (THUNAR_SBR_TYPE_OFFSET_MODE); for (n = 0; n < klass->n_values; ++n) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _(klass->values[n].value_nick)); exo_mutual_binding_new (G_OBJECT (insert_renamer), "offset-mode", G_OBJECT (combo), "active"); gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); g_type_class_unref (klass); gtk_widget_show (combo); }
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 (); }
static void ugtk_download_form_init_page2 (UgtkDownloadForm* dform) { GtkWidget* widget; GtkGrid* grid; dform->page2 = gtk_grid_new (); grid = (GtkGrid*) dform->page2; gtk_container_set_border_width (GTK_CONTAINER (grid), 2); // label - cookie file widget = gtk_label_new (_("Cookie file:")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); dform->cookie_label = widget; // entry - cookie file widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); #if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 10 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, "text-x-generic"); #else gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FILE); #endif gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, _("Select Cookie File")); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 0, 3, 1); g_signal_connect (widget, "icon-release", G_CALLBACK (on_select_cookie), dform); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->cookie_entry = widget; // label - post file widget = gtk_label_new (_("Post file:")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); dform->post_label = widget; // entry - post file widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); #if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 10 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, "text-x-generic"); #else gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FILE); #endif gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, _("Select Post File")); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 1, 3, 1); g_signal_connect (widget, "icon-release", G_CALLBACK (on_select_post), dform); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->post_entry = widget; // label - user agent widget = gtk_label_new (_("User Agent:")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 2, 1, 1); dform->agent_label = widget; // entry - user agent widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 2, 3, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->agent_entry = widget; // Retry limit - label widget = gtk_label_new_with_mnemonic (_("Retry _limit:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->spin_retry); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 3, 2, 1); // Retry limit - spin button widget = gtk_spin_button_new_with_range (0.0, 99.0, 1.0); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 2, 3, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_spin_changed), dform); dform->spin_retry = widget; // counts - label widget = gtk_label_new (_("counts")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 3, 3, 1, 1); // Retry delay - label widget = gtk_label_new_with_mnemonic (_("Retry _delay:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->spin_delay); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 4, 2, 1); // Retry delay - spin button widget = gtk_spin_button_new_with_range (0.0, 600.0, 1.0); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 2, 4, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_spin_changed), dform); dform->spin_delay = widget; // seconds - label widget = gtk_label_new (_("seconds")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 3, 4, 1, 1); // label - Max upload speed widget = gtk_label_new (_("Max upload speed:")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 5, 2, 1); // spin - Max upload speed widget = gtk_spin_button_new_with_range (0, 99999999, 1); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_entry_set_width_chars (GTK_ENTRY (widget), 8); g_object_set (widget, "margin", 1, NULL); gtk_grid_attach (grid, widget, 2, 5, 1, 1); dform->spin_upload_speed = (GtkSpinButton*) widget; // label - "KiB/s" widget = gtk_label_new (_("KiB/s")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 5, 1, 1); // label - Max download speed widget = gtk_label_new (_("Max download speed:")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 6, 2, 1); // spin - Max download speed widget = gtk_spin_button_new_with_range (0, 99999999, 1); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_entry_set_width_chars (GTK_ENTRY (widget), 8); g_object_set (widget, "margin", 1, NULL); gtk_grid_attach (grid, widget, 2, 6, 1, 1); dform->spin_download_speed = (GtkSpinButton*) widget; // label - "KiB/s" widget = gtk_label_new (_("KiB/s")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 6, 1, 1); // Retrieve timestamp widget = gtk_check_button_new_with_label (_("Retrieve timestamp")); gtk_grid_attach (grid, widget, 0, 7, 3, 1); dform->timestamp = (GtkToggleButton*) widget; }
void master_passphrase_change_dialog() { static PangoFontDescription *font_desc; GtkWidget *dialog; GtkWidget *vbox, *hbox; GtkWidget *icon, *table, *label; GtkWidget *msg_title; GtkWidget *entry_old, *entry_new1, *entry_new2; GtkWidget *confirm_area; GtkWidget *ok_button, *cancel_button; struct _ctx *ctx; dialog = gtk_dialog_new(); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_window_set_default_size(GTK_WINDOW(dialog), 375, 100); gtk_window_set_title(GTK_WINDOW(dialog), ""); MANAGE_WINDOW_SIGNALS_CONNECT(dialog); vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); gtk_box_set_spacing(GTK_BOX(vbox), 14); hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 12); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); gtk_widget_show(vbox); msg_title = gtk_label_new(_("Changing master passphrase")); gtk_misc_set_alignment(GTK_MISC(msg_title), 0, 0.5); gtk_label_set_justify(GTK_LABEL(msg_title), GTK_JUSTIFY_LEFT); gtk_label_set_use_markup (GTK_LABEL (msg_title), TRUE); gtk_box_pack_start(GTK_BOX(vbox), msg_title, FALSE, FALSE, 0); gtk_label_set_line_wrap(GTK_LABEL(msg_title), TRUE); if (!font_desc) { gint size; size = pango_font_description_get_size (gtk_widget_get_style(msg_title)->font_desc); font_desc = pango_font_description_new(); pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE); } if (font_desc) gtk_widget_modify_font(msg_title, font_desc); label = gtk_label_new( _("If a master passphrase is currently active, it\n" "needs to be entered.") ); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); table = gtk_table_new(4, 2, FALSE); /* Old passphrase */ label = gtk_label_new(_("Old passphrase:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); entry_old = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry_old), FALSE); gtk_table_attach(GTK_TABLE(table), entry_old, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); /* Separator */ gtk_table_attach(GTK_TABLE(table), gtk_hseparator_new(), 0, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 5); /* New passphrase */ label = gtk_label_new(_("New passphrase:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); entry_new1 = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry_new1), FALSE); gtk_table_attach(GTK_TABLE(table), entry_new1, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0); /* New passphrase again */ label = gtk_label_new(_("Confirm passphrase:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); entry_new2 = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry_new2), FALSE); gtk_table_attach(GTK_TABLE(table), entry_new2, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); /* Dialog buttons */ gtkut_stock_button_set_create(&confirm_area, &cancel_button, GTK_STOCK_CANCEL, &ok_button, GTK_STOCK_OK, NULL, NULL); gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), confirm_area, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(confirm_area), 5); gtk_widget_grab_default(ok_button); /* If no master passphrase is set, disable the "old passphrase" entry */ if (!master_passphrase_is_set()) gtk_widget_set_sensitive(entry_old, FALSE); g_signal_connect(G_OBJECT(entry_old), "activate", G_CALLBACK(entry_activated), entry_new1); g_signal_connect(G_OBJECT(entry_new1), "activate", G_CALLBACK(entry_activated), entry_new2); gtk_entry_set_activates_default(GTK_ENTRY(entry_new2), TRUE); ctx = g_new(struct _ctx, 1); ctx->done = FALSE; ctx->dialog = dialog; ctx->entry_old = entry_old; ctx->entry_new1 = entry_new1; ctx->entry_new2 = entry_new2; g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(ok_button_clicked), ctx); g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(cancel_button_clicked), ctx); g_signal_connect(G_OBJECT(dialog), "destroy", G_CALLBACK(dialog_destroy), ctx); gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(dialog))); gtk_window_present(GTK_WINDOW(dialog)); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); manage_window_set_transient(GTK_WINDOW(dialog)); while (!ctx->done) gtk_main_iteration(); if (ctx->dialog != NULL) gtk_widget_destroy(ctx->dialog); GTK_EVENTS_FLUSH(); g_free(ctx); }
int gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx) { if (!parentwin) { parentwin = mainwin; } // create window char title[200]; snprintf (title, sizeof (title), _("Configure %s"), conf->title); GtkWidget *win; if (!buttons) { win = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parentwin), GTK_DIALOG_MODAL, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (win), GTK_RESPONSE_OK); } else { win = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parentwin), GTK_DIALOG_MODAL, NULL); if (buttons & (1<<ddb_button_ok)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_OK, GTK_RESPONSE_OK); } if (buttons & (1<<ddb_button_cancel)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); } if (buttons & (1<<ddb_button_close)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); } if (buttons & (1<<ddb_button_apply)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY); } if (buttons & (1<<ddb_button_yes)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_YES, GTK_RESPONSE_YES); } if (buttons & (1<<ddb_button_no)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_NO, GTK_RESPONSE_NO); } } gtk_window_set_type_hint (GTK_WINDOW (win), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_container_set_border_width (GTK_CONTAINER(win), 12); gtk_window_set_title (GTK_WINDOW (win), title); gtk_window_set_modal (GTK_WINDOW (win), TRUE); gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parentwin)); GtkWidget *widgets[100] = {NULL}; int pack[100] = {0}; int ncurr = 0; widgets[ncurr] = gtk_dialog_get_content_area (GTK_DIALOG (win)); gtk_box_set_spacing (GTK_BOX (widgets[ncurr]), 8); GtkWidget *action_area = gtk_dialog_get_action_area (GTK_DIALOG (win)); gtk_widget_show (action_area); gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END); // parse script char token[MAX_TOKEN]; const char *script = conf->layout; parser_line = 1; while (script = gettoken (script, token)) { if (strcmp (token, "property")) { fprintf (stderr, "invalid token while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line); break; } char labeltext[MAX_TOKEN]; script = gettoken_warn_eof (script, labeltext); if (!script) { break; } if (ncurr > 0) { pack[ncurr]--; if (pack[ncurr] < 0) { ncurr--; } } char type[MAX_TOKEN]; script = gettoken_warn_eof (script, type); if (!script) { break; } if (!strncmp (type, "hbox[", 5) || !strncmp (type, "vbox[", 5)) { ncurr++; int n = 0; if (1 != sscanf (type+4, "[%d]", &n)) { break; } pack[ncurr] = n; int vert = 0; int hmg = FALSE; int fill = FALSE; int expand = FALSE; int border = 0; int spacing = 8; int height = 100; char param[MAX_TOKEN]; for (;;) { script = gettoken_warn_eof (script, param); if (!script) { break; } if (!strcmp (param, ";")) { break; } else if (!strcmp (param, "hmg")) { hmg = TRUE; } else if (!strcmp (param, "fill")) { fill = TRUE; } else if (!strcmp (param, "expand")) { expand = TRUE; } else if (!strncmp (param, "border=", 7)) { border = atoi (param+7); } else if (!strncmp (param, "spacing=", 8)) { spacing = atoi (param+8); } else if (!strncmp (param, "height=", 7)) { height = atoi (param+7); } } widgets[ncurr] = vert ? gtk_vbox_new (TRUE, spacing) : gtk_hbox_new (TRUE, spacing); gtk_widget_set_size_request (widgets[ncurr], -1, height); gtk_widget_show (widgets[ncurr]); gtk_box_pack_start (GTK_BOX(widgets[ncurr-1]), widgets[ncurr], fill, expand, border); continue; } int vertical = 0; char key[MAX_TOKEN]; for (;;) { script = gettoken_warn_eof (script, key); if (!script) { break; } if (!strcmp (key, "vert")) { vertical = 1; } else { break; } } char def[MAX_TOKEN]; script = gettoken_warn_eof (script, def); if (!script) { break; } // add to dialog GtkWidget *label = NULL; GtkWidget *prop = NULL; GtkWidget *cont = NULL; char value[1000]; conf->get_param (key, value, sizeof (value), def); if (!strcmp (type, "entry") || !strcmp (type, "password")) { label = gtk_label_new (_(labeltext)); gtk_widget_show (label); prop = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (prop), TRUE); g_signal_connect (G_OBJECT (prop), "changed", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); gtk_entry_set_text (GTK_ENTRY (prop), value); if (!strcmp (type, "password")) { gtk_entry_set_visibility (GTK_ENTRY (prop), FALSE); } } else if (!strcmp (type, "checkbox")) { prop = gtk_check_button_new_with_label (_(labeltext)); g_signal_connect (G_OBJECT (prop), "toggled", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); int val = atoi (value); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop), val); } else if (!strcmp (type, "file")) { label = gtk_label_new (_(labeltext)); gtk_widget_show (label); if (deadbeef->conf_get_int ("gtkui.pluginconf.use_filechooser_button", 0)) { prop = gtk_file_chooser_button_new (_(labeltext), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_widget_show (prop); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (prop), value); g_signal_connect (G_OBJECT (prop), "file-set", G_CALLBACK (prop_changed), win); } else { cont = gtk_hbox_new (FALSE, 2); gtk_widget_show (cont); prop = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (prop), TRUE); g_signal_connect (G_OBJECT (prop), "changed", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); gtk_editable_set_editable (GTK_EDITABLE (prop), FALSE); gtk_entry_set_text (GTK_ENTRY (prop), value); gtk_box_pack_start (GTK_BOX (cont), prop, TRUE, TRUE, 0); GtkWidget *btn = gtk_button_new_with_label ("…"); gtk_widget_show (btn); gtk_box_pack_start (GTK_BOX (cont), btn, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (btn), "clicked", G_CALLBACK (on_prop_browse_file), prop); } } else if (!strncmp (type, "select[", 7)) { int n; if (1 != sscanf (type+6, "[%d]", &n)) { break; } label = gtk_label_new (_(labeltext)); gtk_widget_show (label); prop = gtk_combo_box_text_new (); gtk_widget_show (prop); for (int i = 0; i < n; i++) { char entry[MAX_TOKEN]; script = gettoken_warn_eof (script, entry); if (!script) { break; } gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (prop), entry); } if (!script) { break; } gtk_combo_box_set_active (GTK_COMBO_BOX (prop), atoi (value)); g_signal_connect ((gpointer) prop, "changed", G_CALLBACK (prop_changed), win); } else if (!strncmp (type, "hscale[", 7) || !strncmp (type, "vscale[", 7) || !strncmp (type, "spinbtn[", 8)) { float min, max, step; const char *args; if (type[0] == 's') { args = type + 7; } else { args = type + 6; } if (3 != sscanf (args, "[%f,%f,%f]", &min, &max, &step)) { break; } int invert = 0; if (min >= max) { float tmp = min; min = max; max = tmp; invert = 1; } if (step <= 0) { step = 1; } if (type[0] == 's') { prop = gtk_spin_button_new_with_range (min, max, step); gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop), atof (value)); } else { prop = type[0] == 'h' ? gtk_hscale_new_with_range (min, max, step) : gtk_vscale_new_with_range (min, max, step); if (invert) { gtk_range_set_inverted (GTK_RANGE (prop), TRUE); } gtk_range_set_value (GTK_RANGE (prop), (gdouble)atof (value)); gtk_scale_set_value_pos (GTK_SCALE (prop), GTK_POS_RIGHT); } label = gtk_label_new (_(labeltext)); gtk_widget_show (label); g_signal_connect (G_OBJECT (prop), "value-changed", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); } script = gettoken_warn_eof (script, token); if (!script) { break; } if (strcmp (token, ";")) { fprintf (stderr, "expected `;' while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line); break; } if (label && prop) { GtkWidget *hbox = NULL; hbox = vertical ? gtk_vbox_new (FALSE, 8) : gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), cont ? cont : prop, TRUE, TRUE, 0); cont = hbox; } else { cont = prop; } if (prop) { g_object_set_data (G_OBJECT (win), key, prop); } if (cont) { gtk_box_pack_start (GTK_BOX (widgets[ncurr]), cont, FALSE, FALSE, 0); } } int response; do { gtk_dialog_set_response_sensitive (GTK_DIALOG (win), GTK_RESPONSE_APPLY, FALSE); response = gtk_dialog_run (GTK_DIALOG (win)); if (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK) { apply_conf (win, conf); } if (callback) { int btn = ddb_button_from_gtk_response (response); if (!callback (btn, ctx)) { break; } } } while (response == GTK_RESPONSE_APPLY); gtk_widget_destroy (win); int btn = ddb_button_from_gtk_response (response); return btn; }
static void xmi_msim_gui_continuous_energy_dialog_init(XmiMsimGuiContinuousEnergyDialog *dialog) { gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); // in order to have the scale parameter show and hide while automatically resizing the dialog gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Ok", GTK_RESPONSE_ACCEPT, "_Cancel", GTK_RESPONSE_REJECT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); gtk_window_set_default_size(GTK_WINDOW(dialog), 420, 300); GtkWidget *contentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); GtkWidget *mainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); gtk_box_set_homogeneous(GTK_BOX(mainVBox), FALSE); gtk_container_set_border_width(GTK_CONTAINER(mainVBox), 5); gtk_container_add(GTK_CONTAINER(contentArea), mainVBox); //Energy GtkWidget *HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); GtkWidget *label = gtk_label_new("Energy (keV)"); GtkWidget *energy_entry = gtk_entry_new(); gtk_widget_set_name(energy_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(energy_entry), TRUE); gulong energy_changed = g_signal_connect(G_OBJECT(energy_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), energy_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); //horizontal intensity HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Horizontally polarized intensity (ph/s/keV)"); GtkWidget *hor_intensity_entry = gtk_entry_new(); gtk_widget_set_name(hor_intensity_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(hor_intensity_entry), TRUE); gulong hor_intensity_changed = g_signal_connect(G_OBJECT(hor_intensity_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), hor_intensity_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); //vertical intensity HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Vertically polarized intensity (ph/s/keV)"); GtkWidget *ver_intensity_entry = gtk_entry_new(); gtk_widget_set_name(ver_intensity_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(ver_intensity_entry), TRUE); gulong ver_intensity_changed = g_signal_connect(G_OBJECT(ver_intensity_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), ver_intensity_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); //source size x HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Source size x (cm)"); GtkWidget *sigma_x_entry = gtk_entry_new(); gtk_widget_set_name(sigma_x_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(sigma_x_entry), TRUE); gulong sigma_x_changed = g_signal_connect(G_OBJECT(sigma_x_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), sigma_x_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); //source size y HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Source size y (cm)"); GtkWidget *sigma_y_entry = gtk_entry_new(); gtk_widget_set_name(sigma_y_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(sigma_y_entry), TRUE); gulong sigma_y_changed = g_signal_connect(G_OBJECT(sigma_y_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), sigma_y_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); //source divergence x HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Source divergence x (rad)"); GtkWidget *sigma_xp_entry = gtk_entry_new(); gtk_widget_set_name(sigma_xp_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(sigma_xp_entry), TRUE); gulong sigma_xp_changed = g_signal_connect(G_OBJECT(sigma_xp_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), sigma_xp_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); //source divergence y HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE); label = gtk_label_new("Source divergence y (rad)"); GtkWidget *sigma_yp_entry = gtk_entry_new(); gtk_widget_set_name(sigma_yp_entry, "color_entry"); gtk_entry_set_activates_default(GTK_ENTRY(sigma_yp_entry), TRUE); gulong sigma_yp_changed = g_signal_connect(G_OBJECT(sigma_yp_entry), "changed", G_CALLBACK(entry_value_changed), (gpointer) dialog); gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(HBox), sigma_yp_entry, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3); // assign instance variables dialog->energy_entry = energy_entry; dialog->hor_intensity_entry = hor_intensity_entry; dialog->ver_intensity_entry = ver_intensity_entry; dialog->sigma_x_entry = sigma_x_entry; dialog->sigma_y_entry = sigma_y_entry; dialog->sigma_xp_entry = sigma_xp_entry; dialog->sigma_yp_entry = sigma_yp_entry; dialog->energy_changed = energy_changed; dialog->hor_intensity_changed = hor_intensity_changed; dialog->ver_intensity_changed = ver_intensity_changed; dialog->sigma_x_changed = sigma_x_changed; dialog->sigma_y_changed = sigma_y_changed; dialog->sigma_xp_changed = sigma_xp_changed; dialog->sigma_yp_changed = sigma_yp_changed; gtk_widget_show_all(contentArea); }
ReplaceDialog::ReplaceDialog(int dummy) { Shortcuts shortcuts(0); extern Settings *settings; replacedialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(replacedialog), _("Replace")); gtk_window_set_position(GTK_WINDOW(replacedialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_modal(GTK_WINDOW(replacedialog), TRUE); gtk_window_set_destroy_with_parent(GTK_WINDOW(replacedialog), TRUE); dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG(replacedialog)); gtk_widget_show(dialog_vbox1); table1 = gtk_table_new(6, 2, FALSE); gtk_widget_show(table1); gtk_box_pack_start(GTK_BOX(dialog_vbox1), table1, TRUE, TRUE, 0); label7 = gtk_label_new(_("Search for")); gtk_widget_show(label7); gtk_table_attach(GTK_TABLE(table1), label7, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 4, 4); gtk_misc_set_alignment(GTK_MISC(label7), 1, 0.5); shortcuts.label(label7); label8 = gtk_label_new(_("Replace with")); gtk_widget_show(label8); gtk_table_attach(GTK_TABLE(table1), label8, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 4, 4); gtk_misc_set_alignment(GTK_MISC(label8), 1, 0.5); shortcuts.label(label8); entry2 = gtk_entry_new(); // Manually added code. gtk_entry_set_text(GTK_ENTRY(entry2), settings->session.searchword.c_str()); gtk_widget_show(entry2); gtk_table_attach(GTK_TABLE(table1), entry2, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 2); gtk_entry_set_activates_default(GTK_ENTRY(entry2), TRUE); entry3 = gtk_entry_new(); // Manually added code. gtk_entry_set_text(GTK_ENTRY(entry3), settings->session.replaceword.c_str()); gtk_widget_show(entry3); gtk_table_attach(GTK_TABLE(table1), entry3, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 2); gtk_entry_set_activates_default(GTK_ENTRY(entry3), TRUE); if (!settings->genconfig.text_editor_font_default_get()) { PangoFontDescription *font_desc = NULL; font_desc = pango_font_description_from_string(settings->genconfig.text_editor_font_name_get().c_str()); gtk_widget_modify_font(entry2, font_desc); gtk_widget_modify_font(entry3, font_desc); pango_font_description_free(font_desc); } checkbuttoncase = gtk_check_button_new_with_mnemonic(_("Case sensitive")); gtk_widget_show(checkbuttoncase); gtk_table_attach(GTK_TABLE(table1), checkbuttoncase, 0, 2, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); shortcuts.button(checkbuttoncase); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbuttoncase), settings->session.search_case_sensitive); checkbuttonbook = gtk_check_button_new_with_mnemonic(_("Current book only")); gtk_widget_show(checkbuttonbook); gtk_table_attach(GTK_TABLE(table1), checkbuttonbook, 0, 2, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); shortcuts.button(checkbuttonbook); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbuttonbook), settings->session.search_current_book); checkbuttonchapter = gtk_check_button_new_with_mnemonic(_("Current chapter only")); gtk_widget_show(checkbuttonchapter); gtk_table_attach(GTK_TABLE(table1), checkbuttonchapter, 0, 2, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); shortcuts.button(checkbuttonchapter); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbuttonchapter), settings->session.search_current_chapter); selectbutton = gtk_button_new(); gtk_widget_show(selectbutton); gtk_table_attach(GTK_TABLE(table1), selectbutton, 0, 1, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment1); gtk_container_add(GTK_CONTAINER(selectbutton), alignment1); hbox1 = gtk_hbox_new(FALSE, 2); gtk_widget_show(hbox1); gtk_container_add(GTK_CONTAINER(alignment1), hbox1); image1 = gtk_image_new_from_stock("gtk-properties", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image1); gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0); label9 = gtk_label_new_with_mnemonic(_("Select books")); gtk_widget_show(label9); gtk_box_pack_start(GTK_BOX(hbox1), label9, FALSE, FALSE, 0); shortcuts.label(label9); dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG(replacedialog)); gtk_widget_show(dialog_action_area1); gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END); new InDialogHelp(replacedialog, NULL, &shortcuts, NULL); buttonfind = gtk_button_new_from_stock("gtk-find"); gtk_widget_show(buttonfind); gtk_dialog_add_action_widget(GTK_DIALOG(replacedialog), buttonfind, GTK_RESPONSE_OK); gtk_widget_set_can_default (GTK_WIDGET (buttonfind), true); buttoncancel = gtk_button_new_from_stock("gtk-cancel"); gtk_widget_show(buttoncancel); gtk_dialog_add_action_widget(GTK_DIALOG(replacedialog), buttoncancel, GTK_RESPONSE_CANCEL); gtk_widget_set_can_default (GTK_WIDGET (buttoncancel), true); shortcuts.stockbutton(buttonfind); shortcuts.stockbutton(buttoncancel); shortcuts.process(); g_signal_connect((gpointer) checkbuttonbook, "toggled", G_CALLBACK(on_checkbuttonbook_toggled), gpointer(this)); g_signal_connect((gpointer) checkbuttonchapter, "toggled", G_CALLBACK(on_checkbuttonchapter_toggled), gpointer(this)); g_signal_connect((gpointer) selectbutton, "clicked", G_CALLBACK(on_selectbutton_clicked), gpointer(this)); g_signal_connect((gpointer) buttonfind, "clicked", G_CALLBACK(replacedialog_on_buttonfind_clicked), gpointer(this)); g_signal_connect((gpointer) entry2, "changed", G_CALLBACK(on_word_entry_changed), gpointer(this)); gtk_label_set_mnemonic_widget(GTK_LABEL(label7), entry2); gtk_label_set_mnemonic_widget(GTK_LABEL(label8), entry3); gtk_widget_grab_focus(entry2); gtk_widget_grab_default(buttonfind); // Select books feature. selectable_books = project_get_books(settings->genconfig.project_get()); // Entry completion completion_setup(entry2, cpSearch); completion_setup(entry3, cpReplace); set_gui(); }
GtkWidget * file_open_location_dialog_new (Gimp *gimp) { GimpContext *context; GtkWidget *dialog; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *image; GtkWidget *label; GtkWidget *entry; GtkEntryCompletion *completion; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); dialog = gimp_dialog_new (_("Open Location"), "gimp-file-open-location", NULL, 0, gimp_standard_help_func, GIMP_HELP_FILE_OPEN_LOCATION, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); g_signal_connect (dialog, "response", G_CALLBACK (file_open_location_response), gimp); gtk_dialog_set_alternative_button_order (GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); image = gtk_image_new_from_icon_name (GIMP_STOCK_WEB, GTK_ICON_SIZE_BUTTON); gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0); gtk_widget_show (image); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); label = gtk_label_new (_("Enter location (URI):")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); /* we don't want the context to affect the entry, so create * a scratch one instead of using e.g. the user context */ context = gimp_context_new (gimp, "file-open-location-dialog", NULL); entry = gimp_container_entry_new (gimp->documents, context, GIMP_VIEW_SIZE_SMALL, 0); g_object_unref (context); completion = gtk_entry_get_completion (GTK_ENTRY (entry)); gtk_entry_completion_set_match_func (completion, file_open_location_completion, NULL, NULL); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); gtk_widget_set_size_request (entry, 400, -1); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_widget_show (entry); g_object_set_data (G_OBJECT (dialog), "location-entry", entry); return dialog; }
GtkWidget *gui_build_dialog_gtk_table(GSList * list, gint cols, gboolean use_progress) { GSList *listtmp = list; GtkWidget *adv_vbox = NULL; GtkWidget *adv_expander = NULL; gint ielements = g_slist_position(list, g_slist_last(list)); gint rows = ((ielements + 1) / cols) + use_progress; GtkWidget *tab = gtk_table_new(rows, cols, FALSE); gint actC = 0, actR = 0; GtkWidget *to_grab_focus = NULL; gboolean need_advanced = FALSE; gtk_container_set_border_width(GTK_CONTAINER(tab), 15); /* remember to free adv_expander */ adv_vbox = gtk_vbox_new(FALSE, 5); while (listtmp) { GGaduKeyValue *kv = (GGaduKeyValue *) listtmp->data; GtkWidget *entry = NULL; gboolean need_label = TRUE; gboolean is_advanced = FALSE; switch (kv->type) { case VAR_STR: entry = gtk_entry_new(); if (kv->value) gtk_entry_set_text(GTK_ENTRY(entry), g_strdup(kv->value)); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); break; case VAR_INT: { entry = gtk_spin_button_new_with_range(0, 999999999, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry), (gint) kv->value); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); } break; case VAR_INT_WITH_NEGATIVE: { entry = gtk_spin_button_new_with_range(-999999999, 999999999, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry), (gint) kv->value); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); } break; case VAR_BOOL: need_label = FALSE; entry = gtk_check_button_new_with_mnemonic(kv->description); if (kv->value) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entry), TRUE); break; case VAR_FILE_CHOOSER: { GtkWidget *txt_entry = NULL; GtkWidget *button_entry = NULL; entry = gtk_hbox_new(FALSE, 2); txt_entry = gtk_entry_new(); if (kv->value) gtk_entry_set_text(GTK_ENTRY(txt_entry), g_strdup(kv->value)); g_object_set_data(G_OBJECT(txt_entry), "kv", kv); g_object_set_data(G_OBJECT(entry), "txt_entry", txt_entry); button_entry = gtk_button_new_from_stock("gtk-open"); gtk_box_pack_start_defaults(GTK_BOX(entry), txt_entry); gtk_box_pack_start_defaults(GTK_BOX(entry), button_entry); g_signal_connect_swapped(button_entry, "clicked", G_CALLBACK(gui_dialog_show_filename), txt_entry); } break; case VAR_FONT_CHOOSER: { GtkWidget *txt_entry = NULL; GtkWidget *button_entry = NULL; entry = gtk_hbox_new(FALSE, 2); txt_entry = gtk_entry_new(); if (kv->value) gtk_entry_set_text(GTK_ENTRY(txt_entry), g_strdup(kv->value)); g_object_set_data(G_OBJECT(txt_entry), "kv", kv); g_object_set_data(G_OBJECT(entry), "txt_entry", txt_entry); button_entry = gtk_button_new_from_stock("gtk-select-font"); gtk_box_pack_start_defaults(GTK_BOX(entry), txt_entry); gtk_box_pack_start_defaults(GTK_BOX(entry), button_entry); g_signal_connect_swapped(button_entry, "clicked", G_CALLBACK(gui_dialog_show_fontchooser), txt_entry); } break; case VAR_COLOUR_CHOOSER: { GtkWidget *txt_entry = NULL; GtkWidget *button_entry = NULL; GdkColor color; entry = gtk_hbox_new(FALSE, 2); txt_entry = gtk_entry_new(); if (kv->value) gtk_entry_set_text(GTK_ENTRY(txt_entry), g_strdup(kv->value)); gdk_color_parse(gtk_entry_get_text(GTK_ENTRY(txt_entry)), &color); g_object_set_data(G_OBJECT(txt_entry), "kv", kv); g_object_set_data(G_OBJECT(entry), "txt_entry", txt_entry); button_entry = gtk_color_button_new_with_color(&color); gtk_box_pack_start_defaults(GTK_BOX(entry), txt_entry); gtk_box_pack_start_defaults(GTK_BOX(entry), button_entry); g_signal_connect(G_OBJECT(button_entry), "color-set", G_CALLBACK(gui_dialog_show_colorchooser), txt_entry); } break; case VAR_IMG: need_label = FALSE; entry = gtk_image_new_from_file(kv->value); gtk_table_set_homogeneous(GTK_TABLE(tab), FALSE); break; case VAR_LIST: { GSList *selected = g_slist_nth((GSList *) kv->value, 0); GSList *restlist = g_slist_nth((GSList *) kv->value, 1); gint selected_index = 0; gint i = -1; entry = gtk_combo_box_new_text(); g_object_set_data(G_OBJECT(entry), "options-list", restlist); while (restlist) { i++; if (!g_strcasecmp(selected->data, restlist->data)) { selected_index = i; print_debug("############# %d %s", selected_index, selected->data); } gtk_combo_box_append_text(GTK_COMBO_BOX(entry), g_strdup(restlist->data)); restlist = restlist->next; } gtk_combo_box_set_active(GTK_COMBO_BOX(entry), selected_index); } break; default: break; } if ((kv->flag & VAR_FLAG_SENSITIVE) != 0) { gtk_widget_set_sensitive(GTK_WIDGET(entry), TRUE); gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE); } if ((kv->flag & VAR_FLAG_INSENSITIVE) != 0) { gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE); gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE); } if ((kv->flag & VAR_FLAG_PASSWORD) != 0) gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); if ((kv->flag & VAR_FLAG_FOCUS) != 0) to_grab_focus = entry; kv->user_data = (gpointer) entry; if ((kv->flag & VAR_FLAG_ADVANCED) != 0) { GtkWidget *hbox = gtk_hbox_new(FALSE, 5); GtkWidget *align; GtkWidget *label; need_advanced = TRUE; is_advanced = TRUE; gtk_box_pack_end_defaults(GTK_BOX(hbox), entry); if (need_label) { align = gtk_alignment_new(0, 0.5, 0, 0); label = gtk_label_new_with_mnemonic(kv->description); gtk_container_add(GTK_CONTAINER(align), label); gtk_box_pack_end_defaults(GTK_BOX(hbox), align); } gtk_box_pack_start_defaults(GTK_BOX(adv_vbox), hbox); } if (need_label && !is_advanced) { GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); GtkWidget *label = gtk_label_new_with_mnemonic(kv->description); gtk_container_add(GTK_CONTAINER(align), label); gtk_table_attach_defaults(GTK_TABLE(tab), align, 0, 1, actR, actR + 1); if (entry) gtk_table_attach_defaults(GTK_TABLE(tab), entry, 1, 2, actR, actR + 1); } else if (!is_advanced) { gtk_table_attach(GTK_TABLE(tab), entry, actC, actC + 2, actR, actR + 1, GTK_FILL, GTK_SHRINK, 0, 0); } if (!is_advanced) { if ((actC + 1) < cols) actC++; else { actC = 0; actR++; } } listtmp = listtmp->next; } if (need_advanced) { adv_expander = gtk_expander_new_with_mnemonic(_("_More options")); gtk_container_add(GTK_CONTAINER(adv_expander), adv_vbox); gtk_table_attach_defaults(GTK_TABLE(tab), adv_expander, 0, rows, actR, actR + 1); } else { gtk_widget_destroy(adv_vbox); } /* progress stuff */ if (use_progress) { GtkWidget *progress = gtk_progress_bar_new(); gtk_table_attach_defaults(GTK_TABLE(tab), progress, 0, rows, actR, actR + 1); } if (to_grab_focus) gtk_widget_grab_focus(GTK_WIDGET(to_grab_focus)); return tab; }
char * _gtk_request_dialog_run (GtkWindow *parent, GtkDialogFlags flags, const char *title, const char *message, const char *default_value, int max_length, const gchar *no_button_text, const gchar *yes_button_text) { GtkWidget *dialog; GtkWidget *label; GtkWidget *image; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *entry; GtkWidget *button; GtkWidget *content_area; char *result; dialog = gtk_dialog_new_with_buttons (title, parent, flags, NULL, NULL); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); /* Add label and image */ image = gtk_image_new_from_icon_name ("dialog-question", GTK_ICON_SIZE_DIALOG); gtk_widget_set_halign (image, GTK_ALIGN_CENTER); gtk_widget_set_valign (image, GTK_ALIGN_START); label = gtk_label_new_with_mnemonic (message); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_selectable (GTK_LABEL (label), FALSE); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_label_set_yalign (GTK_LABEL (label), 0.0); #else gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); #endif entry = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (entry), 50); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); gtk_entry_set_max_length (GTK_ENTRY (entry), max_length); gtk_entry_set_text (GTK_ENTRY (entry), default_value); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_box_set_spacing (GTK_BOX (content_area), 14); /* 14 + 2 * 5 = 24 */ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_box_set_spacing (GTK_BOX (vbox), 6); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0); gtk_widget_show_all (hbox); /* Add buttons */ button = create_button (GTK_STOCK_CANCEL, no_button_text); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CANCEL); button = create_button (GTK_STOCK_OK, yes_button_text); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_YES); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); /* Run dialog */ gtk_widget_grab_focus (entry); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) result = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); else result = NULL; gtk_widget_destroy (dialog); return result; }
FindNoteDialog::FindNoteDialog(GtkWindow *transient_parent) { extern Settings *settings; findnotedialog = gtk_dialog_new(); gtk_window_set_transient_for(GTK_WINDOW(findnotedialog), transient_parent); gtk_window_set_title(GTK_WINDOW(findnotedialog), _("Find in project notes")); //gtk_window_set_position(GTK_WINDOW(findnotedialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_modal(GTK_WINDOW(findnotedialog), TRUE); // Next one added to Glade's code. gtk_window_set_destroy_with_parent(GTK_WINDOW(findnotedialog), TRUE); dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG(findnotedialog)); gtk_widget_show(dialog_vbox1); hbox2 = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox2); gtk_box_pack_start(GTK_BOX(dialog_vbox1), hbox2, TRUE, TRUE, 0); label5 = gtk_label_new(_("Search for")); gtk_widget_show(label5); gtk_box_pack_start(GTK_BOX(hbox2), label5, FALSE, FALSE, 4); entry1 = gtk_entry_new(); // Next one has been added to Glade's code. gtk_entry_set_text(GTK_ENTRY(entry1), settings->session.searchword.c_str()); gtk_widget_show(entry1); gtk_box_pack_start(GTK_BOX(hbox2), entry1, TRUE, TRUE, 0); gtk_entry_set_activates_default(GTK_ENTRY(entry1), TRUE); checkbutton_case = gtk_check_button_new_with_mnemonic(_("Case _sensitive")); gtk_widget_show(checkbutton_case); gtk_box_pack_start(GTK_BOX(dialog_vbox1), checkbutton_case, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_case), settings->session.search_case_sensitive); dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG(findnotedialog)); gtk_widget_show(dialog_action_area1); gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END); new InDialogHelp(findnotedialog, NULL, NULL, NULL); buttonfind = gtk_button_new_from_stock("gtk-find"); gtk_widget_show(buttonfind); gtk_dialog_add_action_widget(GTK_DIALOG(findnotedialog), buttonfind, GTK_RESPONSE_OK); gtk_widget_set_can_default (GTK_WIDGET (buttonfind), true); buttoncancel = gtk_button_new_from_stock("gtk-cancel"); gtk_widget_show(buttoncancel); gtk_dialog_add_action_widget(GTK_DIALOG(findnotedialog), buttoncancel, GTK_RESPONSE_CANCEL); gtk_widget_set_can_default (GTK_WIDGET (buttoncancel), true); // The next one modified from Glade's code. g_signal_connect((gpointer) buttonfind, "clicked", G_CALLBACK(findnotedialog_on_buttonfind_clicked), gpointer(this)); g_signal_connect((gpointer) entry1, "changed", G_CALLBACK(on_word_entry_changed), gpointer(this)); gtk_widget_grab_focus(entry1); gtk_widget_grab_default(buttonfind); // Entry completion completion_setup(entry1, cpSearch); set_gui(); }
void fm_find_files( const char** search_dirs ) { FindFile* data = g_slice_new0(FindFile); GtkTreeIter it; GtkTreeViewColumn* col; GtkWidget *add_folder_btn, *remove_folder_btn, *img; GtkBuilder* builder = _gtk_builder_new_from_file( PACKAGE_UI_DIR "/find-files.ui", NULL ); data->win = (GtkWidget*)gtk_builder_get_object( builder, "win" ); g_object_set_data_full( G_OBJECT( data->win ), "find-files", data, (GDestroyNotify)free_data ); GdkPixbuf* icon = NULL; GtkIconTheme* theme = gtk_icon_theme_get_default(); if ( theme ) icon = gtk_icon_theme_load_icon( theme, "spacefm-find", 48, 0, NULL ); if ( icon ) { gtk_window_set_icon( GTK_WINDOW( data->win ), icon ); g_object_unref( icon ); } else gtk_window_set_icon_name( GTK_WINDOW( data->win ), GTK_STOCK_FIND ); /* search criteria pane */ data->search_criteria = (GtkWidget*)gtk_builder_get_object( builder, "search_criteria" ); data->fn_pattern = (GtkWidget*)gtk_builder_get_object( builder, "fn_pattern" ); data->fn_pattern_entry = gtk_bin_get_child( GTK_BIN( data->fn_pattern ) ); data->fn_case_sensitive = (GtkWidget*)gtk_builder_get_object( builder, "fn_case_sensitive" ); gtk_entry_set_activates_default( (GtkEntry*)data->fn_pattern_entry, TRUE ); /* file content */ data->fc_pattern = (GtkWidget*)gtk_builder_get_object( builder, "fc_pattern" ); data->fc_case_sensitive = (GtkWidget*)gtk_builder_get_object( builder, "fc_case_sensitive" ); data->fc_use_regexp = (GtkWidget*)gtk_builder_get_object( builder, "fc_use_regexp" ); /* advanced options */ data->search_hidden = (GtkWidget*)gtk_builder_get_object( builder, "search_hidden" ); /* size & date */ data->use_size_lower = (GtkWidget*)gtk_builder_get_object( builder, "use_size_lower" ); data->use_size_upper = (GtkWidget*)gtk_builder_get_object( builder, "use_size_upper" ); data->size_lower = (GtkWidget*)gtk_builder_get_object( builder, "size_lower" ); data->size_upper = (GtkWidget*)gtk_builder_get_object( builder, "size_upper" ); data->size_lower_unit = (GtkWidget*)gtk_builder_get_object( builder, "size_lower_unit" ); data->size_upper_unit = (GtkWidget*)gtk_builder_get_object( builder, "size_upper_unit" ); g_signal_connect( data->use_size_lower, "toggled", G_CALLBACK( on_use_size_lower_toggled ), data ); g_signal_connect( data->use_size_upper, "toggled", G_CALLBACK( on_use_size_upper_toggled ), data ); on_use_size_lower_toggled( data->use_size_lower, data ); on_use_size_upper_toggled( data->use_size_upper, data ); data->date_limit = (GtkWidget*)gtk_builder_get_object( builder, "date_limit" ); data->date1 = (GtkWidget*)gtk_builder_get_object( builder, "date1" ); data->date2 = (GtkWidget*)gtk_builder_get_object( builder, "date2" ); g_signal_connect( data->date_limit, "changed", G_CALLBACK( on_date_limit_changed ), data ); /* file types */ data->all_files = (GtkWidget*)gtk_builder_get_object( builder, "all_files" ); data->text_files = (GtkWidget*)gtk_builder_get_object( builder, "text_files" ); data->img_files = (GtkWidget*)gtk_builder_get_object( builder, "img_files" ); data->audio_files = (GtkWidget*)gtk_builder_get_object( builder, "audio_files" ); data->video_files = (GtkWidget*)gtk_builder_get_object( builder, "video_files" ); /* places */ data->places_list = gtk_list_store_new( 1, G_TYPE_STRING ); data->places_view = (GtkWidget*)gtk_builder_get_object( builder, "places_view" ); add_folder_btn = (GtkWidget*)gtk_builder_get_object( builder, "add_folder_btn" ); remove_folder_btn = (GtkWidget*)gtk_builder_get_object( builder, "remove_folder_btn" ); data->include_sub = (GtkWidget*)gtk_builder_get_object( builder, "include_sub" ); if( search_dirs ) { const char** dir; for( dir = search_dirs; *dir; ++dir ) { if( g_file_test( *dir, G_FILE_TEST_IS_DIR ) ) gtk_list_store_insert_with_values( data->places_list, &it, 0, 0, *dir, -1 ); } } gtk_tree_view_set_model( (GtkTreeView*)data->places_view, (GtkTreeModel*)data->places_list ); g_object_unref( data->places_list ); col = gtk_tree_view_column_new_with_attributes(NULL, gtk_cell_renderer_text_new(), "text", 0, NULL ); gtk_tree_view_append_column( (GtkTreeView*)data->places_view, col ); g_signal_connect(add_folder_btn, "clicked", G_CALLBACK( on_add_search_folder ), data ); g_signal_connect(remove_folder_btn, "clicked", G_CALLBACK( on_remove_search_folder ), data ); /* search result pane */ data->search_result = (GtkWidget*)gtk_builder_get_object( builder, "search_result" ); /* replace the problematic GtkTreeView with ExoTreeView */ data->result_view = exo_tree_view_new(); if( app_settings.single_click ) { exo_tree_view_set_single_click( EXO_TREE_VIEW( data->result_view ), TRUE ); exo_tree_view_set_single_click_timeout( EXO_TREE_VIEW( data->result_view ), SINGLE_CLICK_TIMEOUT ); } gtk_widget_show( data->result_view ); gtk_container_add( (GtkContainer*)gtk_builder_get_object(builder, "result_scroll"), data->result_view ); init_search_result( data ); g_signal_connect(data->result_view, "button-press-event", G_CALLBACK( on_view_button_press ), data ); /* buttons */ data->start_btn = (GtkWidget*)gtk_builder_get_object( builder, "start_btn" ); data->stop_btn = (GtkWidget*)gtk_builder_get_object( builder, "stop_btn" ); data->again_btn = (GtkWidget*)gtk_builder_get_object( builder, "again_btn" ); img = gtk_image_new_from_icon_name( GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON ); gtk_button_set_image( (GtkButton*)data->again_btn, img ); g_signal_connect(data->start_btn, "clicked", G_CALLBACK( on_start_search ), data ); g_signal_connect(data->stop_btn, "clicked", G_CALLBACK( on_stop_search ), data ); g_signal_connect(data->again_btn, "clicked", G_CALLBACK( on_search_again ), data ); gtk_entry_set_text( (GtkEntry*)data->fn_pattern_entry, "*" ); gtk_editable_select_region( (GtkEditable*)data->fn_pattern_entry, 0, -1 ); gtk_combo_box_set_active( (GtkComboBox*)data->size_lower_unit, 1 ); gtk_spin_button_set_range( (GtkSpinButton*)data->size_lower, 0, G_MAXINT ); gtk_combo_box_set_active( (GtkComboBox*)data->size_upper_unit, 2 ); gtk_spin_button_set_range( (GtkSpinButton*)data->size_upper, 0, G_MAXINT ); gtk_combo_box_set_active( (GtkComboBox*)data->date_limit, 0 ); g_signal_connect( data->win, "delete-event", G_CALLBACK(gtk_widget_destroy), NULL ); pcmanfm_ref(); g_signal_connect( data->win, "destroy", G_CALLBACK(pcmanfm_unref), NULL ); int width = xset_get_int( "main_search", "x" ); int height = xset_get_int( "main_search", "y" ); if ( width && height ) gtk_window_set_default_size( GTK_WINDOW( data->win ), width, height ); gtk_widget_show( data->win ); }
bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); return false; } if (HasFlag(wxCB_SORT)) m_strings = new wxGtkCollatedArrayString(); GTKCreateComboBoxWidget(); if (HasFlag(wxBORDER_NONE)) { // Doesn't seem to work // g_object_set (m_widget, "has-frame", FALSE, NULL); } GtkEntry * const entry = GetEntry(); if ( entry ) { // Set it up to trigger default item on enter key press gtk_entry_set_activates_default( entry, !HasFlag(wxTE_PROCESS_ENTER) ); gtk_editable_set_editable(GTK_EDITABLE(entry), true); } Append(n, choices); m_parent->DoAddChild( this ); if ( entry ) m_focusWidget = GTK_WIDGET( entry ); PostCreation(size); if ( entry ) { if (style & wxCB_READONLY) { // this will assert and do nothing if the value is not in our list // of strings which is the desired behaviour (for consistency with // wxMSW and also because it doesn't make sense to have a string // which is not a possible choice in a read-only combobox) SetStringSelection(value); gtk_editable_set_editable(GTK_EDITABLE(entry), false); } else // editable combobox { // any value is accepted, even if it's not in our list gtk_entry_set_text( entry, wxGTK_CONV(value) ); } g_signal_connect_after (entry, "changed", G_CALLBACK (gtkcombobox_text_changed_callback), this); GTKConnectInsertTextSignal(entry); GTKConnectClipboardSignals(GTK_WIDGET(entry)); } g_signal_connect_after (m_widget, "changed", G_CALLBACK (gtkcombobox_changed_callback), this); #ifndef __WXGTK3__ if ( !gtk_check_version(2,10,0) ) #endif { g_signal_connect (m_widget, "notify::popup-shown", G_CALLBACK (gtkcombobox_popupshown_callback), this); } return true; }
static void status_menu_new_status_message_dialog_run (StatusMenu *self, int option) { std::string presence; std::string status; GSList *clist = NULL; GtkWidget *dialog = NULL; GtkWidget *label = NULL; GtkWidget *entry = NULL; GtkWidget *vbox = NULL; GtkWidget *hbox = NULL; GtkWidget *image = NULL; const char *message = NULL; presence = self->priv->personal_data_settings->get_string ("short-status"); status = self->priv->personal_data_settings->get_string ("long-status"); dialog = gtk_dialog_new_with_buttons (_("Custom Message"), self->priv->parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, false, false, 2); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_window_set_icon_name (GTK_WINDOW (dialog), status_icon_name[option - NUM_STATUS_TYPES - 1]); image = gtk_image_new_from_icon_name (status_icon_name[option - NUM_STATUS_TYPES - 1], GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), image, false, false, 2); label = gtk_label_new (_("Define a custom message:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), label, false, false, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 2); entry = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (entry), true); gtk_box_pack_start (GTK_BOX (vbox), entry, false, false, 2); gtk_widget_show_all (dialog); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_ACCEPT: message = gtk_entry_get_text (GTK_ENTRY (entry)); clist = self->priv->personal_data_settings->get_slist (status_types_keys[option - NUM_STATUS_TYPES - 1]); if (message && g_strcmp0 (message, "")) { clist = g_slist_append (clist, g_strdup (message)); self->priv->personal_data_settings->set_slist (status_types_keys[option - NUM_STATUS_TYPES - 1], clist); self->priv->personal_details->set_presence_info (status_types_names[option - NUM_STATUS_TYPES - 1], message); } else { status_menu_set_option (self, presence.c_str (), status.c_str ()); } g_slist_foreach (clist, (GFunc) g_free, NULL); g_slist_free (clist); break; default: status_menu_set_option (self, presence.c_str (), status.c_str ()); break; } gtk_widget_destroy (dialog); }
static void on_button_config (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *playback_status_properties; GtkWidget *config_dialog; GtkWidget *hbox01; GtkWidget *vbox01; GtkWidget *num_lines; GtkWidget *dialog_action_area13; GtkWidget *applybutton1; GtkWidget *cancelbutton1; GtkWidget *okbutton1; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" playback_status_properties = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (playback_status_properties), "Playback Status Properties"); gtk_window_set_type_hint (GTK_WINDOW (playback_status_properties), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_resizable (GTK_WINDOW (playback_status_properties), FALSE); config_dialog = gtk_dialog_get_content_area (GTK_DIALOG (playback_status_properties)); gtk_widget_show (config_dialog); hbox01 = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox01); gtk_box_pack_start (GTK_BOX (config_dialog), hbox01, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox01), 12); vbox01 = gtk_vbox_new (TRUE, 8); gtk_box_pack_start (GTK_BOX (hbox01), vbox01, TRUE, TRUE, 0); gtk_widget_show (vbox01); num_lines = gtk_spin_button_new_with_range (1,MAX_LINES,1); gtk_widget_show (num_lines); gtk_box_pack_start (GTK_BOX (vbox01), num_lines, FALSE, FALSE, 0); g_signal_connect_after ((gpointer) num_lines, "value-changed", G_CALLBACK (on_num_lines_changed), user_data); for (int i = 0; i < MAX_LINES; i++) { format[i] = gtk_entry_new (); gtk_widget_show (format[i]); gtk_entry_set_invisible_char (GTK_ENTRY (format[i]), 8226); gtk_entry_set_activates_default (GTK_ENTRY (format[i]), TRUE); gtk_box_pack_start (GTK_BOX (vbox01), format[i], FALSE, FALSE, 0); if (CONFIG_FORMAT [i]) { gtk_entry_set_text (GTK_ENTRY (format[i]), CONFIG_FORMAT[i]); } } dialog_action_area13 = gtk_dialog_get_action_area (GTK_DIALOG (playback_status_properties)); gtk_widget_show (dialog_action_area13); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area13), GTK_BUTTONBOX_END); applybutton1 = gtk_button_new_from_stock ("gtk-apply"); gtk_widget_show (applybutton1); gtk_dialog_add_action_widget (GTK_DIALOG (playback_status_properties), applybutton1, GTK_RESPONSE_APPLY); gtk_widget_set_can_default (applybutton1, TRUE); cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (cancelbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (playback_status_properties), cancelbutton1, GTK_RESPONSE_CANCEL); gtk_widget_set_can_default (cancelbutton1, TRUE); okbutton1 = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (okbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (playback_status_properties), okbutton1, GTK_RESPONSE_OK); gtk_widget_set_can_default (okbutton1, TRUE); gtk_spin_button_set_value (GTK_SPIN_BUTTON (num_lines), CONFIG_NUM_LINES); for (;;) { int response = gtk_dialog_run (GTK_DIALOG (playback_status_properties)); if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) { CONFIG_NUM_LINES = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (num_lines)); for (int i = 0; i < CONFIG_NUM_LINES; i++) { if (CONFIG_FORMAT[i]) g_free ((gchar *)CONFIG_FORMAT[i]); CONFIG_FORMAT[i] = strdup (gtk_entry_get_text (GTK_ENTRY (format[i]))); } save_config (); deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); } if (response == GTK_RESPONSE_APPLY) { continue; } break; } gtk_widget_destroy (playback_status_properties); #pragma GCC diagnostic pop return; }
gboolean gnc_hbci_get_initial_password (GtkWidget *parent, const char *windowtitle, const char *heading, char **password) { GtkWidget *dialog; GtkWidget *heading_label; GtkWidget *password_entry; GtkWidget *confirm_entry; GladeXML *xml; gint result; g_return_val_if_fail (password != NULL, FALSE); xml = gnc_glade_xml_new ("hbcipass.glade", "Initial Password Dialog"); dialog = glade_xml_get_widget (xml, "Initial Password Dialog"); if (parent) gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); heading_label = glade_xml_get_widget (xml, "heading_label"); password_entry = glade_xml_get_widget (xml, "password_entry"); confirm_entry = glade_xml_get_widget (xml, "confirm_entry"); g_assert(heading_label && password_entry && confirm_entry); gtk_dialog_set_default_response (GTK_DIALOG (dialog), 1); gtk_entry_set_activates_default (GTK_ENTRY (password_entry), FALSE); gtk_entry_set_activates_default (GTK_ENTRY (confirm_entry), TRUE); if (windowtitle) gtk_window_set_title (GTK_WINDOW (dialog), windowtitle); if (heading) gtk_label_set_text (GTK_LABEL (heading_label), heading); while (TRUE) { result = gtk_dialog_run (GTK_DIALOG (dialog)); if (result == 1) /* the hand-assigned response value */ { const char *pw = gtk_entry_get_text (GTK_ENTRY (password_entry)); const char *confirm = gtk_entry_get_text (GTK_ENTRY (confirm_entry)); if (strcmp (pw, confirm) == 0) { *password = g_strdup(pw); gtk_widget_destroy (GTK_WIDGET (dialog)); return TRUE; } } else break; /* strings didn't match */ if (gnc_ok_cancel_dialog (parent, GTK_RESPONSE_OK, _("The two passwords didn't match. " "Please try again.")) != GTK_RESPONSE_OK) break; } *password = NULL; gtk_widget_destroy (GTK_WIDGET (dialog)); return FALSE; }