static int display_file_selector(int the_mode, GcomprisBoard *gcomprisBoard, gchar *rootdir, gchar *file_exts, FileSelectorCallBack iscb, void *user_context) { gchar *full_rootdir; mode = the_mode; /* Get the coordinate x y of the control area from the skin */ control_area_x1 = gc_skin_get_number_default("gcompris/fileselectx", 85); control_area_y1 = gc_skin_get_number_default("gcompris/fileselecty", 80); directory_label_y = gc_skin_get_number_default("gcompris/fileselectdiry", 180); if(rootitem) return 0; gc_bar_hide(TRUE); gc_board_pause(TRUE); fileSelectorCallBack=iscb; rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#FILE_SELECTOR", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); /* Entry area */ widget_entry = gtk_entry_new (); if(mode==MODE_SAVE) gtk_entry_set_max_length(GTK_ENTRY(widget_entry), 30); goo_canvas_widget_new (rootitem, GTK_WIDGET(widget_entry), control_area_x1, control_area_y1, 230.0, 30.0, NULL); g_signal_connect(GTK_OBJECT(widget_entry), "activate", G_CALLBACK(entry_enter_callback), widget_entry); gtk_widget_show(widget_entry); /* * Create the combo with the file types * ------------------------------------ */ if(mode==MODE_SAVE && file_exts && *file_exts != '\0') { gchar **all_type = g_strsplit(file_exts, " ", 0); guint i = 0; gtk_combo_filetypes = GTK_WIDGET(gtk_combo_box_new_text()); /* Extract first string */ while (all_type[i]) gtk_combo_box_append_text(GTK_COMBO_BOX(gtk_combo_filetypes), g_strdup(all_type[i++]) ); g_strfreev(all_type); goo_canvas_widget_new (rootitem, gtk_combo_filetypes, control_area_x1 + 400, control_area_y1, 250.0, 35.0, NULL); gtk_widget_show(gtk_combo_filetypes); gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_combo_filetypes), 0); } /* * Buttons * ------- */ // CANCEL gc_util_button_text_svg(rootitem, BOARDWIDTH * 1/3, BOARDHEIGHT - 32, "#BUTTON_TEXT", _("CANCEL"), (GCallback) item_event_file_selector, "/cancel/"); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 2/3, BOARDHEIGHT - 32, "#BUTTON_TEXT", (mode==MODE_LOAD ? _("LOAD") : _("SAVE")), (GCallback) item_event_file_selector, "/ok/"); file_selector_displayed = TRUE; full_rootdir = g_strconcat(gc_prop_get()->user_dir, "/", rootdir, NULL); gc_util_create_rootdir(full_rootdir); current_rootdir = full_rootdir; current_user_context = user_context; display_files(rootitem, full_rootdir); return 0; }
/* Initialize and display the preferences dialog. */ void terminal_preferences_dialog(GtkAction * action, LXTerminal * terminal) { Setting * setting = terminal->setting; GtkBuilder * builder = gtk_builder_new(); if ( ! gtk_builder_add_from_file(builder, PACKAGE_DATA_DIR "/lxterminal/lxterminal-preferences.ui", NULL)) { g_object_unref(builder); return; } GtkWidget * dialog = GTK_WIDGET(gtk_builder_get_object(builder, "lxterminal_preferences")); gtk_window_set_title(GTK_WINDOW(dialog), _("LXTerminal")); gtk_window_set_icon_from_file(GTK_WINDOW(dialog), PACKAGE_DATA_DIR "/pixmaps/lxterminal.png", NULL); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(preferences_dialog_response_event), terminal); GtkWidget * w = GTK_WIDGET(gtk_builder_get_object(builder, "terminal_font")); gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), setting->font_name); g_signal_connect(G_OBJECT(w), "font-set", G_CALLBACK(preferences_dialog_font_set_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "background_color")); gtk_color_button_set_color(GTK_COLOR_BUTTON(w), &setting->background_color); gtk_color_button_set_alpha(GTK_COLOR_BUTTON(w), setting->background_alpha); g_signal_connect(G_OBJECT(w), "color-set", G_CALLBACK(preferences_dialog_background_color_set_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "foreground_color")); gtk_color_button_set_color(GTK_COLOR_BUTTON(w), &setting->foreground_color); g_signal_connect(G_OBJECT(w), "color-set", G_CALLBACK(preferences_dialog_foreground_color_set_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "allow_bold")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), ! setting->disallow_bold); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_allow_bold_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "cursor_blink")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->cursor_blink); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_cursor_blink_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "cursor_style_block")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), ! setting->cursor_underline); w = GTK_WIDGET(gtk_builder_get_object(builder, "cursor_style_underline")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->cursor_underline); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_cursor_underline_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "audible_bell")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->audible_bell); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_audible_bell_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "tab_position")); gtk_combo_box_set_active(GTK_COMBO_BOX(w), terminal_tab_get_position_id(setting->tab_position)); g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(preferences_dialog_tab_position_changed_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "scrollback_lines")); gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), setting->scrollback); g_signal_connect(G_OBJECT(w), "value-changed", G_CALLBACK(preferences_dialog_scrollback_value_changed_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_scroll_bar")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_scroll_bar); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_hide_scroll_bar_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_menu_bar")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_menu_bar); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_hide_menu_bar_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_close_button")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_close_button); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_hide_close_button_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "select_by_word")); gtk_entry_set_text(GTK_ENTRY(w), setting->word_selection_characters); g_signal_connect(G_OBJECT(w), "focus-out-event", G_CALLBACK(preferences_dialog_selection_focus_out_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "disable_f10")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->disable_f10); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_disable_f10_toggled_event), terminal); w = GTK_WIDGET(gtk_builder_get_object(builder, "disable_alt")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->disable_alt); g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_disable_alt_toggled_event), terminal); gtk_widget_show_all(dialog); g_object_unref(builder); }
GtkWidget * stream_prefs_show() { GtkWidget *main_vb, *main_tb, *label, *combo_box; GtkWidget *sample, *colorsel; int width, height, i; const gchar *mt[] = { "Marked packet foreground", /* MFG_IDX 0*/ "Marked packet background", /* MBG_IDX 1*/ "Ignored packet foreground", /* IFG_IDX 2*/ "Ignored packet background", /* IBG_IDX 3*/ "TCP stream client foreground", /* CFG_IDX 4*/ "TCP stream client background", /* CBG_IDX 5*/ "TCP stream server foreground", /* SFG_IDX 6*/ "TCP stream server background" /* SBG_IDX 7*/ }; int mcount = sizeof(mt) / sizeof (gchar *); GtkTextBuffer *buf; GtkTextIter iter; PangoLayout *layout; color_t_to_gdkcolor(&tcolors[MFG_IDX], &prefs.gui_marked_fg); color_t_to_gdkcolor(&tcolors[MBG_IDX], &prefs.gui_marked_bg); color_t_to_gdkcolor(&tcolors[IFG_IDX], &prefs.gui_ignored_fg); color_t_to_gdkcolor(&tcolors[IBG_IDX], &prefs.gui_ignored_bg); color_t_to_gdkcolor(&tcolors[CFG_IDX], &prefs.st_client_fg); color_t_to_gdkcolor(&tcolors[CBG_IDX], &prefs.st_client_bg); color_t_to_gdkcolor(&tcolors[SFG_IDX], &prefs.st_server_fg); color_t_to_gdkcolor(&tcolors[SBG_IDX], &prefs.st_server_bg); curcolor = &tcolors[CFG_IDX]; /* Enclosing containers for each row of widgets */ main_vb = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5); main_tb = gtk_table_new(3, 3, FALSE); gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10); gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15); gtk_widget_show(main_tb); label = gtk_label_new("Set:"); gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f); gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 0, 1); gtk_widget_show(label); /* We have to create this now, and configure it below. */ colorsel = gtk_color_selection_new(); combo_box = gtk_combo_box_new_text (); for (i = 0; i < mcount; i++){ gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), mt[i]); } gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), CFG_IDX); g_signal_connect(combo_box, "changed", G_CALLBACK(update_current_color), colorsel); gtk_table_attach(GTK_TABLE(main_tb), combo_box, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0); gtk_widget_show(combo_box); sample = gtk_text_view_new(); layout = gtk_widget_create_pango_layout(sample, SAMPLE_SERVER_TEXT); pango_layout_get_pixel_size(layout, &width, &height); g_object_unref(G_OBJECT(layout)); gtk_widget_set_size_request(sample, width, height * 2); gtk_text_view_set_editable(GTK_TEXT_VIEW(sample), FALSE); buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sample)); gtk_text_buffer_get_start_iter(buf, &iter); gtk_text_buffer_create_tag(buf, "marked", "foreground-gdk", &tcolors[MFG_IDX], "background-gdk", &tcolors[MBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "ignored", "foreground-gdk", &tcolors[IFG_IDX], "background-gdk", &tcolors[IBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "client", "foreground-gdk", &tcolors[CFG_IDX], "background-gdk", &tcolors[CBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "server", "foreground-gdk", &tcolors[SFG_IDX], "background-gdk", &tcolors[SBG_IDX], NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_MARKED_TEXT, -1, "marked", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_IGNORED_TEXT, -1, "ignored", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_CLIENT_TEXT, -1, "client", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_SERVER_TEXT, -1, "server", NULL); gtk_table_attach_defaults(GTK_TABLE(main_tb), sample, 2, 3, 0, 2); gtk_widget_show(sample); gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), curcolor); gtk_table_attach(GTK_TABLE(main_tb), colorsel, 0, 3, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0); g_object_set_data(G_OBJECT(colorsel), STREAM_SAMPLE_KEY, sample); g_signal_connect(colorsel, "color-changed", G_CALLBACK(update_text_color), NULL); gtk_widget_show(colorsel); gtk_widget_show(main_vb); return(main_vb); }
static void connect_ip6_page (CEPageIP6 *page) { GtkWidget *content; const gchar *str_method; gboolean disabled; GtkListStore *store; GtkTreeIter iter; guint method; add_address_section (page); add_dns_section (page); add_routes_section (page); page->enabled = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "switch_enable")); g_signal_connect (page->enabled, "notify::active", G_CALLBACK (switch_toggled), page); str_method = nm_setting_ip6_config_get_method (page->setting); disabled = g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0; gtk_switch_set_active (page->enabled, !disabled); g_signal_connect_swapped (page->enabled, "notify::active", G_CALLBACK (ce_page_changed), page); content = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "page_content")); g_object_bind_property (page->enabled, "active", content, "sensitive", G_BINDING_SYNC_CREATE); page->method = GTK_COMBO_BOX (gtk_builder_get_object (CE_PAGE (page)->builder, "combo_addresses")); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Automatic"), METHOD_COL_METHOD, IP6_METHOD_AUTO, -1); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Automatic, DHCP only"), METHOD_COL_METHOD, IP6_METHOD_DHCP, -1); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Manual"), METHOD_COL_METHOD, IP6_METHOD_MANUAL, -1); gtk_list_store_insert_with_values (store, &iter, -1, METHOD_COL_NAME, _("Link-Local Only"), METHOD_COL_METHOD, IP6_METHOD_LINK_LOCAL, -1); gtk_combo_box_set_model (page->method, GTK_TREE_MODEL (store)); g_object_unref (G_OBJECT (store)); method = IP6_METHOD_AUTO; if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) { method = IP6_METHOD_DHCP; } else if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) { method = IP6_METHOD_LINK_LOCAL; } else if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) { method = IP6_METHOD_MANUAL; } else if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) { method = IP6_METHOD_SHARED; } else if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) { method = IP6_METHOD_IGNORE; } page->never_default = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "never_default_check")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->never_default), nm_setting_ip6_config_get_never_default (page->setting)); g_signal_connect_swapped (page->never_default, "toggled", G_CALLBACK (ce_page_changed), page); g_signal_connect (page->method, "changed", G_CALLBACK (method_changed), page); if (method != IP6_METHOD_SHARED && method != IP6_METHOD_IGNORE) gtk_combo_box_set_active (page->method, method); }
void dialog_graphical_options_new (GtkWindow * parent) { int i; DialogGraphicalOptions dlg; char *string_animation[3] = { gettext ("_No animation"), gettext ("_Fast"), gettext ("_Detailed") }; char *string_options[sys->nt + 8]; char *string_channels[sys->n + 1]; for (i = 0; i <= sys->n; ++i) string_channels[i] = sys->channel[i].name; string_graphical_options (string_options, sys); dlg.button_adjust = (GtkCheckButton *) gtk_check_button_new_with_mnemonic (gettext ("_Manual adjust")); g_signal_connect_swapped (dlg.button_adjust, "clicked", (void (*)()) dialog_graphical_options_actualize, &dlg); dlg.button_grid = (GtkCheckButton *) gtk_check_button_new_with_mnemonic (gettext ("_Show grid")); dlg.label_profile_xmax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_profile_xmax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_profile_xmin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_profile_xmin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_profile_x = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_profile_x, GTK_WIDGET (dlg.label_profile_xmax), 0, 0, 1, 1); gtk_grid_attach (dlg.table_profile_x, GTK_WIDGET (dlg.entry_profile_xmax), 1, 0, 1, 1); gtk_grid_attach (dlg.table_profile_x, GTK_WIDGET (dlg.label_profile_xmin), 0, 1, 1, 1); gtk_grid_attach (dlg.table_profile_x, GTK_WIDGET (dlg.entry_profile_xmin), 1, 1, 1, 1); dlg.frame_profile_x = (GtkFrame *) gtk_frame_new (gettext ("Position")); gtk_container_add (GTK_CONTAINER (dlg.frame_profile_x), GTK_WIDGET (dlg.table_profile_x)); dlg.combo_profile_y = jbw_combo_box_new_with_strings (string_options, 8 + sys->nt); dlg.label_profile_ymax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_profile_ymax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_profile_ymin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_profile_ymin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_profile_y = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_profile_y, GTK_WIDGET (dlg.combo_profile_y), 0, 0, 2, 1); gtk_grid_attach (dlg.table_profile_y, GTK_WIDGET (dlg.label_profile_ymax), 0, 1, 1, 1); gtk_grid_attach (dlg.table_profile_y, GTK_WIDGET (dlg.entry_profile_ymax), 1, 1, 1, 1); gtk_grid_attach (dlg.table_profile_y, GTK_WIDGET (dlg.label_profile_ymin), 0, 2, 1, 1); gtk_grid_attach (dlg.table_profile_y, GTK_WIDGET (dlg.entry_profile_ymin), 1, 2, 1, 1); dlg.frame_profile_y = (GtkFrame *) gtk_frame_new (gettext ("Parameter 1")); gtk_container_add (GTK_CONTAINER (dlg.frame_profile_y), GTK_WIDGET (dlg.table_profile_y)); dlg.combo_profile_z = jbw_combo_box_new_with_strings (string_options, 8 + sys->nt); dlg.label_profile_zmax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_profile_zmax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_profile_zmin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_profile_zmin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_profile_z = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_profile_z, GTK_WIDGET (dlg.combo_profile_z), 0, 0, 2, 1); gtk_grid_attach (dlg.table_profile_z, GTK_WIDGET (dlg.label_profile_zmax), 0, 1, 1, 1); gtk_grid_attach (dlg.table_profile_z, GTK_WIDGET (dlg.entry_profile_zmax), 1, 1, 1, 1); gtk_grid_attach (dlg.table_profile_z, GTK_WIDGET (dlg.label_profile_zmin), 0, 2, 1, 1); gtk_grid_attach (dlg.table_profile_z, GTK_WIDGET (dlg.entry_profile_zmin), 1, 2, 1, 1); dlg.frame_profile_z = (GtkFrame *) gtk_frame_new (gettext ("Parameter 2")); gtk_container_add (GTK_CONTAINER (dlg.frame_profile_z), GTK_WIDGET (dlg.table_profile_z)); dlg.table_profile = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_profile, GTK_WIDGET (dlg.frame_profile_x), 0, 1, 1, 1); gtk_grid_attach (dlg.table_profile, GTK_WIDGET (dlg.frame_profile_y), 0, 2, 1, 1); gtk_grid_attach (dlg.table_profile, GTK_WIDGET (dlg.frame_profile_z), 0, 3, 1, 1); if (simulated) { char *string_profile[nstep]; for (i = 0; i < nstep; ++i) { string_profile[i] = (char *) g_malloc (32 * sizeof (char)); snprintf (string_profile[i], 32, FGL, (JBDOUBLE) fmin (i * ti, tf)); } dlg.combo_profile = jbw_combo_box_new_with_strings (string_profile, i); dlg.label_profile_time = (GtkLabel *) gtk_label_new (gettext ("Time")); dlg.box_profile = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.box_profile, GTK_WIDGET (dlg.label_profile_time), 0, 0, 1, 1); gtk_grid_attach (dlg.box_profile, GTK_WIDGET (dlg.combo_profile), 1, 0, 1, 1); gtk_grid_attach (dlg.table_profile, GTK_WIDGET (dlg.box_profile), 0, 0, 1, 1); } dlg.label_evolution_xmax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_evolution_xmax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_evolution_xmin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_evolution_xmin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_evolution_x = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_evolution_x, GTK_WIDGET (dlg.label_evolution_xmax), 0, 0, 1, 1); gtk_grid_attach (dlg.table_evolution_x, GTK_WIDGET (dlg.entry_evolution_xmax), 1, 0, 2, 1); gtk_grid_attach (dlg.table_evolution_x, GTK_WIDGET (dlg.label_evolution_xmin), 0, 1, 1, 1); gtk_grid_attach (dlg.table_evolution_x, GTK_WIDGET (dlg.entry_evolution_xmin), 1, 1, 2, 1); dlg.frame_evolution_x = (GtkFrame *) gtk_frame_new (gettext ("Time")); gtk_container_add (GTK_CONTAINER (dlg.frame_evolution_x), GTK_WIDGET (dlg.table_evolution_x)); dlg.combo_evolution_y = jbw_combo_box_new_with_strings (string_options, 8 + sys->nt); dlg.label_evolution_ymax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_evolution_ymax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_evolution_ymin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_evolution_ymin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_evolution_y = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_evolution_y, GTK_WIDGET (dlg.combo_evolution_y), 0, 0, 2, 1); gtk_grid_attach (dlg.table_evolution_y, GTK_WIDGET (dlg.label_evolution_ymax), 0, 1, 1, 1); gtk_grid_attach (dlg.table_evolution_y, GTK_WIDGET (dlg.entry_evolution_ymax), 1, 1, 1, 1); gtk_grid_attach (dlg.table_evolution_y, GTK_WIDGET (dlg.label_evolution_ymin), 0, 2, 1, 1); gtk_grid_attach (dlg.table_evolution_y, GTK_WIDGET (dlg.entry_evolution_ymin), 1, 2, 1, 1); dlg.frame_evolution_y = (GtkFrame *) gtk_frame_new (gettext ("Parameter 1")); gtk_container_add (GTK_CONTAINER (dlg.frame_evolution_y), GTK_WIDGET (dlg.table_evolution_y)); dlg.combo_evolution_z = jbw_combo_box_new_with_strings (string_options, 8 + sys->nt); dlg.label_evolution_zmax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_evolution_zmax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_evolution_zmin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_evolution_zmin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_evolution_z = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_evolution_z, GTK_WIDGET (dlg.combo_evolution_z), 0, 0, 2, 1); gtk_grid_attach (dlg.table_evolution_z, GTK_WIDGET (dlg.label_evolution_zmax), 0, 1, 1, 1); gtk_grid_attach (dlg.table_evolution_z, GTK_WIDGET (dlg.entry_evolution_zmax), 1, 1, 1, 1); gtk_grid_attach (dlg.table_evolution_z, GTK_WIDGET (dlg.label_evolution_zmin), 0, 2, 1, 1); gtk_grid_attach (dlg.table_evolution_z, GTK_WIDGET (dlg.entry_evolution_zmin), 1, 2, 1, 1); dlg.frame_evolution_z = (GtkFrame *) gtk_frame_new (gettext ("Parameter 2")); gtk_container_add (GTK_CONTAINER (dlg.frame_evolution_z), GTK_WIDGET (dlg.table_evolution_z)); dlg.label_evolution_section = (GtkLabel *) gtk_label_new (gettext ("Transient section")); dlg.combo_evolution_section = (GtkComboBoxText *) gtk_combo_box_text_new (); dlg.combo_section = (GtkComboBoxText *) gtk_combo_box_text_new (); dialog_graphical_options_sections (&dlg); dlg.table_evolution = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_evolution, GTK_WIDGET (dlg.label_evolution_section), 0, 0, 1, 1); gtk_grid_attach (dlg.table_evolution, GTK_WIDGET (dlg.combo_evolution_section), 0, 1, 1, 1); gtk_grid_attach (dlg.table_evolution, GTK_WIDGET (dlg.frame_evolution_x), 0, 2, 1, 1); gtk_grid_attach (dlg.table_evolution, GTK_WIDGET (dlg.frame_evolution_y), 0, 3, 1, 1); gtk_grid_attach (dlg.table_evolution, GTK_WIDGET (dlg.frame_evolution_z), 0, 4, 1, 1); dlg.label_section_xmax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_section_xmax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_section_xmin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_section_xmin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_section_x = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_section_x, GTK_WIDGET (dlg.label_section_xmax), 0, 0, 1, 1); gtk_grid_attach (dlg.table_section_x, GTK_WIDGET (dlg.entry_section_xmax), 1, 0, 1, 1); gtk_grid_attach (dlg.table_section_x, GTK_WIDGET (dlg.label_section_xmin), 0, 1, 1, 1); gtk_grid_attach (dlg.table_section_x, GTK_WIDGET (dlg.entry_section_xmin), 1, 1, 1, 1); dlg.frame_section_x = (GtkFrame *) gtk_frame_new (gettext ("Position")); gtk_container_add (GTK_CONTAINER (dlg.frame_section_x), GTK_WIDGET (dlg.table_section_x)); dlg.label_section_ymax = (GtkLabel *) gtk_label_new (gettext ("Maximum")); dlg.entry_section_ymax = (JBWFloatEntry *) jbw_float_entry_new (); dlg.label_section_ymin = (GtkLabel *) gtk_label_new (gettext ("Minimum")); dlg.entry_section_ymin = (JBWFloatEntry *) jbw_float_entry_new (); dlg.table_section_y = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_section_y, GTK_WIDGET (dlg.label_section_ymax), 0, 0, 1, 1); gtk_grid_attach (dlg.table_section_y, GTK_WIDGET (dlg.entry_section_ymax), 1, 0, 1, 1); gtk_grid_attach (dlg.table_section_y, GTK_WIDGET (dlg.label_section_ymin), 0, 1, 1, 1); gtk_grid_attach (dlg.table_section_y, GTK_WIDGET (dlg.entry_section_ymin), 1, 1, 1, 1); dlg.frame_section_y = (GtkFrame *) gtk_frame_new (gettext ("Level")); gtk_container_add (GTK_CONTAINER (dlg.frame_section_y), GTK_WIDGET (dlg.table_section_y)); dlg.label_section_section = (GtkLabel *) gtk_label_new (gettext ("Transient section")); dlg.table_section = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.table_section, GTK_WIDGET (dlg.label_section_section), 0, 0, 1, 1); gtk_grid_attach (dlg.table_section, GTK_WIDGET (dlg.combo_section), 0, 1, 1, 1); gtk_grid_attach (dlg.table_section, GTK_WIDGET (dlg.frame_section_x), 0, 2, 1, 1); gtk_grid_attach (dlg.table_section, GTK_WIDGET (dlg.frame_section_y), 0, 3, 1, 1); dlg.label_profile = (GtkLabel *) gtk_label_new (gettext ("Longitudinal profile")); dlg.label_evolution = (GtkLabel *) gtk_label_new (gettext ("Time evolution")); dlg.label_section = (GtkLabel *) gtk_label_new (gettext ("Transient section")); dlg.notebook = (GtkNotebook *) gtk_notebook_new (); gtk_notebook_append_page (dlg.notebook, GTK_WIDGET (dlg.table_profile), GTK_WIDGET (dlg.label_profile)); gtk_notebook_append_page (dlg.notebook, GTK_WIDGET (dlg.table_evolution), GTK_WIDGET (dlg.label_evolution)); gtk_notebook_append_page (dlg.notebook, GTK_WIDGET (dlg.table_section), GTK_WIDGET (dlg.label_section)); dlg.array_animation[0] = 0; dlg.box_animation = (GtkGrid *) gtk_grid_new (); for (i = 0; i < 3; ++i) { dlg.array_animation[i] = (GtkRadioButton *) gtk_radio_button_new_with_mnemonic_from_widget (dlg.array_animation[0], string_animation[i]); gtk_grid_attach (dlg.box_animation, GTK_WIDGET (dlg.array_animation[i]), 0, i, 1, 1); } dlg.frame_animation = (GtkFrame *) gtk_frame_new (gettext ("Animation")); gtk_container_add (GTK_CONTAINER (dlg.frame_animation), GTK_WIDGET (dlg.box_animation)); dlg.combo_channel = jbw_combo_box_new_with_strings (string_channels, sys->n + 1); dlg.vbox = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.vbox, GTK_WIDGET (dlg.combo_channel), 0, 0, 1, 1); gtk_grid_attach (dlg.vbox, GTK_WIDGET (dlg.frame_animation), 0, 1, 1, 1); gtk_grid_attach (dlg.vbox, GTK_WIDGET (dlg.button_adjust), 0, 2, 1, 1); gtk_grid_attach (dlg.vbox, GTK_WIDGET (dlg.button_grid), 0, 3, 1, 1); dlg.box = (GtkGrid *) gtk_grid_new (); gtk_grid_attach (dlg.box, GTK_WIDGET (dlg.notebook), 0, 0, 1, 1); gtk_grid_attach (dlg.box, GTK_WIDGET (dlg.vbox), 1, 0, 1, 1); dlg.window = (GtkDialog *) gtk_dialog_new_with_buttons (gettext ("Graphical options"), parent, GTK_DIALOG_MODAL, gettext ("_OK"), GTK_RESPONSE_OK, gettext ("_Cancel"), GTK_RESPONSE_CANCEL, NULL); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dlg.window)), GTK_WIDGET (dlg.box)); gtk_widget_show_all (GTK_WIDGET (dlg.box)); jbw_float_entry_set_value (dlg.entry_profile_xmax, profile_xmax); jbw_float_entry_set_value (dlg.entry_profile_xmin, profile_xmin); jbw_float_entry_set_value (dlg.entry_profile_ymax, profile_ymax); jbw_float_entry_set_value (dlg.entry_profile_ymin, profile_ymin); jbw_float_entry_set_value (dlg.entry_profile_zmax, profile_zmax); jbw_float_entry_set_value (dlg.entry_profile_zmin, profile_zmin); if (simulated) gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_profile), istep); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_profile_y), profile_parameter1); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_profile_z), profile_parameter2); jbw_float_entry_set_value (dlg.entry_evolution_xmax, evolution_xmax); jbw_float_entry_set_value (dlg.entry_evolution_xmin, evolution_xmin); jbw_float_entry_set_value (dlg.entry_evolution_ymax, evolution_ymax); jbw_float_entry_set_value (dlg.entry_evolution_ymin, evolution_ymin); jbw_float_entry_set_value (dlg.entry_evolution_zmax, evolution_zmax); jbw_float_entry_set_value (dlg.entry_evolution_zmin, evolution_zmin); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_evolution_y), evolution_parameter1); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_evolution_z), evolution_parameter2); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_evolution_section), evolution_section); gtk_toggle_button_set_active ((GtkToggleButton *) dlg.button_adjust, draw_adjust); gtk_toggle_button_set_active ((GtkToggleButton *) dlg.button_grid, draw_grid); jbw_float_entry_set_value (dlg.entry_section_xmax, section_xmax); jbw_float_entry_set_value (dlg.entry_section_xmin, section_xmin); jbw_float_entry_set_value (dlg.entry_section_ymax, section_ymax); jbw_float_entry_set_value (dlg.entry_section_ymin, section_ymin); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_section), section); jbw_array_radio_buttons_set_active (dlg.array_animation, type_animation, 1); gtk_notebook_set_current_page (dlg.notebook, type_draw); gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo_channel), channel); dialog_graphical_options_actualize (&dlg); g_signal_connect_swapped (dlg.combo_channel, "changed", (void (*)) dialog_graphical_options_channel, &dlg); if (gtk_dialog_run (dlg.window) == GTK_RESPONSE_OK) { if (simulated) { istep = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_profile)); t = fmin (t0 + istep * ti, tf); dialog_simulator_actualize_bar (dialog_simulator); } channel = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_channel)); draw_adjust = gtk_toggle_button_get_active ((GtkToggleButton *) dlg.button_adjust); draw_grid = gtk_toggle_button_get_active ((GtkToggleButton *) dlg.button_grid); profile_parameter1 = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_profile_y)); profile_parameter2 = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_profile_z)); profile_xmin = jbw_float_entry_get_value (dlg.entry_profile_xmin); profile_xmax = jbw_float_entry_get_value (dlg.entry_profile_xmax); profile_ymin = jbw_float_entry_get_value (dlg.entry_profile_ymin); profile_ymax = jbw_float_entry_get_value (dlg.entry_profile_ymax); profile_zmin = jbw_float_entry_get_value (dlg.entry_profile_zmin); profile_zmax = jbw_float_entry_get_value (dlg.entry_profile_zmax); evolution_parameter1 = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_evolution_y)); evolution_parameter2 = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_evolution_z)); evolution_xmin = jbw_float_entry_get_value (dlg.entry_evolution_xmin); evolution_xmax = jbw_float_entry_get_value (dlg.entry_evolution_xmax); evolution_ymin = jbw_float_entry_get_value (dlg.entry_evolution_ymin); evolution_ymax = jbw_float_entry_get_value (dlg.entry_evolution_ymax); evolution_zmin = jbw_float_entry_get_value (dlg.entry_evolution_zmin); evolution_zmax = jbw_float_entry_get_value (dlg.entry_evolution_zmax); evolution_section = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_evolution_section)); section_xmin = jbw_float_entry_get_value (dlg.entry_section_xmin); section_xmax = jbw_float_entry_get_value (dlg.entry_section_xmax); section_ymin = jbw_float_entry_get_value (dlg.entry_section_ymin); section_ymax = jbw_float_entry_get_value (dlg.entry_section_ymax); section = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg.combo_section)); type_draw = gtk_notebook_get_current_page (dlg.notebook); type_animation = jbw_array_radio_buttons_get_active (dlg.array_animation); dialog_simulator_actualize (dialog_simulator); } gtk_widget_destroy (GTK_WIDGET (dlg.window)); draw (); }
void gui_init (dt_lib_module_t *self) { dt_lib_export_t *d = (dt_lib_export_t *)malloc(sizeof(dt_lib_export_t)); self->data = (void *)d; self->widget = gtk_table_new(8, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(self->widget), 5); GtkWidget *label; label = dtgtk_label_new(_("target storage"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 2, 0, 1, GTK_FILL|GTK_EXPAND, 0, 0, 0); d->storage = GTK_COMBO_BOX(gtk_combo_box_text_new()); GList *it = darktable.imageio->plugins_storage; while(it) { dt_imageio_module_storage_t *module = (dt_imageio_module_storage_t *)it->data; gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->storage), module->name(module)); it = g_list_next(it); } dt_control_signal_connect(darktable.signals,DT_SIGNAL_IMAGEIO_STORAGE_CHANGE,G_CALLBACK(on_storage_list_changed),self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->storage), 0, 2, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_signal_connect (G_OBJECT (d->storage), "changed", G_CALLBACK (storage_changed), (gpointer)d); d->storage_box = GTK_CONTAINER(gtk_alignment_new(1.0, 1.0, 1.0, 1.0)); gtk_alignment_set_padding(GTK_ALIGNMENT(d->storage_box), 0, 0, 0, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->storage_box), 0, 2, 2, 3, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = dtgtk_label_new(_("file format"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_set_row_spacing(GTK_TABLE(self->widget), 2, 20); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 2, 3, 4, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->format = GTK_COMBO_BOX(gtk_combo_box_text_new()); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->format), 0, 2, 4, 5, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_signal_connect (G_OBJECT (d->format), "changed", G_CALLBACK (format_changed), (gpointer)d); d->format_box = GTK_CONTAINER(gtk_alignment_new(1.0, 1.0, 1.0, 1.0)); gtk_alignment_set_padding(GTK_ALIGNMENT(d->format_box), 0, 0, 0, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->format_box), 0, 2, 5, 6, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = dtgtk_label_new(_("global options"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); gtk_table_set_row_spacing(GTK_TABLE(self->widget), 5, 20); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 2, 6, 7, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->width = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0, 10000, 1)); g_object_set(G_OBJECT(d->width), "tooltip-text", _("maximum output width\nset to 0 for no scaling"), (char *)NULL); d->height = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0, 10000, 1)); g_object_set(G_OBJECT(d->height), "tooltip-text", _("maximum output height\nset to 0 for no scaling"), (char *)NULL); dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (d->width)); dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (d->height)); /* gtk_widget_add_events(GTK_WIDGET(d->width), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (d->width), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (d->width), "focus-out-event", G_CALLBACK(focus_out), NULL); gtk_widget_add_events(GTK_WIDGET(d->height), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (d->height), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (d->height), "focus-out-event", G_CALLBACK(focus_out), NULL); */ label = gtk_label_new(_("max size")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 7, 8, GTK_EXPAND|GTK_FILL, 0, 0, 0); GtkBox *hbox = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_box_pack_start(hbox, GTK_WIDGET(d->width), TRUE, TRUE, 0); gtk_box_pack_start(hbox, gtk_label_new(_("x")), FALSE, FALSE, 0); gtk_box_pack_start(hbox, GTK_WIDGET(d->height), TRUE, TRUE, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(hbox), 1, 2, 7, 8, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("intent")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 8, 9, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->intent = GTK_COMBO_BOX(gtk_combo_box_text_new()); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("image settings")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("perceptual")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("relative colorimetric")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), C_("rendering intent", "saturation")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("absolute colorimetric")); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->intent), 1, 2, 8, 9, GTK_EXPAND|GTK_FILL, 0, 0, 0); // Add profile combo d->profiles = NULL; dt_lib_export_profile_t *prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "sRGB", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, _("sRGB (web-safe)"), sizeof(prof->name)); int pos; prof->pos = 1; d->profiles = g_list_append(d->profiles, prof); prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "adobergb", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, _("Adobe RGB (compatible)"), sizeof(prof->name)); prof->pos = 2; d->profiles = g_list_append(d->profiles, prof); prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "X profile", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, "X profile", sizeof(prof->name)); prof->pos = 3; d->profiles = g_list_append(d->profiles, prof); prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "linear_rgb", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, _("linear Rec709 RGB"), sizeof(prof->name)); pos = prof->pos = 4; d->profiles = g_list_append(d->profiles, prof); // read datadir/color/out/*.icc char datadir[DT_MAX_PATH_LEN]; char confdir[DT_MAX_PATH_LEN]; char dirname[DT_MAX_PATH_LEN]; char filename[DT_MAX_PATH_LEN]; dt_loc_get_user_config_dir(confdir, DT_MAX_PATH_LEN); dt_loc_get_datadir(datadir, DT_MAX_PATH_LEN); cmsHPROFILE tmpprof; const gchar *d_name; snprintf(dirname, DT_MAX_PATH_LEN, "%s/color/out", confdir); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) snprintf(dirname, DT_MAX_PATH_LEN, "%s/color/out", datadir); GDir *dir = g_dir_open(dirname, 0, NULL); if(dir) { while((d_name = g_dir_read_name(dir))) { snprintf(filename, DT_MAX_PATH_LEN, "%s/%s", dirname, d_name); tmpprof = cmsOpenProfileFromFile(filename, "r"); if(tmpprof) { char *lang = getenv("LANG"); if (!lang) lang = "en_US"; dt_lib_export_profile_t *prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); dt_colorspaces_get_profile_name(tmpprof, lang, lang+3, prof->name, sizeof(prof->name)); g_strlcpy(prof->filename, d_name, sizeof(prof->filename)); prof->pos = ++pos; cmsCloseProfile(tmpprof); d->profiles = g_list_append(d->profiles, prof); } } g_dir_close(dir); } GList *l = d->profiles; label = gtk_label_new(_("profile")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 9, 10, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->profile = GTK_COMBO_BOX(gtk_combo_box_text_new()); dt_ellipsize_combo(d->profile); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->profile), 1, 2, 9, 10, GTK_SHRINK|GTK_EXPAND|GTK_FILL, 0, 0, 0); // gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->profile), 1, 2, 9, 10, GTK_EXPAND|GTK_FILL, 0, 0, 0); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->profile), _("image settings")); while(l) { dt_lib_export_profile_t *prof = (dt_lib_export_profile_t *)l->data; if(!strcmp(prof->name, "X profile")) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->profile), _("system display profile")); else gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->profile), prof->name); l = g_list_next(l); } gtk_combo_box_set_active(d->profile, 0); char tooltip[1024]; snprintf(tooltip, sizeof(tooltip), _("output ICC profiles in %s/color/out or %s/color/out"), confdir, datadir); g_object_set(G_OBJECT(d->profile), "tooltip-text", tooltip, (char *)NULL); // Add style combo label = gtk_label_new(_("style")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 10, 11, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->style = GTK_COMBO_BOX(gtk_combo_box_text_new()); dt_ellipsize_combo(d->style); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->style), _("none")); GList *styles = dt_styles_get_list(""); while (styles) { dt_style_t *style=(dt_style_t *)styles->data; gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->style), style->name); styles=g_list_next(styles); } gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->style), 1, 2, 10, 11, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_object_set(G_OBJECT(d->style), "tooltip-text", _("temporary style to append while exporting"), (char *)NULL); // Set callback signals g_signal_connect (G_OBJECT (d->intent), "changed", G_CALLBACK (intent_changed), (gpointer)d); g_signal_connect (G_OBJECT (d->profile), "changed", G_CALLBACK (profile_changed), (gpointer)d); g_signal_connect (G_OBJECT (d->style), "changed", G_CALLBACK (style_changed), (gpointer)d); // Export button GtkButton *button = GTK_BUTTON(gtk_button_new_with_label(_("export"))); d->export_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("export with current settings (ctrl-e)"), (char *)NULL); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(button), 1, 2, 11, 12, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (export_button_clicked), (gpointer)self); g_signal_connect (G_OBJECT (d->width), "value-changed", G_CALLBACK (width_changed), NULL); g_signal_connect (G_OBJECT (d->height), "value-changed", G_CALLBACK (height_changed), NULL); self->gui_reset(self); }
static GtkWidget * inner_auth_combo_init (EAPMethodPEAP *method, NMConnection *connection, NMSetting8021x *s_8021x, gboolean secrets_only) { EAPMethod *parent = (EAPMethod *) method; GtkWidget *combo; GtkListStore *auth_model; GtkTreeIter iter; EAPMethodSimple *em_mschap_v2; EAPMethodSimple *em_md5; EAPMethodSimple *em_gtc; guint32 active = 0; const char *phase2_auth = NULL; EAPMethodSimpleFlags simple_flags; auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ()); if (s_8021x) { if (nm_setting_802_1x_get_phase2_auth (s_8021x)) phase2_auth = nm_setting_802_1x_get_phase2_auth (s_8021x); else if (nm_setting_802_1x_get_phase2_autheap (s_8021x)) phase2_auth = nm_setting_802_1x_get_phase2_autheap (s_8021x); } simple_flags = EAP_METHOD_SIMPLE_FLAG_PHASE2; if (method->is_editor) simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR; if (secrets_only) simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; em_mschap_v2 = eap_method_simple_new (method->sec_parent, connection, EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2, simple_flags); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, I_NAME_COLUMN, _("MSCHAPv2"), I_METHOD_COLUMN, em_mschap_v2, -1); eap_method_unref (EAP_METHOD (em_mschap_v2)); /* Check for defaulting to MSCHAPv2 */ if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2")) active = 0; em_md5 = eap_method_simple_new (method->sec_parent, connection, EAP_METHOD_SIMPLE_TYPE_MD5, simple_flags); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, I_NAME_COLUMN, _("MD5"), I_METHOD_COLUMN, em_md5, -1); eap_method_unref (EAP_METHOD (em_md5)); /* Check for defaulting to MD5 */ if (phase2_auth && !strcasecmp (phase2_auth, "md5")) active = 1; em_gtc = eap_method_simple_new (method->sec_parent, connection, EAP_METHOD_SIMPLE_TYPE_GTC, simple_flags); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, I_NAME_COLUMN, _("GTC"), I_METHOD_COLUMN, em_gtc, -1); eap_method_unref (EAP_METHOD (em_gtc)); /* Check for defaulting to GTC */ if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) active = 2; combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); g_assert (combo); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); g_object_unref (G_OBJECT (auth_model)); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); g_signal_connect (G_OBJECT (combo), "changed", (GCallback) inner_auth_combo_changed_cb, method); return combo; }
static void * file_configure (void) { GtkWidget * configure_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); GtkWidget * fileext_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start(GTK_BOX(configure_vbox), fileext_hbox, FALSE, FALSE, 0); GtkWidget * fileext_label = gtk_label_new (_("Output file format:")); gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_label, FALSE, FALSE, 0); fileext_combo = gtk_combo_box_text_new (); gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "WAV"); #ifdef FILEWRITER_MP3 gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "MP3"); #endif #ifdef FILEWRITER_VORBIS gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "Vorbis"); #endif #ifdef FILEWRITER_FLAC gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "FLAC"); #endif gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0); gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext); plugin_button = gtk_button_new_with_label(_("Configure")); gtk_widget_set_sensitive(plugin_button, plugin->configure != NULL); gtk_box_pack_end(GTK_BOX(fileext_hbox), plugin_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0); GtkWidget * saveplace_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox); GtkWidget * saveplace1 = gtk_radio_button_new_with_label (NULL, _("Save into original directory")); gtk_box_pack_start ((GtkBox *) saveplace_hbox, saveplace1, FALSE, FALSE, 0); GtkWidget * saveplace2 = gtk_radio_button_new_with_label_from_widget ((GtkRadioButton *) saveplace1, _("Save into custom directory")); if (!save_original) gtk_toggle_button_set_active ((GtkToggleButton *) saveplace2, TRUE); gtk_box_pack_start ((GtkBox *) saveplace_hbox, saveplace2, FALSE, FALSE, 0); path_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0); GtkWidget * path_label = gtk_label_new (_("Output file folder:")); gtk_box_pack_start ((GtkBox *) path_hbox, path_label, FALSE, FALSE, 0); path_dirbrowser = gtk_file_chooser_button_new (_("Pick a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_file_chooser_set_uri ((GtkFileChooser *) path_dirbrowser, file_path); gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0); if (save_original) gtk_widget_set_sensitive(path_hbox, FALSE); gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0); filenamefrom_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_container_add(GTK_CONTAINER(configure_vbox), filenamefrom_hbox); filenamefrom_label = gtk_label_new(_("Get filename from:")); gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_label, FALSE, FALSE, 0); GtkWidget * filenamefrom_toggle1 = gtk_radio_button_new_with_label (NULL, _("original file tags")); gtk_box_pack_start ((GtkBox *) filenamefrom_hbox, filenamefrom_toggle1, FALSE, FALSE, 0); GtkWidget * filenamefrom_toggle2 = gtk_radio_button_new_with_label_from_widget ((GtkRadioButton *) filenamefrom_toggle1, _("original filename")); gtk_box_pack_start ((GtkBox *) filenamefrom_hbox, filenamefrom_toggle2, FALSE, FALSE, 0); if (!filenamefromtags) gtk_toggle_button_set_active ((GtkToggleButton *) filenamefrom_toggle2, TRUE); use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix); gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0); if (filenamefromtags) gtk_widget_set_sensitive(use_suffix_toggle, FALSE); gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0); prependnumber_toggle = gtk_check_button_new_with_label(_("Prepend track number to filename")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prependnumber_toggle), prependnumber); gtk_box_pack_start(GTK_BOX(configure_vbox), prependnumber_toggle, FALSE, FALSE, 0); g_signal_connect (fileext_combo, "changed", (GCallback) fileext_cb, NULL); g_signal_connect (plugin_button, "clicked", (GCallback) plugin_configure_cb, NULL); g_signal_connect (saveplace1, "toggled", (GCallback) saveplace_original_cb, NULL); g_signal_connect (saveplace2, "toggled", (GCallback) saveplace_custom_cb, NULL); g_signal_connect (filenamefrom_toggle1, "toggled", (GCallback) filenamefromtags_cb, NULL); g_signal_connect (filenamefrom_toggle2, "toggled", (GCallback) filenamefromfilename_cb, NULL); return configure_vbox; }
void preferences_dialog_init (PreferencesDialog *pd) { GtkWidget *widget, *entry; GtkComboBox *combo; GtkListStore *store; GtkTreeIter treeiter; GtkAdjustment *itemCount; GtkTreeStore *treestore; GtkTreeViewColumn *column; GSList *list; gchar *proxyport; gchar *configuredBrowser, *name; gboolean enabled; static int manual; struct browser *iter; gint tmp, i, iSetting, proxy_port; gboolean bSetting; gchar *proxy_host, *proxy_user, *proxy_passwd; gchar *browser_command; prefdialog = pd; pd->priv = PREFERENCES_DIALOG_GET_PRIVATE (pd); pd->priv->dialog = liferea_dialog_new ("prefs.ui", "prefdialog"); /* Set up browser selection popup */ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for(i = 0, iter = browser_get_all (); iter->id != NULL; iter++, i++) { gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _(iter->display), 1, i, -1); } manual = i; /* This allows the user to choose their own browser by typing in the command. */ gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("Manual"), 1, i, -1); combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "browserpopup")); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); ui_common_setup_combo_text (combo, 0); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(on_browser_changed), pd); /* Create location menu */ store = gtk_list_store_new (1, G_TYPE_STRING); combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "browserlocpopup")); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); ui_common_setup_combo_text (combo, 0); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(on_browser_place_changed), pd); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("Browser default"), -1); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("Existing window"), -1); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("New window"), -1); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("New tab"), -1); /* ================== panel 1 "feeds" ==================== */ /* check box for feed startup update */ conf_get_int_value (STARTUP_FEED_ACTION, &iSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "startupactionbtn")), (iSetting == 0)); /* cache size setting */ widget = liferea_dialog_lookup (pd->priv->dialog, "itemCountBtn"); itemCount = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)); conf_get_int_value (DEFAULT_MAX_ITEMS, &iSetting); gtk_adjustment_set_value (itemCount, iSetting); /* set default update interval spin button and unit combo box */ ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "globalRefreshIntervalUnitComboBox"), default_update_interval_unit_options, G_CALLBACK (on_default_update_interval_unit_changed), -1); widget = liferea_dialog_lookup (pd->priv->dialog, "globalRefreshIntervalUnitComboBox"); conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &tmp); if (tmp % 1440 == 0) { /* days */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2); tmp /= 1440; } else if (tmp % 60 == 0) { /* hours */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); tmp /= 60; } else { /* minutes */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); } widget = liferea_dialog_lookup (pd->priv->dialog,"globalRefreshIntervalSpinButton"); gtk_spin_button_set_range (GTK_SPIN_BUTTON (widget), 0, 1000000000); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), tmp); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (on_default_update_interval_value_changed), pd); /* ================== panel 2 "folders" ==================== */ g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "updateAllFavicons")), "clicked", G_CALLBACK(on_updateallfavicons_clicked), pd); conf_get_int_value (FOLDER_DISPLAY_MODE, &iSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "folderdisplaybtn")), iSetting?TRUE:FALSE); conf_get_bool_value (FOLDER_DISPLAY_HIDE_READ, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "hidereadbtn")), bSetting?TRUE:FALSE); /* ================== panel 3 "headlines" ==================== */ conf_get_int_value (BROWSE_KEY_SETTING, &iSetting); ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "skimKeyCombo"), browser_skim_key_options, G_CALLBACK (on_skim_key_changed), iSetting); conf_get_int_value (DEFAULT_VIEW_MODE, &iSetting); ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "defaultViewModeCombo"), default_view_mode_options, G_CALLBACK (on_default_view_mode_changed), iSetting); /* Setup social bookmarking list */ i = 0; conf_get_str_value (SOCIAL_BM_SITE, &name); store = gtk_list_store_new (1, G_TYPE_STRING); list = bookmarkSites; while (list) { socialSitePtr siter = list->data; if (name && !strcmp (siter->name, name)) tmp = i; gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, siter->name, -1); list = g_slist_next (list); i++; } combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "socialpopup")); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (on_socialsite_changed), pd); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); ui_common_setup_combo_text (combo, 0); gtk_combo_box_set_active (combo, tmp); /* ================== panel 4 "browser" ==================== */ /* set the inside browsing flag */ widget = liferea_dialog_lookup(pd->priv->dialog, "browseinwindow"); conf_get_bool_value(BROWSE_INSIDE_APPLICATION, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting); /* set the javascript-disabled flag */ widget = liferea_dialog_lookup(pd->priv->dialog, "disablejavascript"); conf_get_bool_value(DISABLE_JAVASCRIPT, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting); /* set the enable Plugins flag */ widget = liferea_dialog_lookup(pd->priv->dialog, "enableplugins"); conf_get_bool_value(ENABLE_PLUGINS, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting); tmp = 0; conf_get_str_value(BROWSER_ID, &configuredBrowser); if(!strcmp(configuredBrowser, "manual")) tmp = manual; else for(i=0, iter = browser_get_all (); iter->id != NULL; iter++, i++) if(!strcmp(configuredBrowser, iter->id)) tmp = i; gtk_combo_box_set_active(GTK_COMBO_BOX(liferea_dialog_lookup(pd->priv->dialog, "browserpopup")), tmp); g_free(configuredBrowser); conf_get_int_value (BROWSER_PLACE, &iSetting); gtk_combo_box_set_active(GTK_COMBO_BOX(liferea_dialog_lookup(pd->priv->dialog, "browserlocpopup")), iSetting); conf_get_str_value (BROWSER_COMMAND, &browser_command); entry = liferea_dialog_lookup(pd->priv->dialog, "browsercmd"); gtk_entry_set_text(GTK_ENTRY(entry), browser_command); g_free (browser_command); gtk_widget_set_sensitive (GTK_WIDGET (entry), tmp == manual); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "manuallabel"), tmp == manual); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "urlhintlabel"), tmp == manual); /* ================== panel 4 "GUI" ================ */ /* tool bar settings */ widget = liferea_dialog_lookup (pd->priv->dialog, "hidetoolbarbtn"); conf_get_bool_value(DISABLE_TOOLBAR, &bSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting); /* select currently active toolbar style option */ conf_get_str_value (TOOLBAR_STYLE, &name); for (i = 0; gui_toolbar_style_values[i] != NULL; ++i) { if (strcmp (name, gui_toolbar_style_values[i]) == 0) break; } g_free (name); /* On invalid key value: revert to default */ if (gui_toolbar_style_values[i] == NULL) i = 0; /* create toolbar style menu */ ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "toolbarCombo"), gui_toolbar_style_options, G_CALLBACK (on_gui_toolbar_style_changed), i); /* ================= panel 5 "proxy" ======================== */ conf_get_str_value (PROXY_HOST, &proxy_host); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyhostentry")), proxy_host); g_free (proxy_host); conf_get_int_value (PROXY_PORT, &proxy_port); proxyport = g_strdup_printf ("%d", proxy_port); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyportentry")), proxyport); g_free (proxyport); conf_get_bool_value (PROXY_USEAUTH, &enabled); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "useProxyAuth")), enabled); conf_get_str_value (PROXY_USER, &proxy_user); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyusernameentry")), proxy_user); g_free (proxy_user); conf_get_str_value (PROXY_PASSWD, &proxy_passwd); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxypasswordentry")), proxy_passwd); g_free (proxy_passwd); gtk_widget_set_sensitive (GTK_WIDGET (liferea_dialog_lookup(pd->priv->dialog, "proxyauthtable")), enabled); conf_get_int_value (PROXY_DETECT_MODE, &i); switch (i) { default: case 0: /* proxy auto detect */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "proxyAutoDetectRadio")), TRUE); enabled = FALSE; break; case 1: /* no proxy */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "noProxyRadio")), TRUE); enabled = FALSE; break; case 2: /* manual proxy */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "manualProxyRadio")), TRUE); enabled = TRUE; break; } gtk_widget_set_sensitive (GTK_WIDGET (liferea_dialog_lookup (pd->priv->dialog, "proxybox")), enabled); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyAutoDetectRadio")), "clicked", G_CALLBACK (on_proxyAutoDetect_clicked), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "noProxyRadio")), "clicked", G_CALLBACK (on_noProxy_clicked), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "manualProxyRadio")), "clicked", G_CALLBACK (on_manualProxy_clicked), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyhostentry")), "changed", G_CALLBACK (on_proxyhostentry_changed), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyportentry")), "changed", G_CALLBACK (on_proxyportentry_changed), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyusernameentry")), "changed", G_CALLBACK (on_proxyusernameentry_changed), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxypasswordentry")), "changed", G_CALLBACK (on_proxypasswordentry_changed), pd); /* ================= panel 6 "Enclosures" ======================== */ /* menu for download tool */ conf_get_int_value (DOWNLOAD_TOOL, &iSetting); ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "downloadToolCombo"), enclosure_download_tool_options, G_CALLBACK (on_enclosure_download_tool_changed), iSetting); /* set up list of configured enclosure types */ treestore = gtk_tree_store_new (FTS_LEN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); list = (GSList *)enclosure_mime_types_get (); while (list) { GtkTreeIter *newIter = g_new0 (GtkTreeIter, 1); gtk_tree_store_append (treestore, newIter, NULL); gtk_tree_store_set (treestore, newIter, FTS_TYPE, (NULL != ((encTypePtr)(list->data))->mime)?((encTypePtr)(list->data))->mime:((encTypePtr)(list->data))->extension, FTS_CMD, ((encTypePtr)(list->data))->cmd, FTS_PTR, list->data, -1); list = g_slist_next (list); } widget = liferea_dialog_lookup (pd->priv->dialog, "enc_action_view"); gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (treestore)); column = gtk_tree_view_column_new_with_attributes (_("Type"), gtk_cell_renderer_text_new (), "text", FTS_TYPE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); gtk_tree_view_column_set_sort_column_id (column, FTS_TYPE); column = gtk_tree_view_column_new_with_attributes (_("Program"), gtk_cell_renderer_text_new (), "text", FTS_CMD, NULL); gtk_tree_view_column_set_sort_column_id (column, FTS_CMD); gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW(widget)), GTK_SELECTION_SINGLE); /* ================= panel 7 "Plugins" ======================== */ pd->priv->plugins_box = liferea_dialog_lookup (pd->priv->dialog, "plugins_box"); g_assert (pd->priv->plugins_box != NULL); GtkWidget *alignment; alignment = gtk_alignment_new (0., 0., 1., 1.); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12); widget = peas_gtk_plugin_manager_new (NULL); g_assert (widget != NULL); gtk_container_add (GTK_CONTAINER (alignment), widget); gtk_box_pack_start (GTK_BOX (pd->priv->plugins_box), alignment, TRUE, TRUE, 0); g_signal_connect_object (pd->priv->dialog, "destroy", G_CALLBACK (preferences_dialog_destroy_cb), pd, 0); gtk_widget_show_all (pd->priv->dialog); gtk_window_present (GTK_WINDOW (pd->priv->dialog)); }
/* * This function sets the custom list when the session list has changed in * the session dialog (launched from session button or F10 menu). */ void greeter_custom_set_session (gchar *session) { GList *tmp; int i=0; /* * Since the sessions are created before the session list is generated, * keep track of the session and set active row when it is setup. This * function will get a NULL when the session is initialized to NULL * at startup, so just return. */ if (session == NULL) return; else { /* * If the session_widget hasn't been setup yet (which it won't be when * the greeter_sessioninit function is called, then just store the * session and we'll set the value when the combo box is initialized later. */ g_free (session_key); session_key = g_strdup (session); } /* Do nothing if there is no session widget */ if (session_widget == NULL) return; /* Last isn't in the session list, so handle separate. */ if (strcmp (session, LAST_SESSION) == 0) { if (GTK_IS_COMBO_BOX (session_widget)) { gtk_combo_box_set_active (GTK_COMBO_BOX (session_widget), 0); } else if (GTK_IS_SCROLLED_WINDOW (session_widget) && GTK_IS_TREE_VIEW (GTK_BIN (session_widget)->child)) { GtkTreeView *tv = GTK_TREE_VIEW (GTK_BIN (session_widget)->child); GtkTreeModel *tm = gtk_tree_view_get_model (tv); GtkTreeSelection *selection = gtk_tree_view_get_selection (tv); GtkTreeIter loopiter; if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tm), &loopiter)) gtk_tree_selection_select_iter (selection, &loopiter); } } /* * Handle for either combo box or list style, depending on which is being * used. . */ if (GTK_IS_COMBO_BOX (session_widget)) { for (tmp = sessions; tmp != NULL; tmp = tmp->next) { char *file; i++; file = tmp->data; if (strcmp (session, file) == 0) { gtk_combo_box_set_active (GTK_COMBO_BOX (session_widget), i); break; } } } else if (GTK_IS_SCROLLED_WINDOW (session_widget) && GTK_IS_TREE_VIEW (GTK_BIN (session_widget)->child)) { GtkTreeView *tv = GTK_TREE_VIEW (GTK_BIN (session_widget)->child); GtkTreeModel *tm = gtk_tree_view_get_model (tv); GtkTreeSelection *selection = gtk_tree_view_get_selection (tv); GtkTreeIter loopiter; if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tm), &loopiter)) { do { char *file; gtk_tree_model_get (GTK_TREE_MODEL (tm), &loopiter, GREETER_LIST_ID, &file, -1); if (file != NULL && strcmp (session, file) == 0) { GtkTreePath *path = gtk_tree_model_get_path (tm, &loopiter); gtk_tree_selection_select_iter (selection, &loopiter); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv), path, NULL, FALSE, 0.0, 0.0); gtk_tree_path_free (path); break; } } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tm), &loopiter)); } } }
void prefsbox_open (void) { GtkWidget *notebook; GtkWidget *grid; GtkWidget *controls_list; GtkWidget *label; GtkCellRenderer *renderer; GtkListStore *model; GtkTreeIter iter; gint i; if (prefsbox != NULL) { gtk_window_present (GTK_WINDOW (prefsbox)); return; } prefsbox = gtk_dialog_new_with_buttons (_("Four-in-a-Row Preferences"), GTK_WINDOW (app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL); gtk_container_set_border_width (GTK_CONTAINER (prefsbox), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefsbox))), 2); g_signal_connect (G_OBJECT (prefsbox), "destroy", G_CALLBACK (gtk_widget_destroyed), &prefsbox); notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (notebook), 5); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefsbox))), notebook, TRUE, TRUE, 0); /* game tab */ grid = gtk_grid_new (); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_grid_set_column_spacing (GTK_GRID (grid), 12); gtk_container_set_border_width (GTK_CONTAINER (grid), 12); label = gtk_label_new (_("Game")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), grid, label); label = gtk_label_new (_("Player One:")); gtk_widget_set_hexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); combobox1 = gtk_combo_box_new (); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox1), renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox1), renderer, "text", 0); model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); gtk_combo_box_set_model (GTK_COMBO_BOX (combobox1), GTK_TREE_MODEL (model)); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Human"), 1, LEVEL_HUMAN, -1); if (p.level[PLAYER1] == LEVEL_HUMAN) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Level one"), 1, LEVEL_WEAK, -1); if (p.level[PLAYER1] == LEVEL_WEAK) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Level two"), 1, LEVEL_MEDIUM, -1); if (p.level[PLAYER1] == LEVEL_MEDIUM) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Level three"), 1, LEVEL_STRONG, -1); if (p.level[PLAYER1] == LEVEL_STRONG) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter); g_signal_connect (combobox1, "changed", G_CALLBACK (on_select_player1), NULL); gtk_grid_attach (GTK_GRID (grid), combobox1, 1, 0, 1, 1); label = gtk_label_new (_("Player Two:")); gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); combobox2 = gtk_combo_box_new (); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox2), renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox2), renderer, "text", 0); model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); gtk_combo_box_set_model (GTK_COMBO_BOX (combobox2), GTK_TREE_MODEL (model)); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Human"), 1, LEVEL_HUMAN, -1); if (p.level[PLAYER2] == LEVEL_HUMAN) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Level one"), 1, LEVEL_WEAK, -1); if (p.level[PLAYER2] == LEVEL_WEAK) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Level two"), 1, LEVEL_MEDIUM, -1); if (p.level[PLAYER2] == LEVEL_MEDIUM) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, 0, _("Level three"), 1, LEVEL_STRONG, -1); if (p.level[PLAYER2] == LEVEL_STRONG) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter); g_signal_connect (combobox2, "changed", G_CALLBACK (on_select_player2), NULL); gtk_grid_attach (GTK_GRID (grid), combobox2, 1, 1, 1, 1); label = gtk_label_new_with_mnemonic (_("_Theme:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); combobox_theme = gtk_combo_box_text_new (); for (i = 0; i < n_themes; i++) { gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox_theme), _(theme_get_title (i))); } gtk_label_set_mnemonic_widget (GTK_LABEL (label), combobox_theme); gtk_grid_attach (GTK_GRID (grid), combobox_theme, 1, 2, 1, 1); checkbutton_animate = gtk_check_button_new_with_mnemonic (_("Enable _animation")); gtk_grid_attach (GTK_GRID (grid), checkbutton_animate, 0, 3, 2, 1); checkbutton_sound = gtk_check_button_new_with_mnemonic (_("E_nable sounds")); gtk_grid_attach (GTK_GRID (grid), checkbutton_sound, 0, 4, 2, 1); /* keyboard tab */ label = gtk_label_new_with_mnemonic (_("Keyboard Controls")); controls_list = games_controls_list_new (settings); games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list), "key-left", _("Move left"), DEFAULT_KEY_LEFT, "key-right", _("Move right"), DEFAULT_KEY_RIGHT, "key-drop", _("Drop marble"), DEFAULT_KEY_DROP, NULL); gtk_container_set_border_width (GTK_CONTAINER (controls_list), 12); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), controls_list, label); /* fill in initial values */ gtk_combo_box_set_active (GTK_COMBO_BOX (combobox_theme), p.theme_id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_animate), p.do_animate); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_sound), p.do_sound); /* connect signals */ g_signal_connect (prefsbox, "response", G_CALLBACK (on_dialog_close), &prefsbox); g_signal_connect (G_OBJECT (combobox_theme), "changed", G_CALLBACK (on_select_theme), NULL); g_signal_connect (G_OBJECT (checkbutton_animate), "toggled", G_CALLBACK (on_toggle_animate), NULL); g_signal_connect (G_OBJECT (checkbutton_sound), "toggled", G_CALLBACK (on_toggle_sound), NULL); gtk_widget_show_all (prefsbox); }
/* * This function sets the custom list when the language list has changed in * the language dialog (launched from language button or F10 menu). */ void lang_set_custom_callback (gchar *language) { GtkListStore *lang_model = mdm_lang_get_model (); GtkTreeIter iter; gboolean valid; char *locale_name; int i=0; /* Do nothing if there is no language widget */ if (language_widget == NULL) return; /* * Handle for either combo box or list style, depending on which is being * used. . */ if (GTK_IS_COMBO_BOX (language_widget)) { valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (lang_model), &iter); while (valid) { gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter, LOCALE_COLUMN, &locale_name, -1); if (strcmp (language, locale_name) == 0) { gtk_combo_box_set_active (GTK_COMBO_BOX (language_widget), i); break; } valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (lang_model), &iter); i++; } } else if (GTK_IS_SCROLLED_WINDOW (language_widget) && GTK_IS_TREE_VIEW (GTK_BIN (language_widget)->child)) { GtkTreeView *tv = GTK_TREE_VIEW (GTK_BIN (language_widget)->child); GtkTreeModel *tm = gtk_tree_view_get_model (tv); GtkTreeSelection *selection = gtk_tree_view_get_selection (tv); GtkTreeIter loopiter; if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tm), &loopiter)) { do { char *locale_file; gtk_tree_model_get (GTK_TREE_MODEL (tm), &loopiter, GREETER_LIST_ID, &locale_file, -1); if (locale_file != NULL && strcmp (language, locale_file) == 0) { GtkTreePath *path = gtk_tree_model_get_path (tm, &loopiter); gtk_tree_selection_select_iter (selection, &loopiter); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv), path, NULL, FALSE, 0.0, 0.0); gtk_tree_path_free (path); break; } } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tm), &loopiter)); } } }
int main (int argc, char *argv[]) { GtkWidget *win; GtkWidget *box; GtkWidget *button; GtkWidget *button2; GtkBuilder *builder; GMenuModel *model; GSimpleActionGroup *actions; GtkWidget *overlay; GtkWidget *grid; GtkWidget *popover; GtkWidget *popover2; GtkWidget *label; GtkWidget *check; GtkWidget *combo; GtkWidget *header_bar; #ifdef GTK_SRCDIR g_chdir (GTK_SRCDIR); #endif gtk_init (); win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (win), 400, 600); header_bar = gtk_header_bar_new (); gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header_bar), TRUE); gtk_window_set_titlebar (GTK_WINDOW (win), header_bar); gtk_window_set_title (GTK_WINDOW (win), "Test GtkPopover"); actions = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), NULL); gtk_widget_insert_action_group (win, "top", G_ACTION_GROUP (actions)); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (win), overlay); grid = gtk_grid_new (); gtk_widget_set_halign (grid, GTK_ALIGN_FILL); gtk_widget_set_valign (grid, GTK_ALIGN_FILL); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); gtk_container_add (GTK_CONTAINER (overlay), grid); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_vexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_vexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1); builder = gtk_builder_new_from_file ("popover.ui"); model = (GMenuModel *)gtk_builder_get_object (builder, "menu"); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); button = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button); button2 = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button2); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model); gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE); popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button))); builder = gtk_builder_new_from_file ("popover2.ui"); popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover"); gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2); g_object_set (box, "margin", 10, NULL); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box); label = gtk_label_new ("Popover hexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_SYNC_CREATE); g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1); label = gtk_label_new ("Popover vexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_SYNC_CREATE); g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1); label = gtk_label_new ("Button direction"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "up", "Up"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right"); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1); g_object_bind_property (combo, "active", button, "direction", G_BINDING_SYNC_CREATE); g_object_bind_property (combo, "active", button2, "direction", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1); label = gtk_label_new ("Button halign"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 2); g_object_bind_property (combo, "active", box, "halign", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1); label = gtk_label_new ("Button valign"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1); g_object_bind_property (combo, "active", box, "valign", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1); g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (win); gtk_main (); return 0; }
static GtkWidget * create_window (void) { GtkWidget *window; GtkWidget *hbox, *vbox, *widget; GtkWidget *swindow, *frame, *expander; GtkWidget *paper_cntl, *items_cntl; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); hbox = gtk_hbox_new (FALSE, 2); vbox = gtk_vbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (window), 8); gtk_widget_show (vbox); gtk_widget_show (hbox); gtk_container_add (GTK_CONTAINER (window), hbox); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new ("SpreadTable"); gtk_widget_show (frame); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); swindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show (swindow); gtk_container_add (GTK_CONTAINER (frame), swindow); paper = egg_spread_table_new (GTK_ORIENTATION_VERTICAL, INITIAL_LINES); egg_spread_table_set_vertical_spacing (EGG_SPREAD_TABLE (paper), INITIAL_VSPACING); egg_spread_table_set_horizontal_spacing (EGG_SPREAD_TABLE (paper), INITIAL_HSPACING); gtk_widget_show (paper); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), paper); /* Add SpreadTable test control frame */ expander = gtk_expander_new ("SpreadTable controls"); gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE); paper_cntl = gtk_vbox_new (FALSE, 2); gtk_widget_show (paper_cntl); gtk_widget_show (expander); gtk_container_add (GTK_CONTAINER (expander), paper_cntl); gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0); /* Add Orientation control */ widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Set the spread_table orientation"); gtk_box_pack_start (GTK_BOX (paper_cntl), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (orientation_changed), paper); /* Add horizontal/vertical spacing controls */ hbox = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox); widget = gtk_label_new ("H Spacing"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (0, 30, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_HSPACING); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Set the horizontal spacing between children"); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL)); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL)); gtk_box_pack_start (GTK_BOX (paper_cntl), hbox, FALSE, FALSE, 0); hbox = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox); widget = gtk_label_new ("V Spacing"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (0, 30, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_VSPACING); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Set the vertical spacing between children"); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL)); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL)); gtk_box_pack_start (GTK_BOX (paper_cntl), hbox, FALSE, FALSE, 0); /* Add lines controls */ hbox = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox); widget = gtk_label_new ("Lines"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (1, 30, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_LINES); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Set the horizontal spacing between children"); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (lines_changed), NULL); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (lines_changed), NULL); gtk_box_pack_start (GTK_BOX (paper_cntl), hbox, FALSE, FALSE, 0); /* Add test items control frame */ expander = gtk_expander_new ("Test item controls"); gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE); items_cntl = gtk_vbox_new (FALSE, 2); gtk_widget_show (items_cntl); gtk_widget_show (expander); gtk_container_add (GTK_CONTAINER (expander), items_cntl); gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0); /* Add child halign control */ widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Fill"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Start"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "End"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Center"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_HALIGN); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Set the children's halign property"); gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (halign_changed), paper); /* Add image control */ widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "None"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Small"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Large"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Huge"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_IMAGE); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Use an image to test the container"); gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (test_image_changed), paper); /* Add horizontal/vertical spacing controls */ hbox = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox); widget = gtk_label_new ("Image index"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (0, 25, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_IMAGE_INDEX); gtk_widget_show (widget); gtk_widget_set_tooltip_text (widget, "Set the child list index for the optional test image"); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (test_image_index_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL)); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (test_image_index_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL)); populate_spread_table_wrappy (EGG_SPREAD_TABLE (paper)); gtk_window_set_default_size (GTK_WINDOW (window), 500, 400); return window; }
static void add_or_remove (XedEncodingsComboBox *menu, GtkTreeModel *model) { GtkTreeIter iter; gboolean add_item = FALSE; if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (menu), &iter)) { gtk_tree_model_get (model, &iter, ADD_COLUMN, &add_item, -1); } if (!add_item) { menu->priv->activated_item = gtk_combo_box_get_active (GTK_COMBO_BOX (menu)); } else { GtkWidget *dialog; GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu)); if (!gtk_widget_is_toplevel (toplevel)) toplevel = NULL; g_signal_handler_block (menu, menu->priv->changed_id); gtk_combo_box_set_active (GTK_COMBO_BOX (menu), menu->priv->activated_item); g_signal_handler_unblock (menu, menu->priv->changed_id); dialog = xed_encodings_dialog_new(); if (toplevel != NULL) { GtkWindowGroup *wg; gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); wg = gtk_window_get_group (GTK_WINDOW (toplevel)); if (wg == NULL) { wg = gtk_window_group_new (); gtk_window_group_add_window (wg, GTK_WINDOW (toplevel)); } gtk_window_group_add_window (wg, GTK_WINDOW (dialog)); } gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), menu); gtk_widget_show (dialog); } }
void gui_init(dt_lib_module_t *self) { unsigned int i; GtkWidget *container = gtk_vbox_new(FALSE, 5); GtkWidget *output_row = gtk_hbox_new(FALSE, 2); GtkWidget *output_options = gtk_vbox_new(FALSE, 5); GtkWidget *picker_subrow = gtk_hbox_new(FALSE, 2); GtkWidget *restrict_button; GtkWidget *samples_label = dtgtk_label_new(_("live samples"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); GtkWidget *samples_options_row = gtk_hbox_new(FALSE, 2); // Initializing self data structure dt_lib_colorpicker_t *data = (dt_lib_colorpicker_t*)malloc(sizeof(dt_lib_colorpicker_t)); self->data = (void*)data; memset(data, 0, sizeof(dt_lib_colorpicker_t)); // Initializing proxy functions and data darktable.lib->proxy.colorpicker.module = self; darktable.lib->proxy.colorpicker.size = dt_conf_get_int("ui_last/colorpicker_size"); darktable.lib->proxy.colorpicker.display_samples = dt_conf_get_int("ui_last/colorpicker_display_samples"); darktable.lib->proxy.colorpicker.live_samples = NULL; darktable.lib->proxy.colorpicker.picked_color_rgb_mean = (uint8_t*)malloc(sizeof(uint8_t) * 3); darktable.lib->proxy.colorpicker.picked_color_rgb_min = (uint8_t*)malloc(sizeof(uint8_t) * 3); darktable.lib->proxy.colorpicker.picked_color_rgb_max = (uint8_t*)malloc(sizeof(uint8_t) * 3); darktable.lib->proxy.colorpicker.picked_color_lab_mean = (float*)malloc(sizeof(float) * 3); darktable.lib->proxy.colorpicker.picked_color_lab_min = (float*)malloc(sizeof(float) * 3); darktable.lib->proxy.colorpicker.picked_color_lab_max = (float*)malloc(sizeof(float) * 3); for(i = 0; i < 3; i++) darktable.lib->proxy.colorpicker.picked_color_rgb_mean[i] = darktable.lib->proxy.colorpicker.picked_color_rgb_min[i] = darktable.lib->proxy.colorpicker.picked_color_rgb_max[i] = 0; for(i = 0; i < 3; i++) darktable.lib->proxy.colorpicker.picked_color_lab_mean[i] = darktable.lib->proxy.colorpicker.picked_color_lab_min[i] = darktable.lib->proxy.colorpicker.picked_color_lab_max[i] = 0; darktable.lib->proxy.colorpicker.update_panel = _update_picker_output; darktable.lib->proxy.colorpicker.update_samples = _update_samples_output; darktable.lib->proxy.colorpicker.set_sample_area = _set_sample_area; darktable.lib->proxy.colorpicker.set_sample_point = _set_sample_point; // Setting up the GUI self->widget = container; gtk_box_pack_start(GTK_BOX(container), output_row, TRUE, TRUE, 0); // The output button data->output_button = dtgtk_button_new(NULL, CPF_STYLE_BOX); gtk_widget_set_size_request(data->output_button, 100, 100); gtk_widget_set_sensitive(data->output_button, FALSE); gtk_box_pack_start(GTK_BOX(output_row), data->output_button, FALSE, FALSE, 0); // The picker button, output selectors and label gtk_box_pack_start(GTK_BOX(output_row), output_options, TRUE, TRUE, 0); data->size_selector = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->size_selector), _("point")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->size_selector), _("area")); gtk_combo_box_set_active(GTK_COMBO_BOX(data->size_selector), dt_conf_get_int("ui_last/colorpicker_size")); gtk_widget_set_size_request(data->size_selector, 30, -1); gtk_box_pack_start(GTK_BOX(picker_subrow), data->size_selector, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(data->size_selector), "changed", G_CALLBACK(_size_changed), (gpointer)self); data->picker_button = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_BOX); gtk_widget_set_size_request(data->picker_button, 50, -1); gtk_box_pack_start(GTK_BOX(picker_subrow), data->picker_button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(data->picker_button), "toggled", G_CALLBACK(_picker_button_toggled), self); gtk_box_pack_start(GTK_BOX(output_options), picker_subrow, TRUE, TRUE, 0); data->statistic_selector = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->statistic_selector), _("mean")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->statistic_selector), _("min")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->statistic_selector), _("max")); gtk_combo_box_set_active(GTK_COMBO_BOX(data->statistic_selector), dt_conf_get_int("ui_last/colorpicker_mode")); gtk_widget_set_sensitive(data->statistic_selector, dt_conf_get_int("ui_last/colorpicker_size")); gtk_box_pack_start(GTK_BOX(output_options), data->statistic_selector, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(data->statistic_selector), "changed", G_CALLBACK(_statistic_changed), self); data->color_mode_selector = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->color_mode_selector), _("RGB")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->color_mode_selector), _("Lab")); gtk_combo_box_set_active(GTK_COMBO_BOX(data->color_mode_selector), dt_conf_get_int("ui_last/colorpicker_model")); gtk_box_pack_start(GTK_BOX(output_options), data->color_mode_selector, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(data->color_mode_selector), "changed", G_CALLBACK(_color_mode_changed), self); data->output_label = gtk_label_new(""); gtk_label_set_justify(GTK_LABEL(data->output_label), GTK_JUSTIFY_CENTER); gtk_widget_set_size_request(data->output_label, 80, -1); gtk_box_pack_start(GTK_BOX(output_options), data->output_label, FALSE, FALSE, 0); restrict_button = gtk_check_button_new_with_label( _("restrict histogram to selection")); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(restrict_button), dt_conf_get_int("ui_last/colorpicker_restrict_histogram")); darktable.lib->proxy.colorpicker.restrict_histogram = dt_conf_get_int("ui_last/colorpicker_restrict_histogram"); gtk_box_pack_start(GTK_BOX(container), restrict_button, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(restrict_button), "toggled", G_CALLBACK(_restrict_histogram_changed), NULL); // Adding the live samples section gtk_box_pack_start(GTK_BOX(container), samples_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(container), samples_options_row, TRUE, TRUE, 0); data->samples_statistic_selector = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->samples_statistic_selector), _("mean")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->samples_statistic_selector), _("min")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->samples_statistic_selector), _("max")); gtk_combo_box_set_active(GTK_COMBO_BOX(data->samples_statistic_selector), dt_conf_get_int("ui_last/colorsamples_mode")); gtk_box_pack_start(GTK_BOX(samples_options_row), data->samples_statistic_selector, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(data->samples_statistic_selector), "changed", G_CALLBACK(_samples_statistic_changed), self); data->samples_mode_selector = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->samples_mode_selector), _("RGB")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(data->samples_mode_selector), _("Lab")); gtk_combo_box_set_active(GTK_COMBO_BOX(data->samples_mode_selector), dt_conf_get_int("ui_last/colorsamples_model")); gtk_box_pack_start(GTK_BOX(samples_options_row), data->samples_mode_selector, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(data->samples_mode_selector), "changed", G_CALLBACK(_samples_mode_changed), self); data->add_sample_button = gtk_button_new_from_stock(GTK_STOCK_ADD); gtk_widget_set_sensitive(data->add_sample_button, FALSE); gtk_box_pack_start(GTK_BOX(samples_options_row), data->add_sample_button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(data->add_sample_button), "clicked", G_CALLBACK(_add_sample), self); data->samples_container = gtk_vbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(container), data->samples_container, TRUE, TRUE, 0); data->display_samples_check_box = gtk_check_button_new_with_label(_("display sample areas on image")); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(data->display_samples_check_box), dt_conf_get_int("ui_last/colorpicker_display_samples")); gtk_box_pack_start(GTK_BOX(container), data->display_samples_check_box, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(data->display_samples_check_box), "toggled", G_CALLBACK(_display_samples_changed), NULL); }
static void update_menu (XedEncodingsComboBox *menu) { GtkListStore *store; GtkTreeIter iter; GSList *encodings, *l; gchar *str; const XedEncoding *utf8_encoding; const XedEncoding *current_encoding; store = menu->priv->store; /* Unset the previous model */ g_signal_handler_block (menu, menu->priv->changed_id); gtk_list_store_clear (store); gtk_combo_box_set_model (GTK_COMBO_BOX (menu), NULL); utf8_encoding = xed_encoding_get_utf8 (); current_encoding = xed_encoding_get_current (); if (!menu->priv->save_mode) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, NAME_COLUMN, _("Automatically Detected"), ENCODING_COLUMN, NULL, ADD_COLUMN, FALSE, -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, NAME_COLUMN, "", ENCODING_COLUMN, NULL, ADD_COLUMN, FALSE, -1); } if (current_encoding != utf8_encoding) str = xed_encoding_to_string (utf8_encoding); else str = g_strdup_printf (_("Current Locale (%s)"), xed_encoding_get_charset (utf8_encoding)); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, NAME_COLUMN, str, ENCODING_COLUMN, utf8_encoding, ADD_COLUMN, FALSE, -1); g_free (str); if ((utf8_encoding != current_encoding) && (current_encoding != NULL)) { str = g_strdup_printf (_("Current Locale (%s)"), xed_encoding_get_charset (current_encoding)); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, NAME_COLUMN, str, ENCODING_COLUMN, current_encoding, ADD_COLUMN, FALSE, -1); g_free (str); } encodings = xed_prefs_manager_get_shown_in_menu_encodings (); for (l = encodings; l != NULL; l = g_slist_next (l)) { const XedEncoding *enc = (const XedEncoding *)l->data; if ((enc != current_encoding) && (enc != utf8_encoding) && (enc != NULL)) { str = xed_encoding_to_string (enc); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, NAME_COLUMN, str, ENCODING_COLUMN, enc, ADD_COLUMN, FALSE, -1); g_free (str); } } g_slist_free (encodings); if (xed_prefs_manager_shown_in_menu_encodings_can_set ()) { gtk_list_store_append (store, &iter); /* separator */ gtk_list_store_set (store, &iter, NAME_COLUMN, "", ENCODING_COLUMN, NULL, ADD_COLUMN, FALSE, -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, NAME_COLUMN, _("Add or Remove..."), ENCODING_COLUMN, NULL, ADD_COLUMN, TRUE, -1); } /* set the model back */ gtk_combo_box_set_model (GTK_COMBO_BOX (menu), GTK_TREE_MODEL (menu->priv->store)); gtk_combo_box_set_active (GTK_COMBO_BOX (menu), 0); g_signal_handler_unblock (menu, menu->priv->changed_id); }
/** \brief Create and initialise widgets */ static GtkWidget *create_editor_widgets(rotor_conf_t * conf) { GtkWidget *table; GtkWidget *label; table = gtk_table_new(7, 4, FALSE); gtk_container_set_border_width(GTK_CONTAINER(table), 5); gtk_table_set_col_spacings(GTK_TABLE(table), 5); gtk_table_set_row_spacings(GTK_TABLE(table), 5); /* Config name */ label = gtk_label_new(_("Name")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); name = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(name), 25); gtk_widget_set_tooltip_text(name, _("Enter a short name for this configuration, " " e.g. ROTOR-1.\n" "Allowed characters: 0..9, a..z, A..Z, - and _")); gtk_table_attach_defaults(GTK_TABLE(table), name, 1, 4, 0, 1); /* attach changed signal so that we can enable OK button when a proper name has been entered */ g_signal_connect(name, "changed", G_CALLBACK(name_changed), NULL); /* Host */ label = gtk_label_new(_("Host")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); host = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(host), 50); gtk_entry_set_text(GTK_ENTRY(host), "localhost"); gtk_widget_set_tooltip_text(host, _("Enter the host where rotctld is running. " "You can use both host name and IP address, " "e.g. 192.168.1.100\n\n" "If gpredict and rotctld are running on the " "same computer, use localhost")); gtk_table_attach_defaults(GTK_TABLE(table), host, 1, 4, 1, 2); /* port */ label = gtk_label_new(_("Port")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); port = gtk_spin_button_new_with_range(1024, 65535, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), 4533); gtk_spin_button_set_digits(GTK_SPIN_BUTTON(port), 0); gtk_widget_set_tooltip_text(port, _("Enter the port number where rotctld is " "listening. Default is 4533.")); gtk_table_attach_defaults(GTK_TABLE(table), port, 1, 2, 2, 3); gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0, 4, 3, 4); /* Az-type */ label = gtk_label_new(_("Az type")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5); aztype = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(aztype), "0\302\260 \342\206\222 180\302\260 \342\206\222 360\302\260"); gtk_combo_box_append_text(GTK_COMBO_BOX(aztype), "-180\302\260 \342\206\222 0\302\260 \342\206\222 +180\302\260"); gtk_combo_box_set_active(GTK_COMBO_BOX(aztype), 0); gtk_widget_set_tooltip_text(aztype, _("Select your azimuth range here. Note that " "gpredict assumes that 0\302\260 is at North " "and + direction is clockwise for both types")); gtk_table_attach_defaults(GTK_TABLE(table), aztype, 1, 3, 4, 5); g_signal_connect(G_OBJECT(aztype), "changed", G_CALLBACK(aztype_changed_cb), NULL); /* Az and El limits */ label = gtk_label_new(_(" Min Az")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6); minaz = gtk_spin_button_new_with_range(-200, 100, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(minaz), 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(minaz), TRUE); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(minaz), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), minaz, 1, 2, 5, 6); label = gtk_label_new(_(" Max Az")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 5, 6); maxaz = gtk_spin_button_new_with_range(0, 450, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(maxaz), 360); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(maxaz), TRUE); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(maxaz), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), maxaz, 3, 4, 5, 6); label = gtk_label_new(_(" Min El")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 6, 7); minel = gtk_spin_button_new_with_range(-10, 180, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(minel), 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(minel), TRUE); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(minel), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), minel, 1, 2, 6, 7); label = gtk_label_new(_(" Max El")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 6, 7); maxel = gtk_spin_button_new_with_range(-10, 180, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(maxel), 90); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(maxel), TRUE); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(maxel), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), maxel, 3, 4, 6, 7); label = gtk_label_new(_(" Azimuth end stop position")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 7, 8); azstoppos = gtk_spin_button_new_with_range(-180, 360, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(azstoppos), 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(azstoppos), TRUE); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(azstoppos), FALSE); gtk_widget_set_tooltip_text(azstoppos, _("Set the position of the azimuth end stop " "here, where 0\302\260 is at North, " "-180\302\260 is south, etc. " "The default for a 0\302\260 \342\206\222 " "180\302\260 \342\206\222 360\302\260 rotor " "is 0\302\260, and the default for a " "-180\302\260 \342\206\222 0\302\260 " "\342\206\222 +180\302\260 rotor is -180\302\260.")); gtk_table_attach_defaults(GTK_TABLE(table), azstoppos, 3, 4, 7, 8); if (conf->name != NULL) update_widgets(conf); gtk_widget_show_all(table); return table; }
int set_params (dt_lib_module_t *self, const void *params, int size) { dt_lib_export_t *d = (dt_lib_export_t *)self->data; // apply these stored presets again (parse blob) const char *buf = (const char* )params; const int max_width = *(const int *)buf; buf += sizeof(int32_t); const int max_height = *(const int *)buf; buf += sizeof(int32_t); const int iccintent = *(const int *)buf; buf += sizeof(int32_t); const char *iccprofile = buf; buf += strlen(iccprofile) + 1; // reverse these by setting the gui, not the conf vars! gtk_combo_box_set_active (d->intent, iccintent + 1); if(!strcmp(iccprofile, "image")) { gtk_combo_box_set_active(d->profile, 0); } else { GList *prof = d->profiles; while(prof) { dt_lib_export_profile_t *pp = (dt_lib_export_profile_t *)prof->data; if(!strcmp(pp->filename, iccprofile)) { gtk_combo_box_set_active(d->profile, pp->pos); break; } prof = g_list_next(prof); } } // parse both names to '\0' const char *fname = buf; buf += strlen(fname) + 1; const char *sname = buf; buf += strlen(sname) + 1; // get module by name and fail if not there. dt_imageio_module_format_t *fmod = dt_imageio_get_format_by_name(fname); dt_imageio_module_storage_t *smod = dt_imageio_get_storage_by_name(sname); if(!fmod || !smod) return 1; const int fsize = *(const int *)buf; buf += sizeof(int32_t); const int ssize = *(const int *)buf; buf += sizeof(int32_t); if(size != strlen(fname) + strlen(sname) + 2 + 2*sizeof(int32_t) + fsize + ssize + 3*sizeof(int32_t) + strlen(iccprofile) + 1) return 1; const dt_imageio_module_data_t *fdata = (const dt_imageio_module_data_t *)buf; if (fdata->style[0] == '\0') gtk_combo_box_set_active(d->style, 0); else _combo_box_set_active_text(d->style, fdata->style); buf += fsize; const void *sdata = buf; // switch modules set_storage_by_name(d, sname); set_format_by_name(d, fname); // set dimensions after switching, to have new range ready. gtk_spin_button_set_value(d->width, max_width); gtk_spin_button_set_value(d->height, max_height); // propagate to modules int res = 0; if(ssize) res += smod->set_params(smod, sdata, ssize); if(fsize) res += fmod->set_params(fmod, fdata, fsize); return res; }
/* Load the tag editor */ gboolean gimmix_tag_editor_populate (const void *song) { GtkTreeModel *genre_model; gchar *info; gint n; guint year = 0; guint track = 0; gchar *title = NULL; gchar *artist = NULL; gchar *album = NULL; gchar *genre = NULL; gchar *comment = NULL; if (!song) return FALSE; #ifdef HAVE_TAGEDITOR const TagLib_AudioProperties *properties; if (!g_file_test(song,G_FILE_TEST_EXISTS)) return FALSE; file = taglib_file_new (song); if (file == NULL) return FALSE; taglib_set_strings_unicode (FALSE); tag = taglib_file_tag (file); properties = taglib_file_audioproperties (file); #else mpd_Song *foo = (mpd_Song*) g_malloc0 (sizeof(mpd_Song)); memcpy (foo, song, sizeof(mpd_Song)); #endif #ifdef HAVE_TAGEDITOR year = taglib_tag_year (tag); track = taglib_tag_track (tag); title = g_strstrip (taglib_tag_title(tag)); artist = g_strstrip (taglib_tag_artist(tag)); album = g_strstrip (taglib_tag_album(tag)); comment = g_strstrip (taglib_tag_comment(tag)); genre = taglib_tag_genre (tag); #else if (foo->date) { year = atoi (foo->date); } if (foo->track) { track = atoi (foo->track); } title = foo->title; artist = foo->artist; album = foo->album; comment = foo->comment; genre = foo->genre; #endif gtk_spin_button_set_value (GTK_SPIN_BUTTON(tag_year_spin), year); gtk_spin_button_set_value (GTK_SPIN_BUTTON(tag_track_spin), track); gtk_entry_set_text (GTK_ENTRY(tag_file), #ifdef HAVE_TAGEDITOR song #else foo->file #endif ); if (title) { gtk_entry_set_text (GTK_ENTRY(tag_title), title); } if (artist) { gtk_entry_set_text (GTK_ENTRY(tag_artist), artist); } if (album) { gtk_entry_set_text (GTK_ENTRY(tag_album), album); } if (comment) { gtk_entry_set_text (GTK_ENTRY(tag_comment), comment); } if (genre) { gtk_combo_box_append_text (GTK_COMBO_BOX(tag_genre), genre); } genre_model = gtk_combo_box_get_model (GTK_COMBO_BOX(tag_genre)); n = gtk_tree_model_iter_n_children (genre_model, NULL); gtk_combo_box_set_active (GTK_COMBO_BOX(tag_genre), n-1); /* Audio Information */ #ifdef HAVE_TAGEDITOR guint sec = taglib_audioproperties_length(properties) % 60; guint min = (taglib_audioproperties_length(properties) - sec) / 60; info = g_strdup_printf ("%02i:%02i", min, sec); gtk_label_set_text (GTK_LABEL(tag_info_length), info); #else char *tok = NULL; info = (char*) g_malloc0 (sizeof(char)*32); gimmix_get_progress_status (gmo, NULL, info); tok = strtok (info, "/"); tok = strtok (NULL, "/"); g_strstrip (tok); gtk_label_set_text (GTK_LABEL(tag_info_length), tok); #endif g_free (info); #ifdef HAVE_TAGEDITOR info = g_strdup_printf ("%i Kbps", taglib_audioproperties_bitrate(properties)); #else info = g_strdup_printf ("%i Kbps", mpd_status_get_bitrate(gmo)); #endif gtk_label_set_text (GTK_LABEL(tag_info_bitrate), info); g_free (info); #ifdef HAVE_TAGEDITOR info = g_strdup_printf ("%i", taglib_audioproperties_channels(properties)); #else info = g_strdup_printf ("%i", mpd_status_get_channels(gmo)); #endif gtk_label_set_text (GTK_LABEL(tag_info_channels), info); g_free (info); #ifdef HAVE_TAGEDITOR taglib_tag_free_strings (); #else free (foo); #endif return TRUE; }
EAPMethodPEAP * eap_method_peap_new (WirelessSecurity *ws_parent, NMConnection *connection, gboolean is_editor, gboolean secrets_only) { EAPMethod *parent; EAPMethodPEAP *method; GtkWidget *widget, *widget_ca_not_required_checkbox; GtkFileFilter *filter; NMSetting8021x *s_8021x = NULL; const char *filename; parent = eap_method_init (sizeof (EAPMethodPEAP), validate, add_to_size_group, fill_connection, update_secrets, destroy, "/org/gnome/control-center/network/eap-method-peap.ui", "eap_peap_notebook", "eap_peap_anon_identity_entry", FALSE); if (!parent) return NULL; parent->password_flags_name = NM_SETTING_802_1X_PASSWORD; method = (EAPMethodPEAP *) parent; method->sec_parent = ws_parent; method->is_editor = is_editor; if (connection) s_8021x = nm_connection_get_setting_802_1x (connection); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_not_required_checkbox")); g_assert (widget); g_signal_connect (G_OBJECT (widget), "toggled", (GCallback) ca_cert_not_required_toggled, parent); g_signal_connect (G_OBJECT (widget), "toggled", (GCallback) wireless_security_changed_cb, ws_parent); widget_ca_not_required_checkbox = widget; widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_button")); g_assert (widget); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE); gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget), _("Choose a Certificate Authority certificate")); g_signal_connect (G_OBJECT (widget), "selection-changed", (GCallback) wireless_security_changed_cb, ws_parent); filter = eap_method_default_file_chooser_filter_new (FALSE); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter); if (connection && s_8021x) { filename = NULL; if (nm_setting_802_1x_get_ca_cert_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH) { filename = nm_setting_802_1x_get_ca_cert_path (s_8021x); if (filename) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget_ca_not_required_checkbox), !filename && eap_method_ca_cert_ignore_get (parent, connection)); } widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only); inner_auth_combo_changed_cb (widget, (gpointer) method); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo")); g_assert (widget); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); if (s_8021x) { const char *peapver; peapver = nm_setting_802_1x_get_phase1_peapver (s_8021x); if (peapver) { /* Index 0 is "Automatic" */ if (!strcmp (peapver, "0")) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); else if (!strcmp (peapver, "1")) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2); } } g_signal_connect (G_OBJECT (widget), "changed", (GCallback) wireless_security_changed_cb, ws_parent); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry")); if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x)) gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x)); g_signal_connect (G_OBJECT (widget), "changed", (GCallback) wireless_security_changed_cb, ws_parent); if (secrets_only) { widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_label")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_label")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_button")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_not_required_checkbox")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_label")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_label")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo")); gtk_widget_hide (widget); } return method; }
void ColorICCSelector::init() { GtkWidget *t; gint row = 0; _updating = FALSE; _dragging = FALSE; t = gtk_table_new (5, 3, FALSE); gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) //guint partCount = _cmsChannelsOf( icSigRgbData ); gchar const** names = 0; gchar const** tips = 0; getThings( cmsSigRgbData, names, tips, _fooScales ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) /* Create components */ row = 0; _fixupBtn = gtk_button_new_with_label(_("Fix")); g_signal_connect( G_OBJECT(_fixupBtn), "clicked", G_CALLBACK(_fixupHit), (gpointer)this ); gtk_widget_set_sensitive( _fixupBtn, FALSE ); gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); //gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 ); gtk_widget_show( _fixupBtn ); gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); // Combobox and store with 2 columns : label (0) and full name (1) GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); _profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (_profileSel), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (_profileSel), renderer, "text", 0, NULL); GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1); gtk_widget_show( _profileSel ); gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 ); gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) _profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this ); #else gtk_widget_set_sensitive( _profileSel, false ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) row++; _fooCount = 4; _fooAdj = new GtkAdjustment*[_fooCount]; _fooSlider = new GtkWidget*[_fooCount]; _fooBtn = new GtkWidget*[_fooCount]; _fooLabel = new GtkWidget*[_fooCount]; _fooMap = new guchar*[_fooCount]; for ( guint i = 0; i < _fooCount; i++ ) { /* Label */ #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) _fooLabel[i] = gtk_label_new_with_mnemonic( names[i] ); #else _fooLabel[i] = gtk_label_new_with_mnemonic( "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_misc_set_alignment( GTK_MISC (_fooLabel[i]), 1.0, 0.5 ); gtk_widget_show( _fooLabel[i] ); gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); /* Adjustment */ gdouble step = static_cast<gdouble>(_fooScales[i]) / 100.0; gdouble page = static_cast<gdouble>(_fooScales[i]) / 10.0; gint digits = (step > 0.9) ? 0 : 2; _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, _fooScales[i], step, page, page ) ); /* Slider */ _fooSlider[i] = sp_color_slider_new( _fooAdj[i] ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); #else gtk_widget_set_tooltip_text( _fooSlider[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_show( _fooSlider[i] ); gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD ); _fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); #else gtk_widget_set_tooltip_text( _fooBtn[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) sp_dialog_defocus_on_enter( _fooBtn[i] ); gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] ); gtk_widget_show( _fooBtn[i] ); gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); _fooMap[i] = g_new( guchar, 4 * 1024 ); memset( _fooMap[i], 0x0ff, 1024 * 4 ); /* Signals */ g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); g_signal_connect( G_OBJECT( _fooSlider[i] ), "grabbed", G_CALLBACK( _sliderGrabbed ), _csel ); g_signal_connect( G_OBJECT( _fooSlider[i] ), "released", G_CALLBACK( _sliderReleased ), _csel ); g_signal_connect( G_OBJECT( _fooSlider[i] ), "changed", G_CALLBACK( _sliderChanged ), _csel ); row++; } /* Label */ _label = gtk_label_new_with_mnemonic (_("_A:")); gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); gtk_widget_show (_label); gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); /* Adjustment */ _adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 10.0, 10.0); /* Slider */ _slider = sp_color_slider_new (_adj); gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); gtk_widget_show (_slider); gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD); sp_color_slider_set_colors( SP_COLOR_SLIDER( _slider ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.5 ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 1.0 ) ); /* Spinbutton */ _sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (_adj), 1.0, 0); gtk_widget_set_tooltip_text (_sbtn, _("Alpha (opacity)")); sp_dialog_defocus_on_enter (_sbtn); gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); gtk_widget_show (_sbtn); gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); /* Signals */ g_signal_connect (G_OBJECT (_adj), "value_changed", G_CALLBACK (_adjustmentChanged), _csel); g_signal_connect (G_OBJECT (_slider), "grabbed", G_CALLBACK (_sliderGrabbed), _csel); g_signal_connect (G_OBJECT (_slider), "released", G_CALLBACK (_sliderReleased), _csel); g_signal_connect (G_OBJECT (_slider), "changed", G_CALLBACK (_sliderChanged), _csel); }
/* construct widget above */ void gui_init(struct dt_imageio_module_storage_t *self) { self->gui_data = g_malloc0(sizeof(dt_storage_facebook_gui_data_t)); dt_storage_facebook_gui_data_t *ui = self->gui_data; ui->facebook_api = fb_api_init(); self->widget = gtk_vbox_new(FALSE, 0); //create labels ui->label_album_title = GTK_LABEL( gtk_label_new( _("title") ) ); ui->label_album_summary = GTK_LABEL( gtk_label_new( _("summary") ) ); ui->label_album_privacy = GTK_LABEL(gtk_label_new(_("privacy"))); ui->label_status = GTK_LABEL(gtk_label_new(NULL)); gtk_misc_set_alignment(GTK_MISC(ui->label_album_title), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(ui->label_album_summary), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(ui->label_album_privacy), 0.0, 0.5); //create entries GtkListStore *model_username = gtk_list_store_new (COMBO_USER_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); //text, token, id ui->comboBox_username = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_username))); GtkCellRenderer *p_cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ui->comboBox_username), p_cell, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (ui->comboBox_username), p_cell, "text", 0, NULL); ui->entry_album_title = GTK_ENTRY(gtk_entry_new()); ui->entry_album_summary = GTK_ENTRY(gtk_entry_new()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->comboBox_username)); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_title)); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_summary)); //retrieve saved accounts ui_refresh_users(ui); //////// album list ///////// GtkWidget *albumlist = gtk_hbox_new(FALSE, 0); GtkListStore *model_album = gtk_list_store_new (COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING); //name, id ui->comboBox_album = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_album))); p_cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (ui->comboBox_album), p_cell, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (ui->comboBox_album), p_cell, "text", 0, NULL); gtk_widget_set_sensitive(GTK_WIDGET(ui->comboBox_album), FALSE); gtk_combo_box_set_row_separator_func(ui->comboBox_album,combobox_separator,ui->comboBox_album,NULL); gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->comboBox_album), TRUE, TRUE, 0); ui->comboBox_privacy= GTK_COMBO_BOX(gtk_combo_box_text_new()); GtkListStore *list_store = gtk_list_store_new (COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_INT); GtkTreeIter iter; gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("only me"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_SELF, -1); gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("friends"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_ALL_FRIENDS, -1); gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("public"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_EVERYONE, -1); gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("friends of friends"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_FRIENDS_OF_FRIENDS, -1); gtk_combo_box_set_model(ui->comboBox_privacy, GTK_TREE_MODEL(list_store)); gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox_privacy), 1); // Set default permission to private ui->button_login = GTK_BUTTON(gtk_button_new_with_label(_("login"))); ui->connected = FALSE; //pack the ui ////the auth box GtkWidget *hbox_auth = gtk_hbox_new(FALSE,5); GtkWidget *vbox_auth_labels=gtk_vbox_new(FALSE,0); GtkWidget *vbox_auth_fields=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_labels, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_fields, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox_auth), TRUE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->comboBox_username), TRUE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox_auth_labels), GTK_WIDGET(gtk_label_new("")), TRUE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->button_login), TRUE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(albumlist), TRUE, FALSE, 2); ////the album creation box ui->hbox_album = GTK_BOX(gtk_hbox_new(FALSE,5)); gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox_album), TRUE); //hide it by default GtkWidget *vbox_album_labels=gtk_vbox_new(FALSE,0); GtkWidget *vbox_album_fields=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(ui->hbox_album), TRUE, FALSE, 5); gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_labels, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_fields, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_title), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_title), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_summary), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_summary), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_privacy), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->comboBox_privacy), TRUE, FALSE, 0); //connect buttons to signals g_signal_connect(G_OBJECT(ui->button_login), "clicked", G_CALLBACK(ui_login_clicked), (gpointer)ui); g_signal_connect(G_OBJECT(ui->comboBox_username), "changed", G_CALLBACK(ui_combo_username_changed), (gpointer)ui); g_signal_connect(G_OBJECT(ui->comboBox_album), "changed", G_CALLBACK(ui_combo_album_changed), (gpointer)ui); g_object_unref(model_username); g_object_unref(model_album); g_object_unref(list_store); }
int main (int argc, char **argv) { int i; GtkWidget *window; GtkWidget *vbox; GtkWidget *combo_box; GtkWidget *sw; GtkWidget *tree_view; GtkWidget *button; gtk_init (&argc, &argv); /* Window and box */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_container_add (GTK_CONTAINER (window), vbox); /* Option menu contents */ combo_box = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), NO_EXPAND); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), SINGLE_EXPAND); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), MULTI_EXPAND); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), LAST_EXPAND); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), BORDER_EXPAND); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), ALL_EXPAND); gtk_box_pack_start (GTK_BOX (vbox), combo_box, FALSE, FALSE); /* Scrolled window and tree view */ sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE); tree_view = gtk_tree_view_new_with_model (create_model ()); gtk_container_add (GTK_CONTAINER (sw), tree_view); for (i = 0; i < 5; i++) { GtkTreeViewColumn *column; gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), i, "Header", gtk_cell_renderer_text_new (), "text", i, NULL); column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), i); gtk_tree_view_column_set_resizable (column, TRUE); } /* Toggle button for long content row */ button = gtk_toggle_button_new_with_label ("Toggle long content row"); g_signal_connect (button, "toggled", G_CALLBACK (toggle_long_content_row), tree_view); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE); /* Set up option menu callback and default item */ g_signal_connect (combo_box, "changed", G_CALLBACK (combo_box_changed), tree_view); gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0); /* Done */ gtk_widget_show_all (window); gtk_main (); return 0; }
static void tree_menu (void) { GtkWidget *window, *widget; GtkWidget *menubar, *vbox; GtkCellArea *area; GtkTreeModel *store; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "GtkTreeMenu"); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_widget_show (vbox); menubar = gtk_menu_bar_new (); gtk_widget_show (menubar); store = simple_tree_model (); area = create_cell_area (); #if _GTK_TREE_MENU_WAS_A_PUBLIC_CLASS_ menuitem = gtk_menu_item_new_with_label ("Grid"); menu = create_menu_grid_demo (); gtk_widget_show (menu); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); menuitem = gtk_menu_item_new_with_label ("Tree"); menu = simple_tree_menu (); gtk_widget_show (menu); gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (menubar), menuitem); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); g_signal_connect (menu, "menu-activate", G_CALLBACK (menu_activated_cb), NULL); gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); #endif /* Add a combo box with the same menu ! */ widget = gtk_combo_box_new_with_area (area); gtk_combo_box_set_model (GTK_COMBO_BOX (widget), store); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_widget_show (widget); gtk_box_pack_end (GTK_BOX (vbox), widget, FALSE, FALSE, 0); /* Now add some controls */ widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (orientation_changed), area); widget = gtk_check_button_new_with_label ("Align 2nd Cell"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (align_cell_2_toggled), area); widget = gtk_check_button_new_with_label ("Align 3rd Cell"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (align_cell_3_toggled), area); widget = gtk_check_button_new_with_label ("Expand 1st Cell"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (expand_cell_1_toggled), area); widget = gtk_check_button_new_with_label ("Expand 2nd Cell"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (expand_cell_2_toggled), area); widget = gtk_check_button_new_with_label ("Expand 3rd Cell"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (expand_cell_3_toggled), area); #if _GTK_TREE_MENU_WAS_A_PUBLIC_CLASS_ widget = gtk_check_button_new_with_label ("Submenu Headers"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (submenu_headers_toggled), menu); widget = gtk_check_button_new_with_label ("Tearoff menu"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (tearoff_toggled), menu); #endif gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (window); }
// Procedura ładowania języka static void ChooseLang (GtkMenuItem *item, gpointer data) { GtkWidget *dialog, *vbox, *label, *combo; dialog = gtk_dialog_new_with_buttons("Wybierz...", NULL, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); // W treści dialogu dwa elementy vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); // Tekst label = gtk_label_new("Oto lista języków,\ndla których są dostępne słowniki"); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 1); char *list = NULL; size_t len = 0; if(dictionary_lang_list(&list, &len) < 0) { GtkWidget* err_dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Błąd pobierania listy języków!"); gtk_dialog_run(GTK_DIALOG(err_dialog)); gtk_widget_destroy(err_dialog); return; } // Spuszczane menu combo = gtk_combo_box_text_new(); char* lastFirst = list; for (size_t i = 0; i < len; i++) { if ((list + i)[0] == '\0') { // Dodajemy kolejny element gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), lastFirst); lastFirst = list + i + 1; } } gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 1); gtk_widget_show(combo); if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { const char* wybranyJezyk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo)); //zapisujemy stary słownik - ktoś mógł coś tam dodać i mógł się zmienić if(strcmp(dict_location, DEFAULT_LOC) != 0) dictionary_save_lang(dict, dict_location); // i ładujemy wybrany struct dictionary* tempDict = dictionary_load_lang(wybranyJezyk); // Jeśli wybrany jest ok, to podmienimy go if(tempDict == NULL) { GtkWidget* err_dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Nie udało się wczytać słownika!"); gtk_dialog_run(GTK_DIALOG(err_dialog)); gtk_widget_destroy(err_dialog); } if(dict != NULL) dictionary_done(dict); dict = tempDict; strcpy(dict_location, wybranyJezyk); //free(wybranyJezyk); } gtk_widget_destroy(dialog); free(list); }
static void construct_widgets (GpaCardManager *cardman) { GtkWidget *vbox; GtkWidget *hbox, *hbox1, *hbox2; GtkWidget *label; GtkWidget *icon; gchar *markup; GtkWidget *menubar; GtkWidget *toolbar; GtkWidget *statusbar; /* Set a default size for the main window. */ gtk_window_set_default_size (GTK_WINDOW (cardman), 680, 480); /* Realize the window so that we can create pixmaps without warnings. */ gtk_widget_realize (GTK_WIDGET (cardman)); /* Use a vbox to show the menu, toolbar and the file container. */ vbox = gtk_vbox_new (FALSE, 0); /* Get the menu and the toolbar. */ cardman_action_new (cardman, &menubar, &toolbar); gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0); /* Add a fancy label that tells us: This is the card manager. */ hbox1 = gtk_hbox_new (FALSE, 0); icon = gtk_image_new_from_stock (GPA_STOCK_CARDMAN, GTK_ICON_SIZE_DND); gtk_box_pack_start (GTK_BOX (hbox1), icon, FALSE, TRUE, 0); label = gtk_label_new (NULL); markup = g_strdup_printf ("<span font_desc=\"16\">%s</span>", _("Card Manager")); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_box_pack_start (GTK_BOX (hbox1), label, TRUE, TRUE, 10); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); /* Add a application selection box. */ hbox2 = gtk_hbox_new (FALSE, 0); label = gtk_label_new (_("Application selection:")); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 5); cardman->app_selector = gtk_combo_box_new_text (); gtk_combo_box_append_text (GTK_COMBO_BOX (cardman->app_selector), _("Auto")); gtk_combo_box_set_active (GTK_COMBO_BOX (cardman->app_selector), 0); gtk_box_pack_start (GTK_BOX (hbox2), cardman->app_selector, FALSE, TRUE, 0); /* Put Card Manager label and application selector into the same line. */ hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), hbox1, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); /* Create a container (a scolled window) which will take the actual card widget. This container is required so that we can easily change to a differet card widget. */ cardman->card_container = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (cardman->card_container), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), cardman->card_container, TRUE, TRUE, 0); /* Update the container using the current card application. */ update_card_widget (cardman, NULL); statusbar = statusbar_new (cardman); gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (cardman), vbox); }
static void WhatCheck (GtkMenuItem *item, gpointer data) { GtkWidget *dialog; GtkTextIter start, end; char *word; gunichar *wword; // Znajdujemy pozycję kursora gtk_text_buffer_get_iter_at_mark(editor_buf, &start, gtk_text_buffer_get_insert(editor_buf)); // Jeśli nie wewnątrz słowa, kończymy if (!gtk_text_iter_inside_word(&start)) { dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Kursor musi być w środku słowa"); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return; } // Znajdujemy początek i koniec słowa, a potem samo słowo end = start; gtk_text_iter_backward_word_start(&start); gtk_text_iter_forward_word_end(&end); word = gtk_text_iter_get_text(&start, &end); // Zamieniamy na wide char (no prawie) wword = g_utf8_to_ucs4_fast(word, -1, NULL); if(update_actual_dict() < 0) return; // Sprawdzamy if (dictionary_find(dict, (wchar_t *)wword)) { dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Wszystko w porządku,\nśpij spokojnie"); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } else { // Czas korekty GtkWidget *vbox, *label, *combo; struct word_list hints; int i; wchar_t **words; dictionary_hints(dict, (wchar_t *)wword, &hints); words = word_list_get(&hints); dialog = gtk_dialog_new_with_buttons("Korekta", NULL, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); // W treści dialogu dwa elementy vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); // Tekst label = gtk_label_new("Coś nie tak, mam kilka propozycji"); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 1); // Spuszczane menu combo = gtk_combo_box_text_new(); for (i = 0; i < word_list_size(&hints); i++) { // Combo box lubi mieć Gtk char *uword = g_ucs4_to_utf8((gunichar *)words[i], -1, NULL, NULL, NULL); // Dodajemy kolejny element gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), uword); g_free(uword); } //gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),"<inne...>"); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 1); gtk_widget_show(combo); char *korekta, *question; GtkWidget *ask_dialog, *ask_vbox, *ask_label; switch (gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_ACCEPT: korekta = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo)); // Usuwamy stare gtk_text_buffer_delete(editor_buf, &start, &end); // Wstawiamy nowe gtk_text_buffer_insert(editor_buf, &start, korekta, -1); g_free(korekta); break; case GTK_RESPONSE_REJECT: question = "Czy chcesz dodać to słowo do słownika?"; ask_dialog = gtk_dialog_new_with_buttons(question, NULL, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); ask_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); // Tekst ask_label = gtk_label_new("Coś nie tak, mam kilka propozycji"); gtk_widget_show(ask_label); gtk_box_pack_start(GTK_BOX(ask_vbox), ask_label, FALSE, FALSE, 1); // Jeśli chiciał dodać nowe słowo do słownika to dodamy i zapiszemy if (gtk_dialog_run(GTK_DIALOG(ask_dialog)) == GTK_RESPONSE_ACCEPT) { dictionary_insert(dict, (wchar_t *)wword); dictionary_save_lang(dict, dict_location); } gtk_widget_destroy(ask_dialog); break; } gtk_widget_destroy(dialog); } }
static void questions_tree_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { GPInstructLessonTestMultiChoiceEditor *editor = GPINSTRUCT_LESSON_TEST_MULTI_CHOICE_EDITOR (user_data); GPInstructLessonTestMultiChoiceEditorPrivate *priv = editor->priv; GPInstructObject *object; GtkTreeIter iter; GtkWidget *scrolled_window, *text_view, *explanation_view, *answer_combobox; if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->questions_store), &iter, path)) { gtk_tree_model_get (GTK_TREE_MODEL (priv->questions_store), &iter, DATA_COLUMN, &object, -1); if (GPINSTRUCT_IS_LESSON_TEST_MULTI_CHOICE_QUESTION (object)) { GPInstructLessonTestMultiChoiceQuestion *question = GPINSTRUCT_LESSON_TEST_MULTI_CHOICE_QUESTION (object); guint choices_num = gpinstruct_lesson_test_multi_choice_question_get_choices_length (question); GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Question Properties"), GTK_WINDOW (priv->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); GtkWidget *content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); text_view = gtk_text_view_new (); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD_CHAR); gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)), gpinstruct_lesson_test_multi_choice_question_get_text (question), -1); gtk_container_add (GTK_CONTAINER (scrolled_window), text_view); gtk_box_pack_start (GTK_BOX (content_area), gtk_label_new (_("Text:")), FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (content_area), scrolled_window, TRUE, TRUE, 0); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); explanation_view = gtk_text_view_new (); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (explanation_view), GTK_WRAP_WORD_CHAR); gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (explanation_view)), gpinstruct_lesson_test_multi_choice_question_get_explanation (question), -1); gtk_container_add (GTK_CONTAINER (scrolled_window), explanation_view); gtk_box_pack_start (GTK_BOX (content_area), gtk_label_new (_("Explanation:")), FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (content_area), scrolled_window, TRUE, TRUE, 0); if (choices_num) { answer_combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->choices_store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (answer_combobox), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (answer_combobox), renderer, "text", TITLE_COLUMN, NULL); gtk_combo_box_set_active (GTK_COMBO_BOX (answer_combobox), gpinstruct_lesson_test_multi_choice_question_get_answer (question)); gtk_box_pack_start (GTK_BOX (content_area), gtk_label_new (_("Answer:")), FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (content_area), answer_combobox, FALSE, TRUE, 0); } gtk_widget_show_all (content_area); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { GtkTextIter start, end; gchar *text; gtk_text_buffer_get_bounds (gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)), &start, &end); text = gtk_text_iter_get_text (&start, &end); gpinstruct_lesson_test_multi_choice_question_set_text (question, text); g_free (text); gtk_text_buffer_get_bounds (gtk_text_view_get_buffer (GTK_TEXT_VIEW (explanation_view)), &start, &end); text = gtk_text_iter_get_text (&start, &end); gpinstruct_lesson_test_multi_choice_question_set_explanation (question, text); g_free (text); if (choices_num) gpinstruct_lesson_test_multi_choice_question_set_answer (question, gtk_combo_box_get_active (GTK_COMBO_BOX (answer_combobox))); update_questions_tree_view (GPINSTRUCT_LESSON_TEST_MULTI_CHOICE_EDITOR (user_data)); gpinstruct_editor_window_set_modified (priv->window, TRUE); gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->questions_store), &iter, NULL, gtk_tree_path_get_indices (path)[0]); gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), &iter); } gtk_widget_destroy (dialog); } } }
void gui_init (dt_imageio_module_storage_t *self) { self->gui_data = (dt_storage_flickr_gui_data_t *)g_malloc0(sizeof(dt_storage_flickr_gui_data_t)); dt_storage_flickr_gui_data_t *ui= self->gui_data; self->widget = gtk_vbox_new(FALSE, 0); GtkWidget *hbox1=gtk_hbox_new(FALSE,5); GtkWidget *hbox0=gtk_hbox_new(FALSE,5); GtkWidget *vbox1=gtk_vbox_new(FALSE,0); GtkWidget *vbox2=gtk_vbox_new(FALSE,5); ui->label1 = GTK_LABEL( gtk_label_new( _("flickr user") ) ); ui->label3 = GTK_LABEL( gtk_label_new( _("photosets") ) ); ui->labelPerms = GTK_LABEL( gtk_label_new( _("visible to") ) ); ui->label4 = GTK_LABEL( gtk_label_new( NULL ) ); set_status(ui,_("click login button to start"), "#ffffff"); ui->label5 = GTK_LABEL( gtk_label_new( _("title") ) ); ui->label6 = GTK_LABEL( gtk_label_new( _("summary") ) ); gtk_misc_set_alignment(GTK_MISC(ui->label1), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(ui->labelPerms), 0.0, 0.9); gtk_misc_set_alignment(GTK_MISC(ui->label3), 0.0, 0.7); gtk_misc_set_alignment(GTK_MISC(ui->label5), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(ui->label6), 0.0, 0.5); ui->entry1 = GTK_ENTRY( gtk_entry_new() ); ui->entry3 = GTK_ENTRY( gtk_entry_new() ); // Album title ui->entry4 = GTK_ENTRY( gtk_entry_new() ); // Album summary dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (ui->entry1)); dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (ui->entry3)); dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (ui->entry4)); /* gtk_widget_add_events(GTK_WIDGET(ui->entry1), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (ui->entry1), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (ui->entry1), "focus-out-event", G_CALLBACK(focus_out), NULL); gtk_widget_add_events(GTK_WIDGET(ui->entry2), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (ui->entry2), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (ui->entry2), "focus-out-event", G_CALLBACK(focus_out), NULL); gtk_widget_add_events(GTK_WIDGET(ui->entry3), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (ui->entry3), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (ui->entry3), "focus-out-event", G_CALLBACK(focus_out), NULL); gtk_widget_add_events(GTK_WIDGET(ui->entry4), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (ui->entry4), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (ui->entry4), "focus-out-event", G_CALLBACK(focus_out), NULL); */ GHashTable* table = dt_pwstorage_get("flickr"); gchar* _username = g_strdup( g_hash_table_lookup(table, "username")); g_hash_table_destroy(table); gtk_entry_set_text( ui->entry1, _username == NULL?"":_username ); gtk_entry_set_text( ui->entry3, _("my new photoset") ); gtk_entry_set_text( ui->entry4, _("exported from darktable") ); GtkWidget *albumlist=gtk_hbox_new(FALSE,0); ui->comboBox1 = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new()); // Available albums dt_ellipsize_combo(GTK_COMBO_BOX(ui->comboBox1)); ui->dtbutton1 = DTGTK_BUTTON( dtgtk_button_new(dtgtk_cairo_paint_refresh,0) ); g_object_set(G_OBJECT(ui->dtbutton1), "tooltip-text", _("refresh album list"), (char *)NULL); ui->button = GTK_BUTTON(gtk_button_new_with_label(_("login"))); g_object_set(G_OBJECT(ui->button), "tooltip-text", _("flickr login"), (char *)NULL); gtk_widget_set_sensitive( GTK_WIDGET(ui->comboBox1), FALSE); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(ui->comboBox1), combobox_separator,ui->comboBox1,NULL); gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->comboBox1), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->dtbutton1), FALSE, FALSE, 0); ui->checkButton2 = GTK_CHECK_BUTTON( gtk_check_button_new_with_label(_("export tags")) ); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON( ui->checkButton2 ),TRUE); ui->permsComboBox = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new()); gtk_combo_box_text_append_text(ui->permsComboBox, _("you")); gtk_combo_box_text_append_text(ui->permsComboBox, _("friends")); gtk_combo_box_text_append_text(ui->permsComboBox, _("family")); gtk_combo_box_text_append_text(ui->permsComboBox, _("friends + family")); gtk_combo_box_text_append_text(ui->permsComboBox, _("everyone")); gtk_combo_box_set_active(GTK_COMBO_BOX(ui->permsComboBox), 0); // Set default permission to private gtk_box_pack_start(GTK_BOX(self->widget), hbox0, TRUE, FALSE, 5); gtk_box_pack_start(GTK_BOX(self->widget), hbox1, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX( hbox0 ), GTK_WIDGET( ui->label1 ), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( hbox0 ), GTK_WIDGET( ui->entry1 ), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX( hbox0 ), GTK_WIDGET( ui->button ), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX( hbox1 ), vbox1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX( hbox1 ), vbox2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( gtk_label_new("")), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->labelPerms ), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->label3 ), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->label4 ), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->checkButton2 ), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->permsComboBox ), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( albumlist ), TRUE, FALSE, 0); // Create Album ui->hbox1=GTK_BOX(gtk_hbox_new(FALSE,5)); gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox1), TRUE); vbox1=gtk_vbox_new(FALSE,0); vbox2=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(ui->hbox1), vbox1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ui->hbox1), vbox2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(ui->hbox1), TRUE, FALSE, 5); gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->label5 ), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->label6 ), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->entry3 ), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->entry4 ), TRUE, FALSE, 0); // Setup signals // add signal on realize and hide gtk_widget_hide(GTK_WIDGET(ui->hbox1)); g_signal_connect(G_OBJECT(ui->dtbutton1), "clicked", G_CALLBACK(flickr_button1_clicked), (gpointer)ui); g_signal_connect(G_OBJECT(ui->button), "clicked", G_CALLBACK(flickr_button1_clicked), (gpointer)ui); g_signal_connect(G_OBJECT(ui->entry1), "changed", G_CALLBACK(flickr_entry_changed), (gpointer)ui); g_signal_connect(G_OBJECT(ui->comboBox1), "changed", G_CALLBACK(flickr_album_changed), (gpointer)ui); /** dont' populate the combo on startup, save 3 second // If username and password is stored, let's populate the combo if( _username && _password ) { ui->user_token = _password; refresh_albums(ui); } */ if( _username ) g_free (_username); gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox1), 0); }