static void _set_playPauseImage (CustomData *data, const gchar *stockid) { gtk_image_set_from_stock( GTK_IMAGE (gtk_button_get_image (GTK_BUTTON (data->playPauseButton))), stockid, GTK_ICON_SIZE_BUTTON); }
/**************************************************************** Worklist editor shell. *****************************************************************/ GtkWidget *create_worklist(void) { GtkWidget *editor, *table, *sw, *bbox; GtkWidget *src_view, *dst_view, *label, *button; GtkWidget *menubar, *item, *menu, *image; GtkWidget *table2, *arrow, *check; GtkSizeGroup *group; GtkListStore *src_store, *dst_store; struct worklist_data *ptr; ptr = fc_malloc(sizeof(*ptr)); src_store = gtk_list_store_new(1, G_TYPE_INT); dst_store = gtk_list_store_new(1, G_TYPE_INT); ptr->global_worklist_id = -1; ptr->pcity = NULL; ptr->src = src_store; ptr->dst = dst_store; ptr->future = FALSE; /* create shell. */ editor = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(editor), 6); gtk_orientable_set_orientation(GTK_ORIENTABLE(editor), GTK_ORIENTATION_VERTICAL); g_signal_connect(editor, "destroy", G_CALLBACK(worklist_destroy), ptr); g_object_set_data(G_OBJECT(editor), "data", ptr); ptr->editor = editor; /* add source and target lists. */ table = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(editor), table); group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_grid_attach(GTK_GRID(table), sw, 3, 1, 2, 1); src_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(src_store)); gtk_widget_set_hexpand(src_view, TRUE); gtk_widget_set_vexpand(src_view, TRUE); g_object_unref(src_store); gtk_size_group_add_widget(group, src_view); gtk_widget_set_name(src_view, "small_font"); populate_view(GTK_TREE_VIEW(src_view), &ptr->pcity, &ptr->src_col); gtk_container_add(GTK_CONTAINER(sw), src_view); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, "mnemonic-widget", src_view, "label", _("Source _Tasks:"), "xalign", 0.0, "yalign", 0.5, NULL); gtk_grid_attach(GTK_GRID(table), label, 3, 0, 1, 1); check = gtk_check_button_new_with_mnemonic(_("Show _Future Targets")); gtk_grid_attach(GTK_GRID(table), check, 4, 0, 1, 1); g_signal_connect(check, "toggled", G_CALLBACK(future_callback), ptr); table2 = gtk_grid_new(); gtk_grid_attach(GTK_GRID(table), table2, 2, 1, 1, 1); button = gtk_button_new(); gtk_widget_set_margin_top(button, 24); gtk_widget_set_margin_bottom(button, 24); ptr->prepend_cmd = button; gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_grid_attach(GTK_GRID(table2), button, 0, 0, 1, 1); arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_prepend), ptr); gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE); button = gtk_button_new(); ptr->up_cmd = button; gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_grid_attach(GTK_GRID(table2), button, 0, 1, 1, 1); arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_bubble_up), ptr); gtk_widget_set_sensitive(ptr->up_cmd, FALSE); button = gtk_button_new(); ptr->down_cmd = button; gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_grid_attach(GTK_GRID(table2), button, 0, 2, 1, 1); arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_bubble_down), ptr); gtk_widget_set_sensitive(ptr->down_cmd, FALSE); button = gtk_button_new(); gtk_widget_set_margin_top(button, 24); gtk_widget_set_margin_bottom(button, 24); ptr->append_cmd = button; gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_grid_attach(GTK_GRID(table2), button, 0, 3, 1, 1); arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_append), ptr); gtk_widget_set_sensitive(ptr->append_cmd, FALSE); button = gtk_button_new(); gtk_widget_set_margin_top(button, 24); gtk_widget_set_margin_bottom(button, 24); ptr->remove_cmd = button; gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_grid_attach(GTK_GRID(table2), button, 0, 4, 1, 1); arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_remove), ptr); gtk_widget_set_sensitive(ptr->remove_cmd, FALSE); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_grid_attach(GTK_GRID(table), sw, 0, 1, 2, 1); dst_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dst_store)); gtk_widget_set_hexpand(dst_view, TRUE); gtk_widget_set_vexpand(dst_view, TRUE); g_object_unref(dst_store); gtk_size_group_add_widget(group, dst_view); gtk_widget_set_name(dst_view, "small_font"); populate_view(GTK_TREE_VIEW(dst_view), &ptr->pcity, &ptr->dst_col); gtk_container_add(GTK_CONTAINER(sw), dst_view); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, "mnemonic-widget", dst_view, "label", _("Target _Worklist:"), "xalign", 0.0, "yalign", 0.5, NULL); gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1); /* add bottom menu and buttons. */ bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(bbox), 10); gtk_container_add(GTK_CONTAINER(editor), bbox); menubar = gtk_aux_menu_bar_new(); gtk_container_add(GTK_CONTAINER(bbox), menubar); gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), menubar, TRUE); menu = gtk_menu_new(); image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); item = gtk_image_menu_item_new_with_mnemonic(_("_Add Global Worklist")); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item); g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), ptr); ptr->add_cmd = item; gtk_widget_set_sensitive(ptr->add_cmd, FALSE); button = gtk_button_new_from_stock(GTK_STOCK_HELP); gtk_container_add(GTK_CONTAINER(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(help_callback), ptr); ptr->help_cmd = button; gtk_widget_set_sensitive(ptr->help_cmd, FALSE); button = gtk_button_new_with_mnemonic(_("Change Prod_uction")); gtk_container_add(GTK_CONTAINER(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(change_callback), ptr); ptr->change_cmd = button; gtk_widget_set_sensitive(ptr->change_cmd, FALSE); ptr->src_view = src_view; ptr->dst_view = dst_view; ptr->src_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(src_view)); ptr->dst_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dst_view)); gtk_tree_selection_set_mode(ptr->dst_selection, GTK_SELECTION_MULTIPLE); /* DND and other state changing callbacks. */ gtk_tree_view_set_reorderable(GTK_TREE_VIEW(dst_view), TRUE); g_signal_connect(dst_view, "drag_end", G_CALLBACK(dst_dnd_callback), ptr); g_signal_connect(src_view, "row_activated", G_CALLBACK(src_row_callback), ptr); g_signal_connect(src_view, "key_press_event", G_CALLBACK(src_key_press_callback), ptr); g_signal_connect(dst_view, "row_activated", G_CALLBACK(dst_row_callback), ptr); g_signal_connect(dst_view, "key_press_event", G_CALLBACK(dst_key_press_callback), ptr); g_signal_connect(ptr->src_selection, "changed", G_CALLBACK(src_selection_callback), ptr); g_signal_connect(ptr->dst_selection, "changed", G_CALLBACK(dst_selection_callback), ptr); gtk_widget_show_all(table); gtk_widget_show_all(bbox); return editor; }
void caja_x_content_bar_set_x_content_type (CajaXContentBar *bar, const char *x_content_type) { char *message; char *description; GAppInfo *default_app; g_free (bar->priv->x_content_type); bar->priv->x_content_type = g_strdup (x_content_type); description = g_content_type_get_description (x_content_type); /* Customize greeting for well-known x-content types */ if (strcmp (x_content_type, "x-content/audio-cdda") == 0) { message = g_strdup (_("These files are on an Audio CD.")); } else if (strcmp (x_content_type, "x-content/audio-dvd") == 0) { message = g_strdup (_("These files are on an Audio DVD.")); } else if (strcmp (x_content_type, "x-content/video-dvd") == 0) { message = g_strdup (_("These files are on a Video DVD.")); } else if (strcmp (x_content_type, "x-content/video-vcd") == 0) { message = g_strdup (_("These files are on a Video CD.")); } else if (strcmp (x_content_type, "x-content/video-svcd") == 0) { message = g_strdup (_("These files are on a Super Video CD.")); } else if (strcmp (x_content_type, "x-content/image-photocd") == 0) { message = g_strdup (_("These files are on a Photo CD.")); } else if (strcmp (x_content_type, "x-content/image-picturecd") == 0) { message = g_strdup (_("These files are on a Picture CD.")); } else if (strcmp (x_content_type, "x-content/image-dcf") == 0) { message = g_strdup (_("The media contains digital photos.")); } else if (strcmp (x_content_type, "x-content/audio-player") == 0) { message = g_strdup (_("These files are on a digital audio player.")); } else if (strcmp (x_content_type, "x-content/software") == 0) { message = g_strdup (_("The media contains software.")); } else { /* fallback to generic greeting */ message = g_strdup_printf (_("The media has been detected as \"%s\"."), description); } gtk_label_set_text (GTK_LABEL (bar->priv->label), message); gtk_widget_show (bar->priv->label); /* TODO: We really need a GtkBrowserBackButton-ish widget here.. until then, we only * show the default application. */ default_app = g_app_info_get_default_for_type (x_content_type, FALSE); if (default_app != NULL) { char *button_text; const char *name; GIcon *icon; GtkWidget *image; icon = g_app_info_get_icon (default_app); if (icon != NULL) { GdkPixbuf *pixbuf; int icon_size; CajaIconInfo *icon_info; icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON); icon_info = caja_icon_info_lookup (icon, icon_size); pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size); image = gtk_image_new_from_pixbuf (pixbuf); g_object_unref (pixbuf); g_object_unref (icon_info); } else { image = NULL; } name = g_app_info_get_display_name (default_app); button_text = g_strdup_printf (_("Open %s"), name); gtk_button_set_image (GTK_BUTTON (bar->priv->button), image); gtk_button_set_label (GTK_BUTTON (bar->priv->button), button_text); gtk_widget_show (bar->priv->button); g_free (button_text); g_object_unref (default_app); } else { gtk_widget_hide (bar->priv->button); } g_free (message); g_free (description); }
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_new_text()); GList *it = darktable.imageio->plugins_storage; while(it) { dt_imageio_module_storage_t *module = (dt_imageio_module_storage_t *)it->data; gtk_combo_box_append_text(d->storage, module->name()); it = g_list_next(it); } 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_new_text()); 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 (GTK_WIDGET (d->width)); dt_gui_key_accel_block_on_focus (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_new_text()); gtk_combo_box_append_text(d->intent, _("image settings")); gtk_combo_box_append_text(d->intent, _("perceptual")); gtk_combo_box_append_text(d->intent, _("relative colorimetric")); gtk_combo_box_append_text(d->intent, C_("rendering intent", "saturation")); gtk_combo_box_append_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)); g_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)); g_strlcpy(prof->name, _("Adobe RGB"), 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)); g_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)); g_strlcpy(prof->name, _("linear 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)); char name[1024]; cmsGetProfileInfoASCII(tmpprof, cmsInfoDescription, lang, lang+3, name, 1024); g_strlcpy(prof->name, 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_new_text()); 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_append_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_append_text(d->profile, _("system display profile")); else gtk_combo_box_append_text(d->profile, prof->name); l = g_list_next(l); } gtk_combo_box_set_active(d->profile, 0); char tooltip[1024]; snprintf(tooltip, 1024, _("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_new_text()); dt_ellipsize_combo(d->style); gtk_combo_box_append_text(d->style, _("none")); GList *styles = dt_styles_get_list(""); while (styles) { dt_style_t *style=(dt_style_t *)styles->data; gtk_combo_box_append_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), (gpointer)0); g_signal_connect (G_OBJECT (d->height), "value-changed", G_CALLBACK (height_changed), (gpointer)0); self->gui_reset(self); }
static void s_typeslist_changed (GtkWidget *w, gpointer d) { AP_UnixDialog_Styles * dlg = static_cast <AP_UnixDialog_Styles *>(d); dlg->event_ListClicked (gtk_button_get_label (GTK_BUTTON(w))); }
static void wibuti_prefs_init(WibutiPrefs *self) { GError *err = NULL; char *markup = ""; GtkBox *main_box = GTK_BOX(gtk_vbox_new(FALSE, 5)); GtkNotebook *notebook = GTK_NOTEBOOK(gtk_notebook_new()); GtkButton *btn_close = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_CLOSE)); GtkButtonBox *btnbox = GTK_BUTTON_BOX(gtk_hbutton_box_new()); GtkLabel *label_layout_tip = GTK_LABEL(gtk_label_new("")); self->builder = gtk_builder_new(); #ifdef WIBUTI_WITH_BUTTONS GtkAlignment *alignment_theme, *alignment_buttons; GtkLabel *label_theme, *label_buttons; gtk_builder_add_from_file(self->builder, WIBUTI_PATH_BUTTONS_UI, &err); if (err != NULL) { g_fprintf(stderr, "%s\n", err->message); g_error_free(err); } else { alignment_theme = GTK_ALIGNMENT(gtk_builder_get_object(self->builder, "alignment_theme")); alignment_buttons = GTK_ALIGNMENT(gtk_builder_get_object(self->builder, "alignment_buttons")); self->combo_theme = GTK_COMBO_BOX(gtk_builder_get_object(self->builder, CFG_THEME)); self->chkb_hover_effect = GTK_TOGGLE_BUTTON(gtk_builder_get_object(self->builder, CFG_HOVER_EFFECT)); self->chkb_click_effect = GTK_TOGGLE_BUTTON(gtk_builder_get_object(self->builder, CFG_CLICK_EFFECT)); // fill themes combo GtkListStore *list_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(self->combo_theme), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(self->combo_theme), renderer, "text", 0, NULL); gtk_combo_box_set_model(self->combo_theme, GTK_TREE_MODEL(list_store)); const gchar *subdir; GDir *dir = g_dir_open(WIBUTI_PATH_THEMES, 0, NULL); while ((subdir = g_dir_read_name(dir)) != NULL) { GtkTreeIter iter; gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, 0, subdir, 1, 0, -1); } g_dir_close(dir); // pack to notebook label_theme = GTK_LABEL(gtk_label_new("Themes")); gtk_notebook_append_page(notebook, GTK_WIDGET(alignment_theme), GTK_WIDGET(label_theme)); label_buttons = GTK_LABEL(gtk_label_new("Buttons")); gtk_notebook_append_page(notebook, GTK_WIDGET(alignment_buttons), GTK_WIDGET(label_buttons)); markup = g_strconcat(markup, "<b>M</b> - ", "minimize", "\n<b>R</b> - ", "maximize/restore", "\n<b>X</b> - ", "close", "\n", NULL); } #endif // WIBUTI_WITH_BUTTONS #ifdef WIBUTI_WITH_TITLE GtkAlignment *alignment_title; GtkLabel *label_title; gtk_builder_add_from_file(self->builder, WIBUTI_PATH_TITLE_UI, &err); if (err != NULL) { g_fprintf(stderr, "%s\n", err->message); g_error_free(err); } else { alignment_title = GTK_ALIGNMENT(gtk_builder_get_object(self->builder, "alignment_title")); self->chkb_expand_title = GTK_TOGGLE_BUTTON(gtk_builder_get_object(self->builder, CFG_EXPAND_TITLE)); self->chkb_custom_style = GTK_TOGGLE_BUTTON(gtk_builder_get_object(self->builder, CFG_CUSTOM_STYLE)); self->btn_font_active = GTK_FONT_BUTTON(gtk_builder_get_object(self->builder, "btn_font_active")); self->btn_font_inactive = GTK_FONT_BUTTON(gtk_builder_get_object(self->builder, "btn_font_inactive")); self->btn_color_active = GTK_COLOR_BUTTON(gtk_builder_get_object(self->builder, "btn_color_active")); self->btn_color_inactive = GTK_COLOR_BUTTON(gtk_builder_get_object(self->builder, "btn_color_inactive")); self->scale_alignment = GTK_SCALE(gtk_builder_get_object(self->builder, "scale_alignment")); // pack to notebook label_title = GTK_LABEL(gtk_label_new("Title")); gtk_notebook_append_page(notebook, GTK_WIDGET(alignment_title), GTK_WIDGET(label_title)); markup = g_strconcat(markup, "<b>I</b> - ", "icon", "\n<b>T</b> - ", "title", "\n", NULL); } #endif // WIBUTI_WITH_TITLE GtkAlignment *alignment_general; GtkLabel *label_general; gtk_builder_add_from_file(self->builder, WIBUTI_PATH_GENERAL_UI, &err); if (err != NULL) { g_fprintf(stderr, "%s\n", err->message); g_error_free(err); } else { alignment_general = GTK_ALIGNMENT(gtk_builder_get_object(self->builder, "alignment_general")); label_layout_tip = GTK_LABEL(gtk_builder_get_object(self->builder, "label_layout_tip")); self->chkb_only_maximized = GTK_TOGGLE_BUTTON(gtk_builder_get_object(self->builder, CFG_ONLY_MAXIMIZED)); self->chkb_hide_unmaximized = GTK_TOGGLE_BUTTON(gtk_builder_get_object(self->builder, CFG_HIDE_ON_UNMAXIMIZED)); self->btn_reload_layout = GTK_BUTTON(gtk_builder_get_object(self->builder, "btn_reload_layout")); self->entry_layout = GTK_ENTRY(gtk_builder_get_object(self->builder, "entry_layout")); // pack to notebook label_general = GTK_LABEL(gtk_label_new("General")); gtk_notebook_append_page(notebook, GTK_WIDGET(alignment_general), GTK_WIDGET(label_general)); } // gui appearance gtk_notebook_set_current_page(notebook, 0); gtk_button_box_set_layout(btnbox, GTK_BUTTONBOX_END); gtk_label_set_markup(label_layout_tip, markup); g_free(markup); g_object_set(GTK_WINDOW(self), "window-position", GTK_WIN_POS_CENTER_ALWAYS, NULL); g_object_set(GTK_WINDOW(self), "border-width", 3, NULL); // pack gui gtk_box_pack_start(GTK_BOX(btnbox), GTK_WIDGET(btn_close), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(main_box), GTK_WIDGET(notebook), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(main_box), GTK_WIDGET(btnbox), FALSE, TRUE, 0); gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(main_box)); // connect signals g_signal_connect(btn_close, "clicked", G_CALLBACK(wibuti_prefs_close_cb), self); g_signal_connect(self, "delete-event", G_CALLBACK(wibuti_prefs_delete_cb), self); }
static void append_widget(GtkTreeStore *model, GtkWidget *widget, GtkTreeIter *parent_iter) { GtkTreeIter iter; const char *class_name = G_OBJECT_CLASS_NAME(GTK_WIDGET_GET_CLASS(widget)); const char *name; char *row_color = NULL; char *window_info; char *address; gboolean realized; gboolean mapped; gboolean visible; GList *l; name = gtk_widget_get_name(widget); if (name == NULL || strcmp(name, class_name) == 0) { if (GTK_IS_LABEL(widget)) { name = gtk_label_get_text(GTK_LABEL(widget)); } else if (GTK_IS_BUTTON(widget)) { name = gtk_button_get_label(GTK_BUTTON(widget)); } else if (GTK_IS_WINDOW(widget)) { name = gtk_window_get_title(GTK_WINDOW(widget)); } else { name = ""; } } if (gtk_widget_get_window(widget)) { #if HAVE_X11 window_info = g_strdup_printf("%p (XID 0x%x)", widget->window, (int)GDK_WINDOW_XID(widget->window)); #else window_info = g_strdup(""); #endif } else { window_info = g_strdup(""); } address = g_strdup_printf("%p", widget); realized = gtk_widget_get_realized(widget); mapped = gtk_widget_get_mapped(widget); visible = gtk_widget_get_visible(widget); if (!realized || !mapped || !visible) { GtkStyle* style = gtk_widget_get_style(GTK_WIDGET(widget)); GdkColor color = style->fg[GTK_STATE_INSENSITIVE]; row_color = gdk_color_to_string(&color); } gtk_tree_store_append(model, &iter, parent_iter); gtk_tree_store_set(model, &iter, WIDGET, widget, WIDGET_TYPE, class_name, WIDGET_NAME, name, WIDGET_REALIZED, realized, WIDGET_MAPPED, mapped, WIDGET_VISIBLE, visible, WIDGET_WINDOW, window_info, WIDGET_ADDRESS, address, ROW_COLOR, row_color, -1); g_free(window_info); g_free(address); g_free(row_color); if (GTK_IS_CONTAINER(widget)) { GList* children = NULL; /* Pick up all children, including those that are internal. */ gtk_container_forall(GTK_CONTAINER(widget), on_container_forall, &children); for (l = children; l != NULL; l = l->next) { append_widget(model, GTK_WIDGET(l->data), &iter); } g_list_free(children); } }
/* 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_box_new(GTK_ORIENTATION_VERTICAL, 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_widget_set_halign(GTK_WIDGET(ui->label_album_title), GTK_ALIGN_START); gtk_widget_set_halign(GTK_WIDGET(ui->label_album_summary), GTK_ALIGN_START); gtk_widget_set_halign(GTK_WIDGET(ui->label_album_privacy), GTK_ALIGN_START); // 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)); gtk_entry_set_width_chars(GTK_ENTRY(ui->entry_album_title), 0); gtk_entry_set_width_chars(GTK_ENTRY(ui->entry_album_summary), 0); // retrieve saved accounts ui_refresh_users(ui); //////// album list ///////// GtkWidget *albumlist = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 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_box_new(GTK_ORIENTATION_HORIZONTAL, 5); GtkWidget *vbox_auth_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget *vbox_auth_fields = gtk_box_new(GTK_ORIENTATION_VERTICAL, 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_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox_album), TRUE); // hide it by default GtkWidget *vbox_album_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget *vbox_album_fields = gtk_box_new(GTK_ORIENTATION_VERTICAL, 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); }
void _fcitx_main_window_add_addon_page(FcitxMainWindow* self) { /* load addon */ FcitxAddon* addon; utarray_new(self->addons, &addonicd); FcitxAddonsLoad(self->addons); GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); /* advance check box */ self->advancecheckbox = gtk_check_button_new_with_label(_("Advance")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->advancecheckbox), FALSE); g_signal_connect(G_OBJECT(self->advancecheckbox), "toggled", G_CALLBACK(_fcitx_main_window_checkbox_changed), self); /* filter entry */ self->filterentry = gtk_entry_new(); gtk_entry_set_icon_from_gicon (GTK_ENTRY (self->filterentry), GTK_ENTRY_ICON_SECONDARY, g_themed_icon_new_with_default_fallbacks("edit-clear")); g_object_set(G_OBJECT(self->filterentry), "margin", 5, NULL); #if GTK_CHECK_VERSION(3,2,0) gtk_entry_set_placeholder_text(GTK_ENTRY (self->filterentry), _("Search Addon")); #endif g_signal_connect(G_OBJECT(self->filterentry), "icon-press", G_CALLBACK (icon_press_cb), NULL); /* list view */ self->addonstore = gtk_list_store_new(N_COLUMNS, G_TYPE_POINTER); for (addon = (FcitxAddon *) utarray_front(self->addons); addon != NULL; addon = (FcitxAddon *) utarray_next(self->addons, addon)) { GtkTreeIter iter; gtk_list_store_append(self->addonstore, &iter); gtk_list_store_set(self->addonstore, &iter, LIST_ADDON, addon, -1); } self->filtermodel = gtk_tree_model_filter_new(GTK_TREE_MODEL(self->addonstore), NULL); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(self->filtermodel), (GtkTreeModelFilterVisibleFunc) _filter_addon_func, self, NULL); self->addonview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(self->filtermodel)); /* add column check box */ self->togglecell = gtk_cell_renderer_toggle_new(); self->checkboxcolumn = gtk_tree_view_column_new_with_attributes("Enable", self->togglecell, NULL); gtk_tree_view_column_set_visible(self->checkboxcolumn, FALSE); gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), self->checkboxcolumn); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(self->checkboxcolumn), self->togglecell, _fcitx_main_window_enabled_data_func, NULL, NULL); /* add column text */ GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Name", renderer, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), column); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(column), renderer, _fcitx_main_window_name_data_func, NULL, NULL); /* add addon list to vbox */ GtkWidget* swin = gtk_scrolled_window_new(NULL, NULL); g_object_set(swin, "hscrollbar-policy", GTK_POLICY_NEVER, NULL); g_object_set(self->addonview, "headers-visible", FALSE, NULL); gtk_container_add(GTK_CONTAINER(swin), self->addonview); gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0); g_object_set(G_OBJECT(swin), "margin-left", 5, "margin-right", 5, "shadow-type", GTK_SHADOW_IN, NULL); g_signal_connect(G_OBJECT(self->togglecell), "toggled", G_CALLBACK(_fcitx_main_window_toggled_cb), GTK_TREE_MODEL(self->addonstore)); gtk_box_pack_start(GTK_BOX(vbox), self->advancecheckbox, FALSE, TRUE, 0); g_object_set(G_OBJECT(self->advancecheckbox), "margin-left", 5, "margin-right", 5, NULL); gtk_box_pack_start(GTK_BOX(vbox), self->filterentry, FALSE, TRUE, 5); /* configure button */ GtkWidget* hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start(GTK_BOX(vbox), hbuttonbox, FALSE, TRUE, 0); g_object_set(G_OBJECT(hbuttonbox), "margin", 5, NULL); self->button = gtk_button_new_with_label(_("Configure")); gtk_widget_set_sensitive(self->button, FALSE); gtk_button_set_image(GTK_BUTTON(self->button), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("preferences-system"), GTK_ICON_SIZE_BUTTON)); gtk_box_pack_start(GTK_BOX(hbuttonbox), self->button, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(self->button), "clicked", G_CALLBACK(_fcitx_main_window_configure_button_clicked), self); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self->addonview)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(_fcitx_main_window_addon_selection_changed), self); g_signal_connect(G_OBJECT(self->filterentry), "changed", G_CALLBACK(_fcitx_main_window_filtertext_changed), self); gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(self->filtermodel)); g_signal_connect(G_OBJECT(self->addonview), "row-activated", G_CALLBACK(_fcitx_main_window_addon_row_activated), self); _fcitx_main_window_add_page(self, _("Addon"), vbox); }
void prepare_controls_for_state (MafwPlayState state) { gboolean play_possible; gboolean pause_possible; gboolean stop_possible; switch (state) { case Stopped: /* Disable the seekbar when the state is stopped */ gtk_widget_set_sensitive(position_hscale, FALSE); play_possible = TRUE; pause_possible = FALSE; stop_possible = TRUE; in_state_stopped = TRUE; remove_timeout (); g_signal_handlers_block_by_func (G_OBJECT(position_hscale), on_position_hscale_value_changed, NULL); gtk_range_set_value (GTK_RANGE (position_hscale), 0.0); gtk_label_set_text(GTK_LABEL(position_label), "00:00"); g_signal_handlers_unblock_by_func(G_OBJECT(position_hscale), on_position_hscale_value_changed, NULL); break; case Paused: play_possible = TRUE; pause_possible = FALSE; stop_possible = TRUE; in_state_stopped = FALSE; remove_timeout (); update_position (NULL); break; case Playing: play_possible = FALSE; pause_possible = TRUE; stop_possible = TRUE; in_state_stopped = FALSE; /* Start tracking media position in playing state */ add_timeout (); break; case Transitioning: play_possible = FALSE; pause_possible = FALSE; stop_possible = TRUE; in_state_stopped = FALSE; remove_timeout (); break; default: play_possible = TRUE; pause_possible = FALSE; stop_possible = TRUE; in_state_stopped = FALSE; remove_timeout (); break; } if (!stop_possible) { g_signal_handlers_block_by_func (position_hscale, on_position_hscale_value_changed, NULL); gtk_range_set_value (GTK_RANGE (position_hscale), 0.0); gtk_label_set_text(GTK_LABEL(position_label), "00:00"); g_signal_handlers_unblock_by_func (position_hscale, on_position_hscale_value_changed, NULL); } if (play_possible == TRUE) { GtkWidget *image; image = gtk_image_new_from_icon_name("camera_playback", HILDON_ICON_SIZE_SMALL); gtk_button_set_image(GTK_BUTTON(play_button), image); } if (pause_possible == TRUE) { GtkWidget *image; image = gtk_image_new_from_icon_name("camera_video_pause", HILDON_ICON_SIZE_SMALL); gtk_button_set_image(GTK_BUTTON(play_button), image); } if (play_possible == FALSE && pause_possible == FALSE) { gtk_widget_set_sensitive (play_button, FALSE); } else { gtk_widget_set_sensitive (play_button, TRUE); } gtk_widget_set_sensitive (stop_button, stop_possible); }
void setup_renderer_controls (GtkBuilder *builder) { GtkWidget* image; volume_vscale = GTK_WIDGET(gtk_builder_get_object(builder, "volume-vscale")); g_assert (volume_vscale != NULL); position_hscale = GTK_WIDGET(gtk_builder_get_object(builder, "position-hscale")); g_assert (position_hscale != NULL); position_label = GTK_WIDGET(gtk_builder_get_object(builder, "position-label")); g_assert (position_label != NULL); /* Previous */ prev_button = GTK_WIDGET(gtk_builder_get_object(builder, "previous-button")); g_assert (prev_button != NULL); /* Seek backwards */ seek_backwards_button = GTK_WIDGET(gtk_builder_get_object(builder, "seek-backwards-button")); g_assert (seek_backwards_button != NULL); /* Play */ play_button = GTK_WIDGET(gtk_builder_get_object(builder, "play-button")); g_assert (play_button != NULL); gtk_button_set_label(GTK_BUTTON(play_button), NULL); image = gtk_image_new_from_icon_name("camera_playback", HILDON_ICON_SIZE_SMALL); gtk_button_set_image(GTK_BUTTON(play_button), image); /* Stop */ stop_button = GTK_WIDGET(gtk_builder_get_object(builder, "stop-button")); g_assert (stop_button != NULL); /* Seek forwards */ seek_forwards_button = GTK_WIDGET(gtk_builder_get_object(builder, "seek-forwards-button")); g_assert (seek_forwards_button != NULL); /* Next */ next_button = GTK_WIDGET(gtk_builder_get_object(builder, "next-button")); g_assert (next_button != NULL); /* Mute */ mute_toggle = GTK_WIDGET(gtk_builder_get_object(builder, "mute-button")); g_assert (mute_toggle != NULL); #ifndef MAFW_TEST_GUI_ENABLE_MUTE gtk_widget_set_sensitive(mute_toggle, FALSE); #endif timeout_id = 0; /* Seeking is disabled by default */ enable_seek_buttons(FALSE); g_object_weak_ref (G_OBJECT (position_hscale), (GWeakNotify) remove_timeout, NULL); }
GdkWindow *wxCheckBox::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const { return GTK_BUTTON(m_widgetCheckbox)->event_window; }
static GtkWidget * nimf_settings_page_key_build_string_array (NimfSettingsPageKey *page_key) { GtkListStore *store; GtkWidget *treeview; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkWidget *scrolled_w; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *button1; GtkWidget *button2; gchar **strv; gchar *detailed_signal; GtkTreeIter iter; gint j; button1 = gtk_button_new_from_icon_name ("list-add", GTK_ICON_SIZE_SMALL_TOOLBAR); button2 = gtk_button_new_from_icon_name ("list-remove", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_button_set_relief (GTK_BUTTON (button1), GTK_RELIEF_NONE); gtk_button_set_relief (GTK_BUTTON (button2), GTK_RELIEF_NONE); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #if GTK_CHECK_VERSION (3, 12, 0) gtk_widget_set_margin_end (page_key->label, 15); #else gtk_widget_set_margin_right (page_key->label, 15); #endif gtk_box_pack_start (GTK_BOX (hbox), page_key->label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), button2, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), button1, FALSE, FALSE, 0); store = gtk_list_store_new (1, G_TYPE_STRING); strv = g_settings_get_strv (page_key->gsettings, page_key->key); for (j = 0; strv[j] != NULL; j++) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, strv[j], -1); } treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (store); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Hotkeys", renderer, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); scrolled_w = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_w), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_w), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (scrolled_w), treeview); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (vbox), scrolled_w, FALSE, FALSE, 0); page_key->treeview = treeview; detailed_signal = g_strdup_printf ("changed::%s", page_key->key); g_signal_connect (treeview, "realize", G_CALLBACK (on_tree_view_realize), scrolled_w); g_signal_connect (button1, "clicked", G_CALLBACK (on_button_clicked_add), page_key); g_signal_connect (button2, "clicked", G_CALLBACK (on_button_clicked_remove), page_key); g_signal_connect (page_key->gsettings, detailed_signal, G_CALLBACK (on_gsettings_changed), page_key->treeview); g_strfreev (strv); g_free (detailed_signal); return vbox; }
static void thunar_chooser_button_pressed (ThunarChooserButton *chooser_button, GtkWidget *button) { ThunarVfsMimeApplication *default_application; ThunarVfsMimeInfo *info; ThunarIconFactory *icon_factory; GtkIconTheme *icon_theme; const gchar *icon_name; GdkPixbuf *icon; GtkWidget *image; GtkWidget *item; GtkWidget *menu; GList *applications; GList *lp; gint icon_size; _thunar_return_if_fail (THUNAR_IS_CHOOSER_BUTTON (chooser_button)); _thunar_return_if_fail (chooser_button->button == button); _thunar_return_if_fail (GTK_IS_BUTTON (button)); /* verify that we have a valid file */ if (G_UNLIKELY (chooser_button->file == NULL)) return; /* determine the mime info for the file */ info = thunar_file_get_mime_info (chooser_button->file); /* determine the default application */ default_application = thunar_vfs_mime_database_get_default_application (chooser_button->database, info); if (G_UNLIKELY (default_application == NULL)) { /* no default application, just popup the application chooser */ thunar_chooser_button_activate_other (chooser_button); return; } /* determine all applications that claim to be able to handle the file */ applications = thunar_vfs_mime_database_get_applications (chooser_button->database, info); /* make sure the default application comes first */ lp = g_list_find (applications, default_application); if (G_LIKELY (lp != NULL)) { applications = g_list_delete_link (applications, lp); g_object_unref (G_OBJECT (default_application)); } applications = g_list_prepend (applications, default_application); /* allocate a new popup menu */ menu = gtk_menu_new (); /* determine the icon size for menus */ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_size, &icon_size); /* determine the icon factory for our screen */ icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (button)); icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme); /* add the other possible applications */ for (lp = applications; lp != NULL; lp = lp->next) { item = gtk_image_menu_item_new_with_label (thunar_vfs_mime_handler_get_name (lp->data)); g_object_set_data_full (G_OBJECT (item), I_("thunar-vfs-mime-application"), lp->data, g_object_unref); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_chooser_button_activate), chooser_button); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); /* setup the icon for the application */ icon_name = thunar_vfs_mime_handler_lookup_icon_name (lp->data, icon_theme); icon = thunar_icon_factory_load_icon (icon_factory, icon_name, icon_size, NULL, FALSE); image = gtk_image_new_from_pixbuf (icon); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); gtk_widget_show (image); if (G_LIKELY (icon != NULL)) g_object_unref (icon); } /* cleanup */ g_object_unref (G_OBJECT (icon_factory)); /* append a separator */ item = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); /* release the applications list */ g_list_free (applications); /* add the "Other Application..." choice */ item = gtk_image_menu_item_new_with_mnemonic (_("_Other Application...")); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_chooser_button_activate_other), chooser_button); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); /* make sure the menu has atleast the same width as the chooser */ if (menu->allocation.width < button->allocation.width) gtk_widget_set_size_request (menu, button->allocation.width, -1); /* run the menu on the button's screen (takes over the floating reference of menu) */ thunar_gtk_menu_run (GTK_MENU (menu), button, menu_position, button, 0, gtk_get_current_event_time ()); /* yeppa, that's a requirement */ gtk_button_released (GTK_BUTTON (button)); }
int main (int argc, char *argv[]) { GDeviceSetup gds = { NULL, NULL, NULL, NULL, 0}; GtkWidget *window; GtkWidget *scrollwin; GtkWidget *bt_new; GtkWidget *icon; GtkWidget *message; int response; int loop = TRUE; gds.dpy = dpy_init(); if (!gds.dpy) { fprintf(stderr, "Cannot connect to X server, or X server does not " "support XI 2."); return 1; } gtk_init(&argc, &argv); gds.display = gdk_display_get_default(); /* init dialog window */ window = gtk_dialog_new(); gtk_window_set_default_size (GTK_WINDOW(window), 10, 500); gds.window = window; gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_dialog_add_buttons(GTK_DIALOG(window), GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_UNDO, GTK_RESPONSE_CANCEL, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); toggle_undo_button(&gds, FALSE); /* main dialog area */ gds.treeview = get_tree_view(&gds); scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(scrollwin), GTK_WIDGET(gds.treeview)); bt_new = gtk_button_new_with_mnemonic("_Create Cursor/Keyboard Focus"); icon = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(bt_new), icon); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))), GTK_WIDGET(scrollwin), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))), bt_new, 0, 0, 10); g_signal_connect(G_OBJECT(bt_new), "clicked", G_CALLBACK(signal_new_md), &gds); g_signal_connect (gdk_display_get_device_manager (gds.display), "device-added", G_CALLBACK (on_device_change), &gds); g_signal_connect (gdk_display_get_device_manager (gds.display), "device-removed", G_CALLBACK (on_device_change), &gds); g_signal_connect (gdk_display_get_device_manager (gds.display), "device-changed", G_CALLBACK (on_device_change), &gds); gtk_widget_show_all(window); do { response = gtk_dialog_run(GTK_DIALOG(window)); switch(response) { case GTK_RESPONSE_HELP: break; case GTK_RESPONSE_CANCEL: g_printerr("undo !\n"); /*query_devices(&gds); g_list_free(gds.changes); gds.changes = NULL; */ toggle_undo_button(&gds, FALSE); break; case GTK_RESPONSE_CLOSE: if (gds.changes) { message = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "You have unapplied " "changes. Are you sure " "you want to quit?"); response = gtk_dialog_run(GTK_DIALOG(message)); gtk_widget_destroy(message); loop = (response == GTK_RESPONSE_NO); } else loop = FALSE; break; case GTK_RESPONSE_DELETE_EVENT: loop = FALSE; break; } } while (loop); g_list_free(gds.changes); XCloseDisplay(gds.dpy); return 0; }
/* Object initialization * Create private structure and set up default values */ static void nojs_preferences_init(NoJSPreferences *self) { NoJSPreferencesPrivate *priv; GtkTreeSortable *sortableList; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkWidget *widget; gchar *dialogTitle; GtkWidget *scrolled; GtkWidget *vbox; GtkWidget *hbox; gint width, height; GtkListStore *list; GtkTreeIter listIter; priv=self->priv=NOJS_PREFERENCES_GET_PRIVATE(self); /* Set up default values */ priv->manager=NULL; /* Get content area to add gui controls to */ priv->contentArea=gtk_dialog_get_content_area(GTK_DIALOG(self)); #if GTK_CHECK_VERSION (3, 0, 0) vbox=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); #else vbox=gtk_vbox_new(FALSE, 0); #endif /* Set up dialog */ dialogTitle=_("Configure NoJS"); gtk_window_set_title(GTK_WINDOW(self), dialogTitle); gtk_window_set_icon_name(GTK_WINDOW(self), GTK_STOCK_PROPERTIES); sokoke_widget_get_text_size(GTK_WIDGET(self), "M", &width, &height); gtk_window_set_default_size(GTK_WINDOW(self), width*52, -1); widget=sokoke_xfce_header_new(gtk_window_get_icon_name(GTK_WINDOW(self)), dialogTitle); if(widget) gtk_box_pack_start(GTK_BOX(priv->contentArea), widget, FALSE, FALSE, 0); gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); /* Set up description */ widget=gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(widget), _("Below is a list of all web sites and the policy set for them. " "You can delete policies by marking the entries and clicking on <i>Delete</i>.")); gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE); gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 4); /* Set up domain list */ priv->listStore=gtk_list_store_new(N_COLUMN, G_TYPE_STRING, /* DOMAIN_COLUMN */ G_TYPE_STRING /* POLICY_COLUMN */); sortableList=GTK_TREE_SORTABLE(priv->listStore); gtk_tree_sortable_set_sort_func(sortableList, DOMAIN_COLUMN, (GtkTreeIterCompareFunc)_nojs_preferences_sort_string_callback, GINT_TO_POINTER(DOMAIN_COLUMN), NULL); gtk_tree_sortable_set_sort_func(sortableList, POLICY_COLUMN, (GtkTreeIterCompareFunc)_nojs_preferences_sort_string_callback, GINT_TO_POINTER(POLICY_COLUMN), NULL); gtk_tree_sortable_set_sort_column_id(sortableList, DOMAIN_COLUMN, GTK_SORT_ASCENDING); /* Set up domain addition widgets */ #ifdef HAVE_GTK3 hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE); #else hbox=gtk_hbox_new(FALSE, 0); #endif priv->addDomainEntry=gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(priv->addDomainEntry), 64); gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainEntry); g_signal_connect_swapped(priv->addDomainEntry, "changed", G_CALLBACK(_nojs_preferences_on_add_domain_entry_changed), self); list=gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING); gtk_list_store_append(list, &listIter); gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_ACCEPT, 1, _("Accept"), -1); gtk_list_store_append(list, &listIter); gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_ACCEPT_TEMPORARILY, 1, _("Accept for session"), -1); gtk_list_store_append(list, &listIter); gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_BLOCK, 1, _("Block"), -1); priv->addDomainPolicyCombo=gtk_combo_box_new_with_model(GTK_TREE_MODEL(list)); gtk_combo_box_set_active(GTK_COMBO_BOX(priv->addDomainPolicyCombo), 0); gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainPolicyCombo); renderer=gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, TRUE); gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, "text", 1); priv->addDomainButton=gtk_button_new_from_stock(GTK_STOCK_ADD); gtk_widget_set_sensitive(priv->addDomainButton, FALSE); gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainButton); g_signal_connect_swapped(priv->addDomainButton, "clicked", G_CALLBACK(_nojs_preferences_on_add_domain_clicked), self); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5); /* Set up domain list view */ priv->list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->listStore)); #if !GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_size_request(priv->list, -1, 300); #endif priv->listSelection=gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->list)); gtk_tree_selection_set_mode(priv->listSelection, GTK_SELECTION_MULTIPLE); g_signal_connect_swapped(priv->listSelection, "changed", G_CALLBACK(_nojs_preferences_changed_selection), self); renderer=gtk_cell_renderer_text_new(); column=gtk_tree_view_column_new_with_attributes(_("Domain"), renderer, "text", DOMAIN_COLUMN, NULL); gtk_tree_view_column_set_sort_column_id(column, DOMAIN_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column); renderer=gtk_cell_renderer_combo_new(); g_object_set(G_OBJECT(renderer), "model", list, "text-column", 1, "has-entry", false, "editable", true, NULL); g_signal_connect_swapped(renderer, "editing-started", G_CALLBACK(_nojs_preferences_on_policy_editing_started), self); g_signal_connect_swapped(renderer, "editing-canceled", G_CALLBACK(_nojs_preferences_on_policy_editing_canceled), self); g_signal_connect_swapped(renderer, "edited", G_CALLBACK(_nojs_preferences_on_policy_edited), self); column=gtk_tree_view_column_new_with_attributes(_("Policy"), renderer, "text", POLICY_COLUMN, NULL); gtk_tree_view_column_set_sort_column_id(column, POLICY_COLUMN); gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column); scrolled=gtk_scrolled_window_new(NULL, NULL); #if GTK_CHECK_VERSION (3, 0, 0) gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), height*10); #endif gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(scrolled), priv->list); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 5); /* Set up JavaScript domain list management buttons */ #if GTK_CHECK_VERSION (3, 0, 0) hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE); #else hbox=gtk_hbox_new(FALSE, 0); #endif priv->deleteButton=gtk_button_new_from_stock(GTK_STOCK_DELETE); gtk_widget_set_sensitive(priv->deleteButton, FALSE); gtk_container_add(GTK_CONTAINER(hbox), priv->deleteButton); g_signal_connect_swapped(priv->deleteButton, "clicked", G_CALLBACK(_nojs_preferences_on_delete_selection), self); priv->deleteAllButton=gtk_button_new_with_mnemonic(_("Delete _all")); gtk_button_set_image(GTK_BUTTON(priv->deleteAllButton), gtk_image_new_from_stock(GTK_STOCK_DELETE, GTK_ICON_SIZE_BUTTON)); gtk_widget_set_sensitive(priv->deleteAllButton, FALSE); gtk_container_add(GTK_CONTAINER(hbox), priv->deleteAllButton); g_signal_connect_swapped(priv->deleteAllButton, "clicked", G_CALLBACK(_nojs_preferences_on_delete_all), self); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5); /* Add "allow-all-sites" checkbox */ priv->allowAllSitesCheckbox=gtk_check_button_new_with_mnemonic(_("A_llow scripts at all sites")); priv->signalAllowAllSitesToggledID=g_signal_connect_swapped(priv->allowAllSitesCheckbox, "toggled", G_CALLBACK(_nojs_preferences_on_allow_all_sites_changed), self); gtk_box_pack_start(GTK_BOX(vbox), priv->allowAllSitesCheckbox, FALSE, TRUE, 5); /* Add "block-unknown-domains" checkbox */ priv->blockUnknownDomainsCheckbox=gtk_check_button_new_with_mnemonic(_("Bloc_k scripts at unknown domains by default")); priv->signalBlockUnknownDomainsToggledID=g_signal_connect_swapped(priv->blockUnknownDomainsCheckbox, "toggled", G_CALLBACK(_nojs_preferences_on_block_unknown_domains_changed), self); gtk_box_pack_start(GTK_BOX(vbox), priv->blockUnknownDomainsCheckbox, FALSE, TRUE, 5); /* Add "check-second-level-only" checkbox */ priv->checkSecondLevelOnlyCheckbox=gtk_check_button_new_with_mnemonic(_("S_et permissions on second-level domain")); priv->signalCheckSecondLevelOnlyToggledID=g_signal_connect_swapped(priv->checkSecondLevelOnlyCheckbox, "toggled", G_CALLBACK(_nojs_preferences_on_check_second_level_only_changed), self); gtk_box_pack_start(GTK_BOX(vbox), priv->checkSecondLevelOnlyCheckbox, FALSE, TRUE, 5); /* Finalize setup of content area */ gtk_box_pack_start(GTK_BOX(priv->contentArea), vbox, TRUE, TRUE, 0); }
static GtkWidget *create_dialog(void) { GtkWidget *dialog; GtkWidget *header_image; GtkWidget *header_label; GtkWidget *label_info; GtkWidget *codename_label; GtkWidget *builddate_label; GtkWidget *url_button; GtkWidget *cop_label; GtkWidget *label; GtkWidget *license_textview; GtkWidget *notebook; GtkWidget *box; GtkWidget *credits_scrollwin; GtkWidget *table; GtkWidget *license_scrollwin; GtkWidget *info_box; GtkWidget *header_hbox; GtkWidget *header_eventbox; GdkPixbuf *icon; GtkTextBuffer* tb; gchar *license_text = NULL; gchar buffer[512]; gchar buffer2[128]; guint i, row = 0; dialog = gtk_dialog_new(); /* configure dialog */ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_widgets.window)); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_title(GTK_WINDOW(dialog), _("About Geany")); gtk_widget_set_name(dialog, "GeanyDialog"); gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); g_signal_connect(dialog, "key-press-event", G_CALLBACK(gb_on_key_pressed), NULL); /* create header */ header_eventbox = gtk_event_box_new(); gtk_widget_show(header_eventbox); header_hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(header_hbox), 4); gtk_widget_show(header_hbox); gtk_container_add(GTK_CONTAINER(header_eventbox), header_hbox); header_image = gtk_image_new(); gtk_box_pack_start(GTK_BOX(header_hbox), header_image, FALSE, FALSE, 0); header_label = gtk_label_new(NULL); gtk_label_set_use_markup(GTK_LABEL(header_label), TRUE); /* print the subversion revision generated by ./configure if it is available */ g_snprintf(buffer, sizeof(buffer), HEADER, main_get_version_string()); gtk_label_set_markup(GTK_LABEL(header_label), buffer); gtk_widget_show(header_label); gtk_box_pack_start(GTK_BOX(header_hbox), header_label, FALSE, FALSE, 0); header_eventbox_style_set(header_eventbox); header_label_style_set(header_label); g_signal_connect_after(header_eventbox, "style-set", G_CALLBACK(header_eventbox_style_set), NULL); g_signal_connect_after(header_label, "style-set", G_CALLBACK(header_label_style_set), NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), header_eventbox, FALSE, FALSE, 0); /* set image */ icon = ui_new_pixbuf_from_inline(GEANY_IMAGE_LOGO); gtk_image_set_from_pixbuf(GTK_IMAGE(header_image), icon); gtk_window_set_icon(GTK_WINDOW(dialog), icon); g_object_unref(icon); /* free our reference */ /* create notebook */ notebook = gtk_notebook_new(); gtk_widget_show(notebook); gtk_container_set_border_width(GTK_CONTAINER(notebook), 2); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, TRUE, TRUE, 0); /* create "Info" tab */ info_box = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(info_box), 6); gtk_widget_show(info_box); label_info = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(label_info), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label_info), TRUE); gtk_label_set_use_markup(GTK_LABEL(label_info), TRUE); g_snprintf(buffer, sizeof(buffer), INFO, _("A fast and lightweight IDE")); gtk_label_set_markup(GTK_LABEL(label_info), buffer); gtk_misc_set_padding(GTK_MISC(label_info), 2, 11); gtk_widget_show(label_info); gtk_box_pack_start(GTK_BOX(info_box), label_info, FALSE, FALSE, 0); /* Codename label */ codename_label = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(codename_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(codename_label), TRUE); gtk_label_set_use_markup(GTK_LABEL(codename_label), TRUE); gtk_label_set_markup(GTK_LABEL(codename_label), CODENAME); gtk_misc_set_padding(GTK_MISC(codename_label), 2, 8); gtk_widget_show(codename_label); gtk_box_pack_start(GTK_BOX(info_box), codename_label, FALSE, FALSE, 0); /* build date label */ builddate_label = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(builddate_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(builddate_label), TRUE); gtk_label_set_use_markup(GTK_LABEL(builddate_label), TRUE); g_snprintf(buffer2, sizeof(buffer2), _("(built on or after %s)"), __DATE__); g_snprintf(buffer, sizeof(buffer), BUILDDATE, buffer2); gtk_label_set_markup(GTK_LABEL(builddate_label), buffer); gtk_misc_set_padding(GTK_MISC(builddate_label), 2, 2); gtk_widget_show(builddate_label); gtk_box_pack_start(GTK_BOX(info_box), builddate_label, FALSE, FALSE, 0); box = gtk_hbutton_box_new(); url_button = gtk_button_new(); gtk_button_set_relief(GTK_BUTTON(url_button), GTK_RELIEF_NONE); g_signal_connect(url_button, "clicked", G_CALLBACK(homepage_clicked), (gpointer)GEANY_HOMEPAGE); label = gtk_label_new(NULL); gtk_label_set_text(GTK_LABEL(label), GEANY_HOMEPAGE); gtk_widget_show(label); gtk_container_add(GTK_CONTAINER(url_button), label); gtk_widget_show(url_button); gtk_box_pack_start(GTK_BOX(box), url_button, FALSE, FALSE, 0); gtk_widget_show(box); gtk_box_pack_start(GTK_BOX(info_box), box, FALSE, FALSE, 10); /* copyright label */ cop_label = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(cop_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(cop_label), FALSE); gtk_label_set_use_markup(GTK_LABEL(cop_label), TRUE); gtk_label_set_markup(GTK_LABEL(cop_label), COPYRIGHT); gtk_misc_set_padding(GTK_MISC(cop_label), 2, 10); gtk_widget_show(cop_label); gtk_box_pack_start(GTK_BOX(info_box), cop_label, FALSE, FALSE, 0); /*gtk_container_add(GTK_CONTAINER(info_box), cop_label); */ label = gtk_label_new(_("Info")); gtk_widget_show(label); gtk_widget_show_all(info_box); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_box, label); /* create "Credits" tab */ credits_scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_container_set_border_width(GTK_CONTAINER(credits_scrollwin), 10); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(credits_scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); table = gtk_table_new(23 + translators_len + prev_translators_len, 3, FALSE); gtk_table_set_col_spacings(GTK_TABLE(table), 10); row = 0; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Developers")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, GTK_FILL, 0, 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Colomban Wendling - %s", _("maintainer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Nick Treleaven - %s", _("developer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Enrico Tröger - %s", _("developer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Matthew Brush - %s", _("developer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Frank Lanitz - %s", _("translation maintainer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Translators")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; for (i = 0; i < translators_len; i++) { ROW(translators[i][0], row, 0, 1, 4, 0); ROW(translators[i][1], row, 1, 0, 4, 0); row++; } ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Previous Translators")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; for (i = 0; i < prev_translators_len; i++) { ROW(prev_translators[i][0], row, 0, 1, 4, 0); ROW(prev_translators[i][1], row, 1, 0, 4, 0); row++; } ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Contributors")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; g_snprintf(buffer, sizeof(buffer), _("Some of the many contributors (for a more detailed list, see the file %s):"), #ifdef G_OS_WIN32 "Thanks.txt" #else "THANKS" #endif ); label = geany_wrap_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; label = geany_wrap_label_new(contributors); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL | GTK_EXPAND), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(credits_scrollwin), table); gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_widget_get_parent(table)), GTK_SHADOW_NONE); gtk_widget_show_all(table); label = gtk_label_new(_("Credits")); gtk_widget_show(label); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), credits_scrollwin, label); /* create "License" tab */ license_scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_container_set_border_width(GTK_CONTAINER(license_scrollwin), 6); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(license_scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); license_textview = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(license_textview), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(license_textview), FALSE); gtk_widget_show(license_textview); gtk_container_add(GTK_CONTAINER(license_scrollwin), license_textview); label = gtk_label_new(_("License")); gtk_widget_show(label); g_snprintf(buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S "GPL-2", app->datadir); g_file_get_contents(buffer, &license_text, NULL, NULL); if (license_text == NULL) { license_text = g_strdup( _("License text could not be found, please visit http://www.gnu.org/licenses/gpl-2.0.txt to view it online.")); } tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(license_textview)); gtk_text_buffer_set_text(tb, license_text, -1); g_free(license_text); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), license_scrollwin, label); gtk_widget_show_all(dialog); return dialog; }
Download * download_new(DownloadPrefs * prefs, char const * url) { Download * download; char * p; char buf[256]; GtkWidget * vbox; GtkWidget * hbox; GtkSizeGroup * left; GtkWidget * widget; PangoFontDescription * bold; unsigned long id; /* verify arguments */ if(prefs == NULL || url == NULL) { errno = EINVAL; _download_error(NULL, NULL, 1); return NULL; } if((download = malloc(sizeof(*download))) == NULL) { _download_error(NULL, "malloc", 1); return NULL; } /* initialize structure */ download->prefs.output = (prefs->output != NULL) ? strdup(prefs->output) : NULL; download->prefs.user_agent = (prefs->user_agent != NULL) ? strdup(prefs->user_agent) : NULL; if((p = _ghtml_make_url(NULL, url)) != NULL) url = p; download->url = strdup(url); free(p); if(download->url != NULL && prefs->output == NULL) download->prefs.output = strdup(basename(download->url)); download->conn = NULL; download->data_received = 0; download->content_length = 0; download->timeout = 0; download->pulse = 0; /* verify initialization */ if((prefs->output != NULL && download->prefs.output == NULL) || (prefs->user_agent != NULL && download->prefs.user_agent == NULL) || download->url == NULL || gettimeofday(&download->tv, NULL) != 0) { _download_error(NULL, "gettimeofday", 1); download_delete(download); return NULL; } /* window */ if(prefs->embedded == 0) { download->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); snprintf(buf, sizeof(buf), "%s %s", _("Download"), download->url); #if GTK_CHECK_VERSION(2, 6, 0) gtk_window_set_icon_name(GTK_WINDOW(download->window), "stock_download"); #endif gtk_window_set_resizable(GTK_WINDOW(download->window), FALSE); gtk_window_set_title(GTK_WINDOW(download->window), buf); g_signal_connect_swapped(download->window, "delete-event", G_CALLBACK(_download_on_closex), download); } else { download->window = gtk_plug_new(0); g_signal_connect_swapped(download->window, "embedded", G_CALLBACK(_download_on_embedded), download); } #if GTK_CHECK_VERSION(3, 0, 0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); #else vbox = gtk_vbox_new(FALSE, 2); #endif bold = pango_font_description_new(); pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD); left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); /* address */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new(_("Address: ")); #if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_override_font(widget, bold); g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_widget_modify_font(widget, bold); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(left, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); download->address = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(download->address), download->url); gtk_editable_set_editable(GTK_EDITABLE(download->address), FALSE); gtk_box_pack_start(GTK_BOX(hbox), download->address, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); /* labels */ _download_label(vbox, bold, left, _("File: "), &download->filename, download->prefs.output); _download_label(vbox, bold, left, _("Status: "), &download->status, _("Resolving...")); _download_label(vbox, bold, left, _("Received: "), &download->received, _("0.0 kB")); _download_label(vbox, bold, left, _("Remaining: "), &download->remaining, _("Unknown")); /* progress bar */ download->progress = gtk_progress_bar_new(); gtk_box_pack_start(GTK_BOX(vbox), download->progress, FALSE, FALSE, 0); /* checkbox */ download->check = gtk_check_button_new_with_label( _("Close window when the download is complete")); gtk_box_pack_start(GTK_BOX(vbox), download->check, FALSE, FALSE, 0); /* button */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif download->cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); g_signal_connect_swapped(download->cancel, "clicked", G_CALLBACK( _download_on_cancel), download); gtk_box_pack_end(GTK_BOX(hbox), download->cancel, FALSE, TRUE, 0); download->browse = gtk_button_new_with_mnemonic("_Open folder"); gtk_widget_set_no_show_all(download->browse, TRUE); widget = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(download->browse), widget); g_signal_connect_swapped(download->browse, "clicked", G_CALLBACK( _download_on_browse), download); gtk_box_pack_end(GTK_BOX(hbox), download->browse, FALSE, TRUE, 0); gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(download->window), 4); gtk_container_add(GTK_CONTAINER(download->window), vbox); download->timeout = g_idle_add(_download_on_idle, download); _download_refresh(download); gtk_widget_show_all(vbox); if(prefs->embedded == 0) gtk_widget_show(download->window); else { id = gtk_plug_get_id(GTK_PLUG(download->window)); printf("%lu\n", id); fclose(stdout); } _download_cnt++; return download; }
GtkWidget *plugin_configure(GtkDialog *dialog) { GtkWidget *vbox, *label, *notebook_vbox, *checkbox_enable; GtkWidget *notebook, *inner_vbox; vbox = gtk_vbox_new(FALSE, 6); notebook = gtk_notebook_new(); GTK_WIDGET_UNSET_FLAGS(notebook, GTK_CAN_FOCUS); gtk_container_set_border_width(GTK_CONTAINER(notebook), 5); gtk_box_pack_start(GTK_BOX(vbox), notebook, FALSE, TRUE, 0); /* * Auto Save */ { GtkWidget *spin, *hbox, *checkbox, *radio1, *radio2; notebook_vbox = gtk_vbox_new(FALSE, 2); inner_vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(inner_vbox), 5); gtk_box_pack_start(GTK_BOX(notebook_vbox), inner_vbox, TRUE, TRUE, 5); gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), notebook_vbox, gtk_label_new(_("Auto Save")), NOTEBOOK_PAGE_AUTOSAVE); checkbox_enable = gtk_check_button_new_with_mnemonic(_("_Enable")); gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_enable), FALSE); pref_widgets.checkbox_enable_autosave = checkbox_enable; gtk_box_pack_start(GTK_BOX(inner_vbox), checkbox_enable, FALSE, FALSE, 6); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_enable), enable_autosave); g_signal_connect(checkbox_enable, "toggled", G_CALLBACK(checkbox_toggled_cb), GINT_TO_POINTER(NOTEBOOK_PAGE_AUTOSAVE)); label = gtk_label_new_with_mnemonic(_("Auto save _interval:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_container_add(GTK_CONTAINER(inner_vbox), label); pref_widgets.autosave_interval_spin = spin = gtk_spin_button_new_with_range(1, 1800, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), autosave_interval); gtk_label_set_mnemonic_widget(GTK_LABEL(label), spin); label = gtk_label_new(_("seconds")); hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), spin, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(inner_vbox), hbox, FALSE, FALSE, 5); checkbox = gtk_check_button_new_with_mnemonic( _("_Print status message if files have been automatically saved")); gtk_button_set_focus_on_click(GTK_BUTTON(checkbox), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), autosave_print_msg); gtk_label_set_mnemonic_widget(GTK_LABEL(label), checkbox); gtk_box_pack_start(GTK_BOX(inner_vbox), checkbox, FALSE, FALSE, 5); pref_widgets.autosave_print_msg_checkbox = checkbox; radio1 = gtk_radio_button_new_with_mnemonic(NULL, _("Save only current open _file")); pref_widgets.autosave_save_all_radio1 = radio1; gtk_label_set_mnemonic_widget(GTK_LABEL(label), radio1); gtk_button_set_focus_on_click(GTK_BUTTON(radio1), FALSE); gtk_container_add(GTK_CONTAINER(inner_vbox), radio1); radio2 = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON(radio1), _("Sa_ve all open files")); pref_widgets.autosave_save_all_radio2 = radio2; gtk_label_set_mnemonic_widget(GTK_LABEL(label), radio2); gtk_button_set_focus_on_click(GTK_BUTTON(radio2), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio2), autosave_save_all); gtk_container_add(GTK_CONTAINER(inner_vbox), radio2); } /* * Instant Save */ { GtkWidget *combo; guint i; const GSList *node; notebook_vbox = gtk_vbox_new(FALSE, 2); inner_vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(inner_vbox), 5); gtk_box_pack_start(GTK_BOX(notebook_vbox), inner_vbox, TRUE, TRUE, 5); gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), notebook_vbox, gtk_label_new(_("Instant Save")), NOTEBOOK_PAGE_INSTANTSAVE); checkbox_enable = gtk_check_button_new_with_mnemonic(_("_Enable")); pref_widgets.checkbox_enable_instantsave = checkbox_enable; gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_enable), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_enable), enable_instantsave); gtk_box_pack_start(GTK_BOX(inner_vbox), checkbox_enable, FALSE, FALSE, 6); g_signal_connect(checkbox_enable, "toggled", G_CALLBACK(checkbox_toggled_cb), GINT_TO_POINTER(NOTEBOOK_PAGE_INSTANTSAVE)); label = gtk_label_new_with_mnemonic(_("_Filetype to use for newly opened files:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_box_pack_start(GTK_BOX(inner_vbox), label, FALSE, FALSE, 0); pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_new_text(); i = 0; foreach_slist(node, filetypes_get_sorted_by_name()) { GeanyFiletype *ft = node->data; gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ft->name); if (utils_str_equal(ft->name, instantsave_default_ft)) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i); i++; } gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 3); gtk_label_set_mnemonic_widget(GTK_LABEL(label), combo); gtk_box_pack_start(GTK_BOX(inner_vbox), combo, FALSE, FALSE, 0); }
void gui_create_search_sidebar(void) { GtkWidget *vbox1; GtkWidget *vbox90; GtkWidget *vbox5; GtkWidget *frame2; GtkWidget *vbox2; GtkWidget *frame3; GtkWidget *vbox3; GtkWidget *frame4; GtkWidget *vbox4; GtkWidget *table1; GtkWidget *label1; GtkWidget *label2; GtkWidget *scrolledwindow_search; GtkWidget *viewport_search; gchar *header; //GtkListStore *store; //ss = &sss; scrolledwindow_search = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow_search); gtk_container_add(GTK_CONTAINER(widgets.notebook_sidebar), scrolledwindow_search); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow_search), settings.shadow_type); gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow_search), 2); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_search), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); viewport_search = gtk_viewport_new(NULL, NULL); gtk_widget_show(viewport_search); gtk_container_add(GTK_CONTAINER(scrolledwindow_search), viewport_search); UI_VBOX(vbox1, FALSE, 4); gtk_widget_show(vbox1); gtk_container_add(GTK_CONTAINER(viewport_search), vbox1); UI_VBOX(vbox5, FALSE, 0); gtk_widget_show(vbox5); gtk_box_pack_start(GTK_BOX(vbox1), vbox5, FALSE, TRUE, 0); /* text entry */ ss.entrySearch = gtk_entry_new(); gtk_widget_show(ss.entrySearch); gtk_box_pack_start(GTK_BOX(vbox5), ss.entrySearch, TRUE, TRUE, 0); gtk_widget_set_size_request(ss.entrySearch, 130, -1); ; /* find button */ #ifdef HAVE_GTK_310 remember_search = gtk_button_new_from_icon_name("edit-find-symbolic", GTK_ICON_SIZE_BUTTON); #else remember_search = gtk_button_new_from_stock(GTK_STOCK_FIND); #endif gtk_widget_show(remember_search); gtk_box_pack_start(GTK_BOX(vbox5), remember_search, TRUE, FALSE, 0); gtk_widget_set_tooltip_text(remember_search, _("This is an inclusive (\"AND\") search:\nFind matches showing all words.")); gtk_button_set_relief(GTK_BUTTON(remember_search), GTK_RELIEF_HALF); /* progress bar */ ss.progressbar_search = gtk_progress_bar_new(); gtk_widget_show(ss.progressbar_search); gtk_box_pack_start(GTK_BOX(vbox5), ss.progressbar_search, FALSE, TRUE, 0); /* button to open advanced search */ ss.advanced_search = gtk_button_new_with_mnemonic(_("_Open Advanced Search")); gtk_widget_show(ss.advanced_search); gtk_box_pack_start(GTK_BOX(vbox5), ss.advanced_search, TRUE, FALSE, 0); gtk_widget_set_tooltip_text(ss.advanced_search, _("Open the separate Advanced Search dialog.")); gtk_button_set_relief(GTK_BUTTON(ss.advanced_search), GTK_RELIEF_HALF); ss.frame_module = gtk_frame_new(NULL); gtk_widget_show(ss.frame_module); gtk_box_pack_start(GTK_BOX(vbox1), ss.frame_module, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(ss.frame_module), 2); gtk_frame_set_shadow_type(GTK_FRAME(ss.frame_module), GTK_SHADOW_NONE); label1 = gtk_label_new(NULL); header = g_strdup_printf("<span weight=\"bold\">%s</span>", _("Search Module")); gtk_label_set_markup(GTK_LABEL(label1), header); g_free(header); gtk_widget_show(label1); gtk_frame_set_label_widget(GTK_FRAME(ss.frame_module), label1); UI_VBOX(vbox90, FALSE, 0); gtk_widget_show(vbox90); gtk_container_add(GTK_CONTAINER(ss.frame_module), vbox90); gtk_container_set_border_width(GTK_CONTAINER(vbox90), 4); ss.radiobutton_search_text = gtk_radio_button_new_with_label(NULL, _("Bible")); gtk_widget_show(ss.radiobutton_search_text); gtk_widget_set_size_request(ss.radiobutton_search_text, -1, 20); gtk_box_pack_start(GTK_BOX(vbox90), ss.radiobutton_search_text, FALSE, FALSE, 0); ss.radiobutton_search_comm = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ss.radiobutton_search_text), _("Commentary")); gtk_widget_show(ss.radiobutton_search_comm); gtk_widget_set_size_request(ss.radiobutton_search_comm, -1, 20); gtk_box_pack_start(GTK_BOX(vbox90), ss.radiobutton_search_comm, FALSE, FALSE, 0); frame2 = gtk_frame_new(NULL); gtk_widget_show(frame2); gtk_box_pack_start(GTK_BOX(vbox1), frame2, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame2), 2); gtk_frame_set_shadow_type(GTK_FRAME(frame2), GTK_SHADOW_NONE); label1 = gtk_label_new(NULL); header = g_strdup_printf("<span weight=\"bold\">%s</span>", _("Search Type")); gtk_label_set_markup(GTK_LABEL(label1), header); g_free(header); gtk_widget_show(label1); gtk_frame_set_label_widget(GTK_FRAME(frame2), label1); UI_VBOX(vbox2, TRUE, 0); gtk_widget_show(vbox2); gtk_container_add(GTK_CONTAINER(frame2), vbox2); gtk_container_set_border_width(GTK_CONTAINER(vbox2), 4); ss.rbMultiword = gtk_radio_button_new_with_label(NULL, _("Optimized (\"Lucene\")")); gtk_widget_show(ss.rbMultiword); gtk_box_pack_start(GTK_BOX(vbox2), ss.rbMultiword, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.rbMultiword, -1, 20); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ss.rbMultiword), TRUE); ss.rbRegExp = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ss.rbMultiword), _("Regular expression")); gtk_widget_show(ss.rbRegExp); gtk_box_pack_start(GTK_BOX(vbox2), ss.rbRegExp, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.rbRegExp, -1, 20); ss.rbPhraseSearch = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ss.rbMultiword), _("Exact phrase")); gtk_widget_show(ss.rbPhraseSearch); gtk_box_pack_start(GTK_BOX(vbox2), ss.rbPhraseSearch, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.rbPhraseSearch, -1, 20); frame3 = gtk_frame_new(NULL); gtk_widget_show(frame3); gtk_box_pack_start(GTK_BOX(vbox1), frame3, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame3), 2); gtk_frame_set_shadow_type(GTK_FRAME(frame3), GTK_SHADOW_NONE); label1 = gtk_label_new(NULL); header = g_strdup_printf("<span weight=\"bold\">%s</span>", _("Search Options")); gtk_label_set_markup(GTK_LABEL(label1), header); g_free(header); gtk_widget_show(label1); gtk_frame_set_label_widget(GTK_FRAME(frame3), label1); UI_VBOX(vbox3, FALSE, 0); gtk_widget_show(vbox3); gtk_container_add(GTK_CONTAINER(frame3), vbox3); gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); ss.ckbCaseSensitive = gtk_check_button_new_with_label(_("Match case")); gtk_widget_show(ss.ckbCaseSensitive); gtk_box_pack_start(GTK_BOX(vbox3), ss.ckbCaseSensitive, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.ckbCaseSensitive, -1, 20); frame4 = gtk_frame_new(NULL); gtk_widget_show(frame4); gtk_box_pack_start(GTK_BOX(vbox1), frame4, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame4), 2); gtk_frame_set_shadow_type(GTK_FRAME(frame4), GTK_SHADOW_NONE); label1 = gtk_label_new(NULL); header = g_strdup_printf("<span weight=\"bold\">%s</span>", _("Search Scope")); gtk_label_set_markup(GTK_LABEL(label1), header); g_free(header); gtk_widget_show(label1); gtk_frame_set_label_widget(GTK_FRAME(frame4), label1); UI_VBOX(vbox4, TRUE, 0); gtk_widget_show(vbox4); gtk_container_add(GTK_CONTAINER(frame4), vbox4); gtk_container_set_border_width(GTK_CONTAINER(vbox4), 4); ss.rbNoScope = gtk_radio_button_new_with_label(NULL, _("No scope")); gtk_widget_show(ss.rbNoScope); gtk_box_pack_start(GTK_BOX(vbox4), ss.rbNoScope, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.rbNoScope, -1, 20); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ss.rbNoScope), TRUE); ss.rrbUseBounds = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ss.rbNoScope), _("Use bounds")); gtk_widget_show(ss.rrbUseBounds); gtk_box_pack_start(GTK_BOX(vbox4), ss.rrbUseBounds, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.rrbUseBounds, -1, 20); ss.rbLastSearch = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ss.rbNoScope), _("Last search")); gtk_widget_show(ss.rbLastSearch); gtk_box_pack_start(GTK_BOX(vbox4), ss.rbLastSearch, FALSE, FALSE, 0); gtk_widget_set_size_request(ss.rbLastSearch, -1, 20); ss.frame5 = gtk_frame_new(NULL); gtk_widget_show(ss.frame5); gtk_box_pack_start(GTK_BOX(vbox1), ss.frame5, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(ss.frame5), 2); gtk_widget_hide(ss.frame5); gtk_frame_set_shadow_type(GTK_FRAME(ss.frame5), GTK_SHADOW_NONE); label1 = gtk_label_new(NULL); header = g_strdup_printf("<span weight=\"bold\">%s</span>", _("Bounds")); gtk_label_set_markup(GTK_LABEL(label1), header); g_free(header); gtk_widget_show(label1); gtk_frame_set_label_widget(GTK_FRAME(ss.frame5), label1); #ifdef HAVE_GTK_34 table1 = gtk_grid_new(); gtk_widget_show(table1); gtk_container_add(GTK_CONTAINER(ss.frame5), table1); gtk_grid_set_row_spacing(GTK_GRID(table1), 3); gtk_grid_set_column_spacing(GTK_GRID(table1), 3); gtk_container_set_border_width(GTK_CONTAINER(table1), 8); label1 = gtk_label_new(_("Lower")); gtk_widget_show(label1); gtk_grid_attach(GTK_GRID(table1), label1, 0, 0, 1, 1); #ifndef HAVE_GTK_310 gtk_misc_set_alignment(GTK_MISC(label1), 1.0, 0.5); #endif ss.entryLower = gtk_combo_box_text_new_with_entry(); gtk_widget_show(ss.entryLower); gtk_grid_attach(GTK_GRID(table1), ss.entryLower, 1, 0, 1, 1); gtk_widget_set_size_request(ss.entryLower, 114, 22); label2 = gtk_label_new(_("Upper")); gtk_widget_show(label2); gtk_grid_attach(GTK_GRID(table1), label2, 0, 1, 1, 1); #ifndef HAVE_GTK_310 gtk_misc_set_alignment(GTK_MISC(label2), 1.0, 0.5); #endif ss.entryUpper = gtk_combo_box_text_new_with_entry(); gtk_widget_show(ss.entryUpper); gtk_grid_attach(GTK_GRID(table1), ss.entryUpper, 1, 1, 1, 1); gtk_widget_set_size_request(ss.entryUpper, 114, 22); #else table1 = gtk_table_new(2, 2, FALSE); gtk_widget_show(table1); gtk_container_add(GTK_CONTAINER(ss.frame5), table1); gtk_table_set_row_spacings(GTK_TABLE(table1), 3); gtk_table_set_col_spacings(GTK_TABLE(table1), 3); gtk_container_set_border_width(GTK_CONTAINER(table1), 8); label1 = gtk_label_new(_("Lower")); gtk_widget_show(label1); gtk_table_attach(GTK_TABLE(table1), label1, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label1), 1.0, 0.5); label2 = gtk_label_new(_("Upper")); gtk_widget_show(label2); gtk_table_attach(GTK_TABLE(table1), label2, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label2), 1.0, 0.5); #ifdef HAVE_GTK_224 ss.entryLower = gtk_combo_box_text_new_with_entry(); #else ss.entryLower = gtk_combo_box_entry_new_text(); #endif gtk_widget_show(ss.entryLower); gtk_table_attach(GTK_TABLE(table1), ss.entryLower, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_widget_set_size_request(ss.entryLower, 114, 22); #ifdef HAVE_GTK_224 ss.entryUpper = gtk_combo_box_text_new_with_entry(); #else ss.entryUpper = gtk_combo_box_entry_new_text(); #endif gtk_widget_show(ss.entryUpper); gtk_table_attach(GTK_TABLE(table1), ss.entryUpper, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_widget_set_size_request(ss.entryUpper, 114, 22); #endif g_signal_connect(G_OBJECT(ss.rrbUseBounds), "toggled", G_CALLBACK(on_rrbUseBounds_toggled), NULL); g_signal_connect(G_OBJECT(remember_search), "clicked", G_CALLBACK(on_search_button_clicked), NULL); g_signal_connect(G_OBJECT(ss.entrySearch), "activate", G_CALLBACK(on_search_button_clicked), NULL); g_signal_connect(G_OBJECT(ss.advanced_search), "clicked", G_CALLBACK(main_open_search_dialog), NULL); /* prep for toggle case sensitive availability per optimized */ g_signal_connect(ss.rbMultiword, "toggled", G_CALLBACK(sidebar_optimized_toggled), NULL); /* initialize it off */ gtk_widget_set_sensitive(ss.ckbCaseSensitive, FALSE); }
static void messageview_show_cb(GObject *obj, gpointer msgview, MsgInfo *msginfo, gboolean all_headers) { MessageView *messageview; HeaderView *headerview; GtkWidget *hbox; gchar *msg_path; GtkWidget *copy_btn; GdkPixbuf* pbuf; GtkWidget* image; GtkTooltips *tip; GList* wl; gint i; gboolean bfound = FALSE; gpointer gdata; #if DEBUG g_print("[DEBUG] test: %p: messageview_show (%p), all_headers: %d: %s\n", obj, msgview, all_headers, msginfo && msginfo->subject ? msginfo->subject : ""); #endif if (!msgview) { g_print("[DEBUG] msgview is NULL\n"); return; } messageview = (MessageView*)msgview; if (!messageview) { g_print("[DEBUG] messageview is NULL\n"); return; } headerview = messageview->headerview; if (!headerview) { g_print("[DEBUG] headerview is NULL\n"); return; } hbox = headerview->hbox; if (!hbox) { g_print("[DEBUG] hbox is NULL\n"); return; } wl = gtk_container_get_children(GTK_CONTAINER(hbox)); i = g_list_length(wl)-1; /* search recently added GtkImage */ while (i >= 0) { gdata = g_list_nth_data(wl, i); if (GTK_IS_BUTTON(gdata) && gdata != headerview->image) { /* remove from hbox */ g_print("[DEBUG] GTK_IS_BUTTON %p\n", gdata); #if DEBUG g_print("[DEBUG] remove button: %p\n", gicon); #endif gtk_container_remove(GTK_CONTAINER(hbox), GTK_WIDGET(gdata)); } i--; } msg_path = procmsg_get_message_file_path(msginfo); debug_print("[DEBUG] msg_path:%s\n", msg_path); if (bfound != TRUE){ copy_btn = gtk_button_new_from_stock(GTK_STOCK_FILE); gtk_box_pack_end(GTK_BOX(hbox), copy_btn, FALSE, FALSE, 0); pbuf = gdk_pixbuf_new_from_xpm_data((const char**)page_save); image = gtk_image_new_from_pixbuf(pbuf); gtk_button_set_image(GTK_BUTTON(copy_btn), image); gtk_button_set_label(GTK_BUTTON(copy_btn), ""); tip = gtk_tooltips_new(); gtk_tooltips_set_tip(tip, copy_btn, _("Copy this mail to clipboard."), NULL); g_signal_connect(G_OBJECT(copy_btn), "clicked", G_CALLBACK(copy_btn_clicked), msginfo); gtk_widget_show(image); gtk_widget_show_all(copy_btn); debug_print("[DEBUG] copy mail to clipboard icon: %p\n", copy_btn); } }
static void abi_table_init (AbiTable* table) { UT_UTF8String prText = "%d x %d "; char* text = g_strdup_printf(prText.utf8_str(), init_rows, init_cols); register_stock_icon(); table->button_box = gtk_vbox_new(FALSE, 0); table->window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); table->window_vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0)); table->area = GTK_DRAWING_AREA(gtk_drawing_area_new()); table->handlers = 0; table->window_label = GTK_LABEL(gtk_label_new(text)); g_free(text); table->szTable = NULL; table->szCancel = NULL; gtk_container_add(GTK_CONTAINER(table->window), GTK_WIDGET(table->window_vbox)); gtk_box_pack_end(GTK_BOX(table->window_vbox), GTK_WIDGET(table->window_label), FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(table->window_vbox), GTK_WIDGET(table->area), TRUE, TRUE, 0); gtk_widget_show_all(GTK_WIDGET(table->window_vbox)); table->selected_rows = init_rows; table->selected_cols = init_cols; table->total_rows = my_max(init_rows + 1, 5); table->total_cols = my_max(init_cols + 1, 6); abi_table_resize(table); table->icon = NULL; if (gtk_stock_lookup ("abi-table-widget", &table->stock_item)) { table->label = gtk_label_new_with_mnemonic(table->stock_item.label); table->icon = gtk_image_new_from_stock ("abi-table-widget", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_show(table->icon); gtk_widget_show(table->label); // // We actually never want this label in toolbar // gtk_box_pack_end(GTK_BOX(table->button_box), table->label, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(table->button_box), table->icon, FALSE, FALSE, 0); UT_DEBUGMSG(("abi-table icon loaded %p !\n",table->icon)); } else { /* it should not happen... */ UT_DEBUGMSG(("abi-table icon did not load !\n")); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); table->label = gtk_label_new_with_mnemonic("_Table"); // gtk_box_pack_end(GTK_BOX(table->button_box), table->label, FALSE, FALSE, 0); } gtk_container_add(GTK_CONTAINER(table), GTK_WIDGET(table->button_box)); g_signal_connect(G_OBJECT(table), "pressed", G_CALLBACK(on_pressed), static_cast<gpointer>(table)); g_signal_connect(G_OBJECT(table->area), "expose_event", G_CALLBACK(on_drawing_area_event), static_cast<gpointer>(table)); g_signal_connect(G_OBJECT(table->area), "motion_notify_event", G_CALLBACK(on_motion_notify_event), static_cast<gpointer>(table)); g_signal_connect(G_OBJECT(table->area), "button_release_event", G_CALLBACK(on_button_release_event), static_cast<gpointer>(table)); g_signal_connect(G_OBJECT(table->area), "button_press_event", G_CALLBACK(on_button_release_event), static_cast<gpointer>(table)); g_signal_connect(G_OBJECT(table->area), "leave_notify_event", G_CALLBACK(on_leave_event), static_cast<gpointer>(table)); g_signal_connect(G_OBJECT(table->window), "key_press_event", G_CALLBACK(on_key_event), static_cast<gpointer>(table)); gtk_widget_set_events (GTK_WIDGET(table->area), GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); gtk_button_set_relief (GTK_BUTTON (table), GTK_RELIEF_NORMAL); }
IRC_Client_GUI_MessageHandler::IRC_Client_GUI_MessageHandler (Common_UI_GTKState* GTKState_in, IRC_Client_GUI_Connection* connection_in, RPG_Net_Protocol_IIRCControl* controller_in, const std::string& id_in, const std::string& UIFileDirectory_in, GtkNotebook* parent_in) : CBData_ () , displayQueue_ () , lock_ () , eventSourceID_ (0) , isFirstMemberListMsg_ (true) , parent_ (parent_in) , view_ (NULL) { RPG_TRACE (ACE_TEXT ("IRC_Client_GUI_MessageHandler::IRC_Client_GUI_MessageHandler")); // sanity check(s) ACE_ASSERT (GTKState_in); ACE_ASSERT(connection_in); ACE_ASSERT(controller_in); ACE_ASSERT (!id_in.empty ()); if (!Common_File_Tools::isDirectory (UIFileDirectory_in)) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("invalid argument (was: \"%s\"): not a directory, returning\n"), ACE_TEXT (UIFileDirectory_in.c_str ()))); return; } // end IF ACE_ASSERT (parent_in); // initialize cb data CBData_.GTKState = GTKState_in; CBData_.connection = connection_in; CBData_.id = id_in; CBData_.controller = controller_in; CBData_.channelModes = 0; // create new GtkBuilder GtkBuilder* builder_p = gtk_builder_new (); if (!builder_p) { ACE_DEBUG ((LM_CRITICAL, ACE_TEXT ("failed to allocate memory: \"%m\", returning\n"))); return; } // end IF std::string ui_definition_filename = UIFileDirectory_in; ui_definition_filename += ACE_DIRECTORY_SEPARATOR_CHAR_A; ui_definition_filename += IRC_CLIENT_GUI_DEF_UI_CHANNEL_TAB_FILE; if (!Common_File_Tools::isReadable (ui_definition_filename)) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("invalid UI file (was: \"%s\"): not readable, returning\n"), ACE_TEXT (ui_definition_filename.c_str ()))); // clean up g_object_unref (G_OBJECT (builder_p)); return; } // end IF // load widget tree GError* error = NULL; gtk_builder_add_from_file (builder_p, ui_definition_filename.c_str (), &error); if (error) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("failed to gtk_builder_add_from_file(\"%s\"): \"%s\", aborting\n"), ACE_TEXT (ui_definition_filename.c_str ()), ACE_TEXT (error->message))); // clean up g_error_free (error); g_object_unref (G_OBJECT (builder_p)); return; } // end IF // setup auto-scrolling in textview view_ = GTK_TEXT_VIEW (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_textview"))); ACE_ASSERT (view_); GtkTextIter iter; gtk_text_buffer_get_end_iter (gtk_text_view_get_buffer (view_), &iter); gtk_text_buffer_create_mark (gtk_text_view_get_buffer (view_), ACE_TEXT_ALWAYS_CHAR ("scroll"), &iter, TRUE); // enable multi-selection in treeview GtkTreeView* tree_view_p = GTK_TREE_VIEW (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_treeview"))); ACE_ASSERT (tree_view_p); GtkTreeSelection* tree_selection_p = gtk_tree_view_get_selection (tree_view_p); ACE_ASSERT (tree_selection_p); gtk_tree_selection_set_mode (tree_selection_p, GTK_SELECTION_MULTIPLE); // add the invite_channel_members_menu to the "Invite" menu item GtkMenu* menu_p = GTK_MENU (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("invite_channel_members_menu"))); ACE_ASSERT (menu_p); GtkMenuItem* menu_item_p = GTK_MENU_ITEM (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("menuitem_invite"))); ACE_ASSERT (menu_item_p); gtk_menu_item_set_submenu (menu_item_p, GTK_WIDGET (menu_p)); // connect signal(s) GtkButton* button_p = GTK_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_label_button"))); ACE_ASSERT (button_p); g_signal_connect (button_p, ACE_TEXT_ALWAYS_CHAR ("clicked"), G_CALLBACK (part_clicked_cb), &CBData_); // toggle buttons GtkToggleButton* toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_key_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_voice_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_ban_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_userlimit_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_moderated_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_blockforeign_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_restricttopic_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_inviteonly_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_secret_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_private_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); toggle_button_p = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("mode_operator_toggle_button_p"))); ACE_ASSERT (toggle_button_p); g_signal_connect (toggle_button_p, ACE_TEXT_ALWAYS_CHAR ("toggled"), G_CALLBACK (channel_mode_toggled_cb), &CBData_); // topic label GtkEventBox* event_box_p = GTK_EVENT_BOX (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_topic_label_eventbox"))); ACE_ASSERT (event_box_p); g_signal_connect (event_box_p, ACE_TEXT_ALWAYS_CHAR ("button-press-event"), G_CALLBACK (topic_clicked_cb), &CBData_); // context menu in treeview g_signal_connect (tree_view_p, ACE_TEXT_ALWAYS_CHAR ("button-press-event"), G_CALLBACK (members_clicked_cb), &CBData_); // actions in treeview GtkAction* action_p = GTK_ACTION (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("action_msg"))); ACE_ASSERT (action_p); g_signal_connect (action_p, ACE_TEXT_ALWAYS_CHAR ("activate"), G_CALLBACK (action_msg_cb), &CBData_); action_p = GTK_ACTION (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("action_invite"))); ACE_ASSERT (action_p); g_signal_connect (action_p, ACE_TEXT_ALWAYS_CHAR ("activate"), G_CALLBACK (action_invite_cb), &CBData_); action_p = GTK_ACTION (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("action_info"))); ACE_ASSERT (action_p); g_signal_connect (action_p, ACE_TEXT_ALWAYS_CHAR ("activate"), G_CALLBACK (action_info_cb), &CBData_); action_p = GTK_ACTION (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("action_kick"))); ACE_ASSERT (action_p); g_signal_connect (action_p, ACE_TEXT_ALWAYS_CHAR ("activate"), G_CALLBACK (action_kick_cb), &CBData_); action_p = GTK_ACTION (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("action_ban"))); ACE_ASSERT (action_p); g_signal_connect (action_p, ACE_TEXT_ALWAYS_CHAR ("activate"), G_CALLBACK (action_ban_cb), &CBData_); // add new channel page to notebook (== server log) // retrieve (dummy) parent window GtkWindow* window_p = GTK_WINDOW (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_label_template"))); ACE_ASSERT (window_p); // retrieve channel tab label GtkHBox* hbox_p = GTK_HBOX (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_label_hbox"))); ACE_ASSERT (hbox_p); g_object_ref (hbox_p); gtk_container_remove (GTK_CONTAINER (window_p), GTK_WIDGET (hbox_p)); // set tab label GtkLabel* label_p = GTK_LABEL (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_label"))); ACE_ASSERT (label_p); std::string page_tab_label_string; if (!RPG_Net_Protocol_Tools::isValidIRCChannelName (CBData_.id)) { // --> private conversation window, modify label accordingly page_tab_label_string = ACE_TEXT_ALWAYS_CHAR ("["); page_tab_label_string += CBData_.id; page_tab_label_string += ACE_TEXT_ALWAYS_CHAR("]"); // hide channel mode tab frame GtkFrame* frame_p = GTK_FRAME (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_mode_frame"))); ACE_ASSERT (frame_p); gtk_widget_hide (GTK_WIDGET (frame_p)); // hide channel tab treeview tree_view_p = GTK_TREE_VIEW (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_treeview"))); ACE_ASSERT (tree_view_p); gtk_widget_hide (GTK_WIDGET (tree_view_p)); // erase "topic" label label_p = GTK_LABEL (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_topic_label"))); ACE_ASSERT (label_p); gtk_label_set_text (label_p, NULL); } // end IF else page_tab_label_string = CBData_.id; gtk_label_set_text (label_p, page_tab_label_string.c_str ()); // retrieve (dummy) parent window window_p = GTK_WINDOW (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_template"))); ACE_ASSERT (window_p); // retrieve channel tab GtkVBox* vbox_p = GTK_VBOX (gtk_builder_get_object (builder_p, ACE_TEXT_ALWAYS_CHAR ("channel_tab_vbox"))); ACE_ASSERT (vbox_p); g_object_ref (vbox_p); gtk_container_remove (GTK_CONTAINER (window_p), GTK_WIDGET (vbox_p)); gint page_num = gtk_notebook_append_page (parent_, GTK_WIDGET (vbox_p), GTK_WIDGET (hbox_p)); if (page_num == -1) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("failed to gtk_notebook_append_page(%@), returning\n"), parent_)); // clean up g_object_unref (hbox_p); g_object_unref (vbox_p); g_object_unref (G_OBJECT (builder_p)); return; } // end IF g_object_unref (hbox_p); // allow reordering gtk_notebook_set_tab_reorderable (parent_, GTK_WIDGET (vbox_p), TRUE); g_object_unref (vbox_p); // activate new page (iff it's a channel tab !) if (RPG_Net_Protocol_Tools::isValidIRCChannelName (CBData_.id)) gtk_notebook_set_current_page (parent_, page_num); builderLabel_ = connection_in->getLabel (); builderLabel_ += ACE_TEXT_ALWAYS_CHAR ("::"); builderLabel_ += page_tab_label_string; // synch access { ACE_Guard<ACE_Thread_Mutex> aGuard (CBData_.GTKState->lock); CBData_.GTKState->builders[builderLabel_] = std::make_pair (ui_definition_filename, builder_p); } // end lock scope }
static void brasero_project_type_chooser_build_recent (BraseroProjectTypeChooser *self, GtkRecentManager *recent) { GtkSizeGroup *image_group; GtkSizeGroup *group; GList *list = NULL; gchar *filename; GList *recents; GList *iter; recents = gtk_recent_manager_get_items (recent); for (iter = recents; iter; iter = iter->next) { GtkRecentInfo *info; const gchar *mime; info = iter->data; mime = gtk_recent_info_get_mime_type (info); if (!mime) continue; /* filter those we want */ if (strcmp (mime, "application/x-brasero") && strcmp (mime, "application/x-cd-image") && strcmp (mime, "application/x-cdrdao-toc") && strcmp (mime, "application/x-toc") && strcmp (mime, "application/x-cue") && strcmp (mime, "audio/x-scpls") && strcmp (mime, "audio/x-ms-asx") && strcmp (mime, "audio/x-mp3-playlist") && strcmp (mime, "audio/x-mpegurl")) continue; /* sort */ list = g_list_insert_sorted (list, info, brasero_project_type_chooser_sort_recent); if (g_list_length (list) > 5) list = g_list_delete_link (list, g_list_last (list)); } group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); image_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); /* If a project was left unfinished last time then add another entry */ filename = g_build_filename (g_get_user_config_dir (), "brasero", BRASERO_SESSION_TMP_PROJECT_PATH, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { gchar *uri; GtkWidget *link; GtkWidget *image; uri = g_filename_to_uri (filename, NULL, NULL); image = gtk_image_new_from_icon_name ("brasero", GTK_ICON_SIZE_BUTTON); gtk_size_group_add_widget (image_group, image); link = gtk_button_new_with_label (_("Last _Unsaved Project")); g_object_set_data_full (G_OBJECT (link), "BraseroButtonURI", uri, g_free); gtk_button_set_relief (GTK_BUTTON (link), GTK_RELIEF_NONE); gtk_button_set_alignment (GTK_BUTTON (link), 0.0, 0.5); gtk_button_set_focus_on_click (GTK_BUTTON (link), FALSE); gtk_button_set_image (GTK_BUTTON (link), image); gtk_button_set_use_underline (GTK_BUTTON (link), TRUE); g_signal_connect (link, "clicked", G_CALLBACK (brasero_project_type_chooser_last_unsaved_clicked_cb), self); gtk_widget_show (link); gtk_widget_set_tooltip_text (link, _("Load the last project that was not burned and not saved")); gtk_box_pack_start (GTK_BOX (self->priv->recent_box), link, FALSE, TRUE, 0); gtk_size_group_add_widget (group, link); } g_free (filename); for (iter = list; iter; iter = iter->next) { GtkRecentInfo *info; GList *child_iter; const gchar *name; GIcon *icon; GtkWidget *image; const gchar *uri; GtkWidget *child; GtkWidget *link; GList *children; gchar *tooltip; info = iter->data; tooltip = gtk_recent_info_get_uri_display (info); icon = gtk_recent_info_get_gicon (info); image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON); g_object_unref (icon); gtk_size_group_add_widget (image_group, image); gtk_widget_show (image); gtk_widget_set_tooltip_text (image, tooltip); name = gtk_recent_info_get_display_name (info); uri = gtk_recent_info_get_uri (info); /* Don't use mnemonics with filenames */ link = gtk_button_new_with_label (name); g_object_set_data_full (G_OBJECT (link), "BraseroButtonURI", g_strdup (uri), g_free); gtk_button_set_relief (GTK_BUTTON (link), GTK_RELIEF_NONE); gtk_button_set_image (GTK_BUTTON (link), image); gtk_button_set_alignment (GTK_BUTTON (link), 0.0, 0.5); gtk_button_set_focus_on_click (GTK_BUTTON (link), FALSE); g_signal_connect (link, "clicked", G_CALLBACK (brasero_project_type_chooser_recent_clicked_cb), self); gtk_widget_show (link); gtk_widget_set_tooltip_text (link, tooltip); gtk_box_pack_start (GTK_BOX (self->priv->recent_box), link, FALSE, TRUE, 0); g_free (tooltip); gtk_size_group_add_widget (group, link); /* That's a tedious hack to avoid mnemonics which are hardcoded * when you add an image to a button. BUG? */ if (!GTK_IS_BIN (link)) continue; child = gtk_bin_get_child (GTK_BIN (link)); if (!GTK_IS_ALIGNMENT (child)) continue; gtk_alignment_set (GTK_ALIGNMENT (child), 0.0, 0.5, 1.0, 1.0); child = gtk_bin_get_child (GTK_BIN (child)); if (!GTK_IS_BOX (child)) continue; children = gtk_container_get_children (GTK_CONTAINER (child)); for (child_iter = children; child_iter; child_iter = child_iter->next) { GtkWidget *widget; widget = child_iter->data; if (GTK_IS_LABEL (widget)) { gtk_label_set_use_underline (GTK_LABEL (widget), FALSE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); /* Make sure that the name is not too long */ gtk_box_set_child_packing (GTK_BOX (child), widget, TRUE, TRUE, 0, GTK_PACK_START); gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END); break; } } g_list_free (children); } g_object_unref (image_group); g_object_unref (group); if (!g_list_length (list)) { GtkWidget *label; gchar *string; string = g_strdup_printf ("<i>%s</i>", _("No recently used project")); label = gtk_label_new (string); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); g_free (string); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (self->priv->recent_box), label, FALSE, FALSE, 0); } g_list_free (list); g_list_foreach (recents, (GFunc) gtk_recent_info_unref, NULL); g_list_free (recents); }
void program_init(void) { GtkWidget *widget; StashGroup *group = stash_group_new("program"); extern gboolean thread_select_on_running; extern gboolean thread_select_on_stopped; extern gboolean thread_select_on_exited; extern gboolean thread_select_follow; program_dialog = dialog_connect("program_dialog"); program_page_vbox = get_widget("program_page_vbox"); program_exec_entry = GTK_ENTRY(get_widget("program_executable_entry")); gtk_entry_set_max_length(program_exec_entry, PATH_MAX); stash_group_add_entry(group, &program_executable, "executable", "", program_exec_entry); ui_setup_open_button_callback(get_widget("program_executable_button"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, program_exec_entry); stash_group_add_entry(group, &program_arguments, "arguments", "", get_widget("program_arguments_entry")); widget = get_widget("program_environment"); environment = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); stash_group_add_string(group, &program_environment, "environment", ""); working_dir_entry = GTK_ENTRY(get_widget("program_working_dir_entry")); gtk_entry_set_max_length(working_dir_entry, PATH_MAX); stash_group_add_entry(group, &program_working_dir, "working_dir", "", working_dir_entry); ui_setup_open_button_callback(get_widget("program_working_dir_button"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, working_dir_entry); load_script_entry = GTK_ENTRY(get_widget("program_load_script_entry")); gtk_entry_set_max_length(load_script_entry, PATH_MAX); stash_group_add_entry(group, &program_load_script, "load_script", "", load_script_entry); ui_setup_open_button_callback(get_widget("program_load_script_button"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, load_script_entry); auto_run_exit = get_widget("program_auto_run_exit"); stash_group_add_toggle_button(group, &program_auto_run_exit, "auto_run_exit", TRUE, auto_run_exit); stash_group_add_toggle_button(group, &program_non_stop_mode, "non_stop_mode", FALSE, get_widget("program_non_stop_mode")); temp_breakpoint = get_widget("program_temp_breakpoint"); stash_group_add_toggle_button(group, &program_temp_breakpoint, "temp_breakpoint", FALSE, temp_breakpoint); widget = get_widget("program_temp_break_location"); gtk_entry_set_max_length(GTK_ENTRY(widget), PATH_MAX + 0xFF); stash_group_add_entry(group, &program_temp_break_location, "temp_break_location", "", widget); program_group = group; delete_all_items = GTK_TOGGLE_BUTTON(get_widget("program_delete_all_items")); g_signal_connect(program_exec_entry, "changed", G_CALLBACK(on_program_name_entry_changed), NULL); g_signal_connect(load_script_entry, "changed", G_CALLBACK(on_program_name_entry_changed), NULL); g_signal_connect(temp_breakpoint, "toggled", G_CALLBACK(on_temp_breakpoint_toggled), widget); import_button = get_widget("program_import"); g_signal_connect(import_button, "clicked", G_CALLBACK(on_program_import_button_clicked), NULL); widget = get_widget("program_ok"); g_signal_connect(widget, "clicked", G_CALLBACK(on_program_ok_button_clicked), NULL); gtk_widget_grab_default(widget); group = stash_group_new("options"); stash_group_add_toggle_button(group, &option_open_panel_on_load, "open_panel_on_load", TRUE, get_widget("option_open_panel_on_load")); stash_group_add_toggle_button(group, &option_open_panel_on_start, "open_panel_on_start", TRUE, get_widget("option_open_panel_on_start")); stash_group_add_toggle_button(group, &option_update_all_views, "update_all_views", FALSE, get_widget("option_update_all_views")); stash_group_add_radio_buttons(group, &option_high_bit_mode, "high_bit_mode", HB_7BIT, get_widget("option_high_bit_mode_7bit"), HB_7BIT, get_widget("option_high_bit_mode_locale"), HB_LOCALE, get_widget("option_high_bit_mode_utf8"), HB_UTF8, NULL); stash_group_add_toggle_button(group, &option_member_names, "member_names", TRUE, get_widget("option_member_names")); stash_group_add_toggle_button(group, &option_argument_names, "argument_names", TRUE, get_widget("option_argument_names")); long_mr_format = GTK_BUTTON(get_widget("option_mr_long_mr_format")); stash_group_add_boolean(group, &option_long_mr_format, "long_mr_format", TRUE); LONG_MR_FORMAT[FALSE] = _("as _Name=value"); LONG_MR_FORMAT[TRUE] = _("as _Name = value"); g_signal_connect(long_mr_format, "clicked", G_CALLBACK(on_long_mr_format_clicked), NULL); stash_group_add_toggle_button(group, &option_inspect_expand, "inspect_expand", TRUE, get_widget("option_inspect_expand")); stash_group_add_spin_button_integer(group, &option_inspect_count, "inspect_count", 100, get_widget("option_inspect_count")); stash_group_add_toggle_button(group, &option_library_messages, "library_messages", FALSE, get_widget("option_library_messages")); stash_group_add_toggle_button(group, &option_editor_tooltips, "editor_tooltips", TRUE, get_widget("option_editor_tooltips")); stash_group_add_boolean(group, &stack_show_address, "stack_show_address", TRUE); options_group = group; group = stash_group_new("terminal"); #ifdef G_OS_UNIX stash_group_add_boolean(group, &terminal_auto_show, "auto_show", FALSE); stash_group_add_boolean(group, &terminal_auto_hide, "auto_hide", FALSE); stash_group_add_boolean(group, &terminal_show_on_error, "show_on_error", FALSE); #endif terminal_group = group; group = stash_group_new("thread"); stash_group_add_boolean(group, &thread_select_on_running, "select_on_running", FALSE); stash_group_add_boolean(group, &thread_select_on_stopped, "select_on_stopped", TRUE); stash_group_add_boolean(group, &thread_select_on_exited, "select_on_exited", TRUE); stash_group_add_boolean(group, &thread_select_follow, "select_follow", TRUE); stash_group_add_boolean(group, &thread_show_group, "show_group", TRUE); stash_group_add_boolean(group, &thread_show_core, "show_core", TRUE); thread_group = group; recent_programs = SCP_TREE_STORE(get_object("recent_program_store")); recent_bitmap = 0; recent_menu = get_widget("program_recent_menu"); }
static void mcharmap_mini_font_selection_init (McharmapMiniFontSelection *fontsel) { GtkCellRenderer *renderer; GtkStyle *style; AtkObject *accessib; gtk_widget_ensure_style (GTK_WIDGET (fontsel)); style = gtk_widget_get_style (GTK_WIDGET (fontsel)); fontsel->font_desc = pango_font_description_copy (style->font_desc); fontsel->default_size = -1; fontsel->size_adj = gtk_adjustment_new (MIN_FONT_SIZE, MIN_FONT_SIZE, MAX_FONT_SIZE, 1, 8, 0); accessib = gtk_widget_get_accessible (GTK_WIDGET (fontsel)); atk_object_set_name (accessib, _("Font")); gtk_box_set_spacing (GTK_BOX (fontsel), 6); fontsel->family = gtk_combo_box_new (); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (fontsel->family), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (fontsel->family), renderer, "text", COL_FAMILIY, NULL); gtk_widget_show (fontsel->family); accessib = gtk_widget_get_accessible (fontsel->family); atk_object_set_name (accessib, _("Font Family")); fontsel->bold = gtk_toggle_button_new_with_mnemonic (GTK_STOCK_BOLD); gtk_button_set_use_stock (GTK_BUTTON (fontsel->bold), TRUE); gtk_widget_show (fontsel->bold); g_signal_connect (fontsel->bold, "toggled", G_CALLBACK (bold_toggled), fontsel); fontsel->italic = gtk_toggle_button_new_with_mnemonic (GTK_STOCK_ITALIC); gtk_button_set_use_stock (GTK_BUTTON (fontsel->italic), TRUE); gtk_widget_show (fontsel->italic); g_signal_connect (fontsel->italic, "toggled", G_CALLBACK (italic_toggled), fontsel); fontsel->size = gtk_spin_button_new (GTK_ADJUSTMENT (fontsel->size_adj), 0, 0); gtk_widget_show (fontsel->size); accessib = gtk_widget_get_accessible (fontsel->size); atk_object_set_name (accessib, _("Font Size")); g_signal_connect (fontsel->size_adj, "value-changed", G_CALLBACK (font_size_changed), fontsel); fill_font_families_combo (fontsel); gtk_combo_box_set_active (GTK_COMBO_BOX (fontsel->family), -1); g_signal_connect (fontsel->family, "changed", G_CALLBACK (family_combo_changed), fontsel); gtk_box_pack_start (GTK_BOX (fontsel), fontsel->family, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (fontsel), fontsel->bold, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (fontsel), fontsel->italic, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (fontsel), fontsel->size, FALSE, FALSE, 0); gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (fontsel->family), FALSE); gtk_button_set_focus_on_click (GTK_BUTTON (fontsel->bold), FALSE); gtk_button_set_focus_on_click (GTK_BUTTON (fontsel->italic), FALSE); gtk_container_set_border_width (GTK_CONTAINER (fontsel), 6); gtk_widget_show_all (GTK_WIDGET (fontsel)); }
static void nautilus_zoom_control_init (NautilusZoomControl *zoom_control) { GtkWidget *image; int i; zoom_control->details = G_TYPE_INSTANCE_GET_PRIVATE (zoom_control, NAUTILUS_TYPE_ZOOM_CONTROL, NautilusZoomControlDetails); zoom_control->details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD; zoom_control->details->min_zoom_level = NAUTILUS_ZOOM_LEVEL_SMALLEST; zoom_control->details->max_zoom_level = NAUTILUS_ZOOM_LEVEL_LARGEST; zoom_control->details->has_min_zoom_level = TRUE; zoom_control->details->has_max_zoom_level = TRUE; for (i = NAUTILUS_ZOOM_LEVEL_LARGEST; i >= NAUTILUS_ZOOM_LEVEL_SMALLEST; i--) { zoom_control->details->preferred_zoom_levels = g_list_prepend ( zoom_control->details->preferred_zoom_levels, GINT_TO_POINTER (i)); } image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU); zoom_control->details->zoom_out = gtk_button_new (); gtk_button_set_focus_on_click (GTK_BUTTON (zoom_control->details->zoom_out), FALSE); gtk_button_set_relief (GTK_BUTTON (zoom_control->details->zoom_out), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text (zoom_control->details->zoom_out, _("Decrease the view size")); g_signal_connect (G_OBJECT (zoom_control->details->zoom_out), "clicked", G_CALLBACK (zoom_out_clicked), zoom_control); gtk_container_add (GTK_CONTAINER (zoom_control->details->zoom_out), image); gtk_box_pack_start (GTK_BOX (zoom_control), zoom_control->details->zoom_out, FALSE, FALSE, 0); zoom_control->details->zoom_button = gtk_button_new (); gtk_button_set_focus_on_click (GTK_BUTTON (zoom_control->details->zoom_button), FALSE); gtk_button_set_relief (GTK_BUTTON (zoom_control->details->zoom_button), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text (zoom_control->details->zoom_button, _("Use the normal view size")); gtk_widget_add_events (GTK_WIDGET (zoom_control->details->zoom_button), GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); g_signal_connect (G_OBJECT (zoom_control->details->zoom_button), "button-press-event", G_CALLBACK (nautilus_zoom_control_button_press_event), zoom_control); g_signal_connect (G_OBJECT (zoom_control->details->zoom_button), "clicked", G_CALLBACK (zoom_button_clicked), zoom_control); g_signal_connect (G_OBJECT (zoom_control->details->zoom_button), "popup-menu", G_CALLBACK (zoom_popup_menu), zoom_control); zoom_control->details->zoom_label = gtk_label_new ("100%"); g_signal_connect (zoom_control->details->zoom_label, "style_set", G_CALLBACK (label_style_set_callback), zoom_control); set_label_size (zoom_control); gtk_container_add (GTK_CONTAINER (zoom_control->details->zoom_button), zoom_control->details->zoom_label); gtk_box_pack_start (GTK_BOX (zoom_control), zoom_control->details->zoom_button, TRUE, TRUE, 0); image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU); zoom_control->details->zoom_in = gtk_button_new (); gtk_button_set_focus_on_click (GTK_BUTTON (zoom_control->details->zoom_in), FALSE); gtk_button_set_relief (GTK_BUTTON (zoom_control->details->zoom_in), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text (zoom_control->details->zoom_in, _("Increase the view size")); g_signal_connect (G_OBJECT (zoom_control->details->zoom_in), "clicked", G_CALLBACK (zoom_in_clicked), zoom_control); gtk_container_add (GTK_CONTAINER (zoom_control->details->zoom_in), image); gtk_box_pack_start (GTK_BOX (zoom_control), zoom_control->details->zoom_in, FALSE, FALSE, 0); gtk_widget_show_all (zoom_control->details->zoom_out); gtk_widget_show_all (zoom_control->details->zoom_button); gtk_widget_show_all (zoom_control->details->zoom_in); }
static gboolean _togglebutton_draw(GtkWidget *widget, cairo_t *cr) { g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(DTGTK_IS_TOGGLEBUTTON(widget), FALSE); GtkDarktableToggleButton *button = DTGTK_TOGGLEBUTTON(widget); GtkStateFlags state = gtk_widget_get_state_flags(widget); GdkRGBA bg_color, fg_color; GtkStyleContext *context = gtk_widget_get_style_context(widget); if(button->icon_flags & CPF_CUSTOM_BG) bg_color = button->bg; else gtk_style_context_get_background_color(context, state, &bg_color); if(button->icon_flags & CPF_CUSTOM_FG) fg_color = button->fg; else gtk_style_context_get_color(context, state, &fg_color); /* fetch flags */ int flags = DTGTK_TOGGLEBUTTON(widget)->icon_flags; /* set inner border */ int border = DT_PIXEL_APPLY_DPI((flags & CPF_DO_NOT_USE_BORDER) ? 2 : 6); /* update active state paint flag */ gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if(active) flags |= CPF_ACTIVE; else flags &= ~(CPF_ACTIVE); /* prelight */ if(state & GTK_STATE_FLAG_PRELIGHT) flags |= CPF_PRELIGHT; else flags &= ~CPF_PRELIGHT; /* begin cairo drawing */ GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); int width = allocation.width; int height = allocation.height; /* draw standard button background if not transparent nor flat styled */ if((flags & CPF_STYLE_FLAT)) { if(flags & CPF_PRELIGHT || flags & CPF_ACTIVE) { cairo_rectangle(cr, 0, 0, width, height); gdk_cairo_set_source_rgba(cr, &bg_color); cairo_fill(cr); } } else if(!(flags & CPF_BG_TRANSPARENT)) { /* draw default boxed button */ gtk_render_background(context, cr, 0, 0, width, height); if(!(flags & CPF_DO_NOT_USE_BORDER)) gtk_render_frame(context, cr, 0, 0, width, height); } /* create pango text settings if label exists */ PangoLayout *layout = NULL; int pw = 0, ph = 0; const gchar *text = gtk_button_get_label(GTK_BUTTON(widget)); if(text) { layout = pango_cairo_create_layout(cr); pango_layout_set_font_description(layout, darktable.bauhaus->pango_font_desc); pango_cairo_context_set_resolution(pango_layout_get_context(layout), darktable.gui->dpi); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_size(layout, &pw, &ph); } gdk_cairo_set_source_rgba(cr, &fg_color); /* draw icon */ if(DTGTK_TOGGLEBUTTON(widget)->icon) { // if (flags & CPF_IGNORE_FG_STATE) // state = GTK_STATE_NORMAL; int icon_width = text ? height - (border * 2) : width - (border * 2); int icon_height = height - (border * 2); if(icon_width > 0 && icon_height > 0) { if(text) DTGTK_TOGGLEBUTTON(widget) ->icon(cr, border, border, height - (border * 2), height - (border * 2), flags); else DTGTK_TOGGLEBUTTON(widget) ->icon(cr, border, border, width - (border * 2), height - (border * 2), flags); } } /* draw label */ if(text) { int lx = DT_PIXEL_APPLY_DPI(2), ly = ((height / 2.0) - (ph / 2.0)); // if (DTGTK_TOGGLEBUTTON (widget)->icon) lx += width; // GdkRectangle t={x,y,x+width,y+height}; // gtk_paint_layout(style,gtk_widget_get_window(widget), // state,TRUE,&t,widget,"togglebutton",lx,ly,layout); cairo_translate(cr, lx, ly); pango_cairo_show_layout(cr, layout); g_object_unref(layout); } return FALSE; }
static void caja_file_conflict_dialog_init (CajaFileConflictDialog *fcd) { GtkWidget *hbox, *vbox, *vbox2; GtkWidget *widget, *dialog_area; CajaFileConflictDialogPrivate *details; GtkDialog *dialog; details = fcd->details = caja_file_conflict_dialog_get_instance_private (fcd); dialog = GTK_DIALOG (fcd); /* Setup the main hbox */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); dialog_area = gtk_dialog_get_content_area (dialog); gtk_box_pack_start (GTK_BOX (dialog_area), hbox, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); /* Setup the dialog image */ widget = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); gtk_widget_set_halign (widget, GTK_ALIGN_CENTER); gtk_widget_set_valign (widget, GTK_ALIGN_START); /* Setup the vbox containing the dialog body */ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); /* Setup the vbox for the dialog labels */ widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); details->titles_vbox = widget; /* Setup the hboxes to pack file infos into */ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_widget_set_halign (vbox2, GTK_ALIGN_START); gtk_widget_set_valign (vbox2, GTK_ALIGN_START); gtk_widget_set_margin_start (vbox2, 12); gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); details->first_hbox = hbox; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); details->second_hbox = hbox; /* Setup the expander for the rename action */ details->expander = gtk_expander_new_with_mnemonic (_("Select a new name for the _destination")); gtk_box_pack_start (GTK_BOX (vbox2), details->expander, FALSE, FALSE, 0); g_signal_connect (details->expander, "activate", G_CALLBACK (expander_activated_cb), dialog); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (details->expander), hbox); widget = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 6); details->entry = widget; g_signal_connect (widget, "changed", G_CALLBACK (entry_text_changed_cb), dialog); widget = gtk_button_new_with_label (_("Reset")); gtk_button_set_image (GTK_BUTTON (widget), gtk_image_new_from_icon_name ("edit-undo", GTK_ICON_SIZE_MENU)); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6); g_signal_connect (widget, "clicked", G_CALLBACK (reset_button_clicked_cb), dialog); gtk_widget_show_all (vbox2); /* Setup the diff button for text files */ details->diff_button = gtk_button_new_with_label (_("Differences...")); gtk_button_set_image (GTK_BUTTON (details->diff_button), gtk_image_new_from_icon_name ("edit-find", GTK_ICON_SIZE_MENU)); gtk_box_pack_start (GTK_BOX (vbox), details->diff_button, FALSE, FALSE, 6); g_signal_connect (details->diff_button, "clicked", G_CALLBACK (diff_button_clicked_cb), dialog); gtk_widget_hide (details->diff_button); /* Setup the checkbox to apply the action to all files */ widget = gtk_check_button_new_with_mnemonic (_("Apply this action to all files and folders")); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); details->checkbox = widget; g_signal_connect (widget, "toggled", G_CALLBACK (checkbox_toggled_cb), dialog); /* Add buttons */ eel_dialog_add_button (dialog, _("_Cancel"), "process-stop", GTK_RESPONSE_CANCEL); gtk_dialog_add_button (dialog, _("_Skip"), CONFLICT_RESPONSE_SKIP); details->rename_button = gtk_dialog_add_button (dialog, _("Re_name"), CONFLICT_RESPONSE_RENAME); gtk_widget_hide (details->rename_button); details->replace_button = gtk_dialog_add_button (dialog, _("Replace"), CONFLICT_RESPONSE_REPLACE); gtk_widget_grab_focus (details->replace_button); /* Setup HIG properties */ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (dialog)), 14); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_widget_show_all (dialog_area); }
static GtkWidget * create_window (int confirm_mode) { GtkWidget *w; GtkWidget *win, *box; GtkWidget *wvbox, *chbox, *bbox; GtkAccelGroup *acc; gchar *msg; tooltips = gtk_tooltips_new (); /* FIXME: check the grabbing code against the one we used with the old gpg-agent */ win = gtk_window_new (GTK_WINDOW_TOPLEVEL); acc = gtk_accel_group_new (); g_signal_connect (G_OBJECT (win), "delete_event", G_CALLBACK (delete_event), NULL); #if 0 g_signal_connect (G_OBJECT (win), "destroy", G_CALLBACK (gtk_main_quit), NULL); #endif g_signal_connect (G_OBJECT (win), "size-request", G_CALLBACK (constrain_size), NULL); if (!confirm_mode) { if (pinentry->grab) g_signal_connect (G_OBJECT (win), "realize", G_CALLBACK (make_transient), NULL); /* We need to grab the keyboard when its visible! not when its mapped (there is a difference) */ g_object_set (G_OBJECT(win), "events", GDK_VISIBILITY_NOTIFY_MASK | GDK_STRUCTURE_MASK, NULL); g_signal_connect (G_OBJECT (win), pinentry->grab ? "visibility-notify-event" : "focus-in-event", G_CALLBACK (grab_keyboard), NULL); g_signal_connect (G_OBJECT (win), pinentry->grab ? "unmap-event" : "focus-out-event", G_CALLBACK (ungrab_keyboard), NULL); } gtk_window_add_accel_group (GTK_WINDOW (win), acc); wvbox = gtk_vbox_new (FALSE, HIG_LARGE * 2); gtk_container_add (GTK_CONTAINER (win), wvbox); gtk_container_set_border_width (GTK_CONTAINER (wvbox), HIG_LARGE); chbox = gtk_hbox_new (FALSE, HIG_LARGE); gtk_box_pack_start (GTK_BOX (wvbox), chbox, FALSE, FALSE, 0); w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (chbox), w, FALSE, FALSE, 0); box = gtk_vbox_new (FALSE, HIG_SMALL); gtk_box_pack_start (GTK_BOX (chbox), box, TRUE, TRUE, 0); if (pinentry->title) { msg = pinentry_utf8_validate (pinentry->title); gtk_window_set_title (GTK_WINDOW(win), msg); } if (pinentry->description) { msg = pinentry_utf8_validate (pinentry->description); w = gtk_label_new (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_box_pack_start (GTK_BOX (box), w, TRUE, FALSE, 0); } if (pinentry->error && !confirm_mode) { GdkColor color = { 0, 0xffff, 0, 0 }; msg = pinentry_utf8_validate (pinentry->error); w = gtk_label_new (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_box_pack_start (GTK_BOX (box), w, TRUE, FALSE, 0); gtk_widget_modify_fg (w, GTK_STATE_NORMAL, &color); } qualitybar = NULL; if (!confirm_mode) { GtkWidget* table = gtk_table_new (pinentry->quality_bar ? 2 : 1, 2, FALSE); gtk_box_pack_start (GTK_BOX (box), table, FALSE, FALSE, 0); if (pinentry->prompt) { msg = pinentry_utf8_validate (pinentry->prompt); w = gtk_label_new_with_mnemonic (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), w, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 4, 0); } entry = gtk_secure_entry_new (); gtk_widget_set_size_request (entry, 200, -1); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), entry); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (changed_text_handler), entry); gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0); gtk_widget_grab_focus (entry); gtk_widget_show (entry); if (pinentry->quality_bar) { msg = pinentry_utf8_validate (pinentry->quality_bar); w = gtk_label_new (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), w, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 4, 0); qualitybar = gtk_progress_bar_new(); gtk_widget_add_events (qualitybar, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (qualitybar), QUALITYBAR_EMPTY_TEXT); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (qualitybar), 0.0); if (pinentry->quality_bar_tt) gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), qualitybar, pinentry->quality_bar_tt, ""); gtk_table_attach (GTK_TABLE (table), qualitybar, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0); } #ifdef ENABLE_ENHANCED if (pinentry->enhanced) { GtkWidget *sbox = gtk_hbox_new (FALSE, HIG_SMALL); gtk_box_pack_start (GTK_BOX (box), sbox, FALSE, FALSE, 0); w = gtk_label_new ("Forget secret after"); gtk_box_pack_start (GTK_BOX (sbox), w, FALSE, FALSE, 0); gtk_widget_show (w); time_out = gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, HUGE_VAL, 1, 60, 60)), 2, 0); gtk_box_pack_start (GTK_BOX (sbox), time_out, FALSE, FALSE, 0); gtk_widget_show (time_out); w = gtk_label_new ("seconds"); gtk_box_pack_start (GTK_BOX (sbox), w, FALSE, FALSE, 0); gtk_widget_show (w); gtk_widget_show (sbox); insure = gtk_check_button_new_with_label ("ask before giving out " "secret"); gtk_box_pack_start (GTK_BOX (box), insure, FALSE, FALSE, 0); gtk_widget_show (insure); } #endif } bbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); gtk_box_set_spacing (GTK_BOX (bbox), 6); gtk_box_pack_start (GTK_BOX (wvbox), bbox, TRUE, FALSE, 0); if (!pinentry->one_button) { if (pinentry->cancel) { msg = pinentry_utf8_validate (pinentry->cancel); w = gtk_button_new_with_mnemonic (msg); g_free (msg); } else if (pinentry->default_cancel) { GtkWidget *image; msg = pinentry_utf8_validate (pinentry->default_cancel); w = gtk_button_new_with_mnemonic (msg); g_free (msg); image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON); if (image) gtk_button_set_image (GTK_BUTTON (w), image); } else w = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_container_add (GTK_CONTAINER (bbox), w); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (confirm_mode ? confirm_button_clicked : button_clicked), (gpointer) CONFIRM_CANCEL); GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT); } if (confirm_mode && !pinentry->one_button && pinentry->notok) { msg = pinentry_utf8_validate (pinentry->notok); w = gtk_button_new_with_mnemonic (msg); g_free (msg); gtk_container_add (GTK_CONTAINER (bbox), w); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (confirm_button_clicked), (gpointer) CONFIRM_NOTOK); GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT); } if (pinentry->ok) { msg = pinentry_utf8_validate (pinentry->ok); w = gtk_button_new_with_mnemonic (msg); g_free (msg); } else if (pinentry->default_ok) { GtkWidget *image; msg = pinentry_utf8_validate (pinentry->default_ok); w = gtk_button_new_with_mnemonic (msg); g_free (msg); image = gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON); if (image) gtk_button_set_image (GTK_BUTTON (w), image); } else w = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_container_add (GTK_CONTAINER(bbox), w); if (!confirm_mode) { g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (button_clicked), "ok"); GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT); gtk_widget_grab_default (w); g_signal_connect_object (G_OBJECT (entry), "focus_in_event", G_CALLBACK (gtk_widget_grab_default), G_OBJECT (w), 0); } else { g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK(confirm_button_clicked), (gpointer) CONFIRM_OK); GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT); } gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER); gtk_window_set_keep_above (GTK_WINDOW (win), TRUE); gtk_widget_show_all (win); gtk_window_present (GTK_WINDOW (win)); /* Make sure it has the focus. */ return win; }