static gboolean confirm_delete_immediately (GtkWidget *parent_view, gint num_files, gboolean all) { GdkScreen *screen; GtkWidget *dialog, *hbox, *vbox, *image, *label; gchar *str, *prompt, *detail; int response; screen = gtk_widget_get_screen (parent_view); dialog = gtk_dialog_new (); gtk_window_set_screen (GTK_WINDOW (dialog), screen); atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT); gtk_window_set_title (GTK_WINDOW (dialog), _("Delete Immediately?")); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_widget_realize (dialog); gdk_window_set_transient_for (gtk_widget_get_window (GTK_WIDGET (dialog)), gdk_screen_get_root_window (screen)); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14); hbox = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, FALSE, 0); image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_widget_show (image); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); vbox = gtk_vbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); if (all) { prompt = _("Cannot move items to trash, do you want to delete them immediately?"); detail = g_strdup_printf ("None of the %d selected items can be moved to the Trash", num_files); } else { prompt = _("Cannot move some items to trash, do you want to delete these immediately?"); detail = g_strdup_printf ("%d of the selected items cannot be moved to the Trash", num_files); } str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", prompt, "</span>", NULL); label = gtk_label_new (str); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (str); label = gtk_label_new (detail); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (detail); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_DELETE, GTK_RESPONSE_YES); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog)); return response == GTK_RESPONSE_YES; }
void create_infowin (void) { GtkWidget * hbox; GtkWidget * hbox_status_and_bbox; GtkWidget * vbox0; GtkWidget * vbox2; GtkWidget * label_title; GtkWidget * label_artist; GtkWidget * label_album; GtkWidget * label_comment; GtkWidget * label_genre; GtkWidget * label_year; GtkWidget * label_track; GtkWidget * label_format; GtkWidget * label_quality_label; GtkWidget * label_bitrate_label; GtkWidget * codec_hbox; GtkWidget * codec_table; GtkWidget * table1; GtkWidget * bbox_close; GtkWidget * btn_close; GtkWidget * alignment; infowin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width ((GtkContainer *) infowin, 6); gtk_window_set_title ((GtkWindow *) infowin, _("Track Information")); gtk_window_set_type_hint ((GtkWindow *) infowin, GDK_WINDOW_TYPE_HINT_DIALOG); vbox0 = gtk_vbox_new (FALSE, 0); gtk_container_add ((GtkContainer *) infowin, vbox0); hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start ((GtkBox *) vbox0, hbox, TRUE, TRUE, 0); vbox2 = gtk_vbox_new (FALSE, 6); gtk_box_pack_start ((GtkBox *) hbox, vbox2, TRUE, TRUE, 0); image_artwork = gtk_image_new (); gtk_box_pack_start ((GtkBox *) vbox2, image_artwork, TRUE, TRUE, 0); location_text = gtk_label_new (""); gtk_widget_set_size_request (location_text, 200, -1); gtk_label_set_line_wrap ((GtkLabel *) location_text, TRUE); gtk_label_set_line_wrap_mode ((GtkLabel *) location_text, PANGO_WRAP_WORD_CHAR); gtk_label_set_selectable ((GtkLabel *) location_text, TRUE); gtk_box_pack_start ((GtkBox *) vbox2, location_text, FALSE, FALSE, 0); codec_hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start ((GtkBox *) vbox2, codec_hbox, FALSE, FALSE, 0); codec_table = gtk_table_new(3, 2, FALSE); gtk_table_set_row_spacings ((GtkTable *) codec_table, 3); gtk_table_set_col_spacings ((GtkTable *) codec_table, 12); gtk_box_pack_start ((GtkBox *) codec_hbox, codec_table, FALSE, FALSE, 0); label_format = gtk_label_new (_("<span size=\"small\">Format:</span>")); gtk_label_set_use_markup ((GtkLabel *) label_format, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_format, 0, 0.5); label_quality_label = gtk_label_new (_("<span size=\"small\">Quality:</span>")); gtk_label_set_use_markup ((GtkLabel *) label_quality_label, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_quality_label, 0, 0.5); label_bitrate_label = gtk_label_new (_("<span size=\"small\">Bitrate:</span>")); gtk_label_set_use_markup ((GtkLabel *) label_bitrate_label, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_bitrate_label, 0, 0.5); label_format_name = gtk_label_new (_("<span size=\"small\">n/a</span>")); gtk_label_set_use_markup ((GtkLabel *) label_format_name, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_format_name, 0, 0.5); label_quality = gtk_label_new (_("<span size=\"small\">n/a</span>")); gtk_label_set_use_markup ((GtkLabel *) label_quality, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_quality, 0, 0.5); label_bitrate = gtk_label_new (_("<span size=\"small\">n/a</span>")); gtk_label_set_use_markup ((GtkLabel *) label_bitrate, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_bitrate, 0, 0.5); gtk_table_attach ((GtkTable *) codec_table, label_format, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ((GtkTable *) codec_table, label_format_name, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ((GtkTable *) codec_table, label_quality_label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ((GtkTable *) codec_table, label_quality, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ((GtkTable *) codec_table, label_bitrate_label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ((GtkTable *) codec_table, label_bitrate, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); vbox2 = gtk_vbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *) hbox, vbox2, TRUE, TRUE, 0); label_title = gtk_label_new (_("<span size=\"small\">Title</span>")); gtk_box_pack_start ((GtkBox *) vbox2, label_title, FALSE, FALSE, 0); gtk_label_set_use_markup ((GtkLabel *) label_title, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_title, 0, 0); alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start ((GtkBox *) vbox2, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding ((GtkAlignment *) alignment, 0, 6, 0, 0); entry_title = gtk_entry_new (); gtk_container_add ((GtkContainer *) alignment, entry_title); g_signal_connect (entry_title, "changed", (GCallback) entry_changed, NULL); label_artist = gtk_label_new (_("<span size=\"small\">Artist</span>")); gtk_box_pack_start ((GtkBox *) vbox2, label_artist, FALSE, FALSE, 0); gtk_label_set_use_markup ((GtkLabel *) label_artist, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_artist, 0, 0.5); alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start ((GtkBox *) vbox2, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding ((GtkAlignment *) alignment, 0, 6, 0, 0); entry_artist = gtk_entry_new (); gtk_container_add ((GtkContainer *) alignment, entry_artist); g_signal_connect (entry_artist, "changed", (GCallback) entry_changed, NULL); label_album = gtk_label_new (_("<span size=\"small\">Album</span>")); gtk_box_pack_start ((GtkBox *) vbox2, label_album, FALSE, FALSE, 0); gtk_label_set_use_markup ((GtkLabel *) label_album, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_album, 0, 0.5); alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start ((GtkBox *) vbox2, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding ((GtkAlignment *) alignment, 0, 6, 0, 0); entry_album = gtk_entry_new (); gtk_container_add ((GtkContainer *) alignment, entry_album); g_signal_connect (entry_album, "changed", (GCallback) entry_changed, NULL); label_comment = gtk_label_new (_("<span size=\"small\">Comment</span>")); gtk_box_pack_start ((GtkBox *) vbox2, label_comment, FALSE, FALSE, 0); gtk_label_set_use_markup ((GtkLabel *) label_comment, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_comment, 0, 0.5); alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start ((GtkBox *) vbox2, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding ((GtkAlignment *) alignment, 0, 6, 0, 0); entry_comment = gtk_entry_new (); gtk_container_add ((GtkContainer *) alignment, entry_comment); g_signal_connect (entry_comment, "changed", (GCallback) entry_changed, NULL); label_genre = gtk_label_new (_("<span size=\"small\">Genre</span>")); gtk_box_pack_start ((GtkBox *) vbox2, label_genre, FALSE, FALSE, 0); gtk_label_set_use_markup ((GtkLabel *) label_genre, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_genre, 0, 0.5); alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start ((GtkBox *) vbox2, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding ((GtkAlignment *) alignment, 0, 6, 0, 0); entry_genre = gtk_combo_box_text_new_with_entry (); gtk_container_add ((GtkContainer *) alignment, entry_genre); g_signal_connect (entry_genre, "changed", (GCallback) entry_changed, NULL); g_idle_add ((GSourceFunc) genre_fill, entry_genre); alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_box_pack_start ((GtkBox *) vbox2, alignment, FALSE, FALSE, 0); gtk_alignment_set_padding ((GtkAlignment *) alignment, 0, 6, 0, 0); table1 = gtk_table_new (2, 2, FALSE); gtk_container_add ((GtkContainer *) alignment, table1); gtk_table_set_col_spacings ((GtkTable *) table1, 6); label_year = gtk_label_new (_("<span size=\"small\">Year</span>")); gtk_table_attach ((GtkTable *) table1, label_year, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); gtk_label_set_use_markup ((GtkLabel *) label_year, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_year, 0, 0.5); entry_year = gtk_entry_new (); gtk_table_attach ((GtkTable *) table1, entry_year, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect (entry_year, "changed", (GCallback) entry_changed, NULL); label_track = gtk_label_new (_("<span size=\"small\">Track Number</span>")); gtk_table_attach ((GtkTable *) table1, label_track, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); gtk_label_set_use_markup ((GtkLabel *) label_track, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_track, 0, 0.5); entry_track = gtk_entry_new (); gtk_table_attach ((GtkTable *) table1, entry_track, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect (entry_track, "changed", (GCallback) entry_changed, NULL); hbox_status_and_bbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *) vbox0, hbox_status_and_bbox, FALSE, FALSE, 0); label_mini_status = gtk_label_new ("<span size=\"small\"></span>"); gtk_label_set_use_markup ((GtkLabel *) label_mini_status, TRUE); gtk_misc_set_alignment ((GtkMisc *) label_mini_status, 0, 0.5); gtk_box_pack_start ((GtkBox *) hbox_status_and_bbox, label_mini_status, TRUE, TRUE, 0); bbox_close = gtk_hbutton_box_new (); gtk_box_set_spacing ((GtkBox *) bbox_close, 6); gtk_box_pack_start ((GtkBox *) hbox_status_and_bbox, bbox_close, FALSE, FALSE, 0); gtk_button_box_set_layout ((GtkButtonBox *) bbox_close, GTK_BUTTONBOX_END); btn_apply = gtk_button_new_from_stock (GTK_STOCK_SAVE); gtk_container_add ((GtkContainer *) bbox_close, btn_apply); g_signal_connect (btn_apply, "clicked", (GCallback) infowin_update_tuple, NULL); gtk_widget_set_sensitive (btn_apply, FALSE); btn_close = gtk_button_new_from_stock (GTK_STOCK_CLOSE); gtk_container_add ((GtkContainer *) bbox_close, btn_close); g_signal_connect_swapped (btn_close, "clicked", (GCallback) gtk_widget_hide, infowin); audgui_hide_on_delete (infowin); audgui_hide_on_escape (infowin); gtk_widget_show_all (vbox0); gtk_widget_grab_focus (entry_title); }
/* * display the interface selection dialog */ static void gtkui_unified_sniff(void) { GList *iface_list; const char *iface_desc = NULL; char err[100]; GtkWidget *iface_combo; pcap_if_t *dev; GtkWidget *dialog, *label, *hbox, *image; DEBUG_MSG("gtk_unified_sniff"); dialog = gtk_dialog_new_with_buttons(EC_PROGRAM" Input", GTK_WINDOW (window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_dialog_set_has_separator(GTK_DIALOG (dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER (dialog), 5); hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); label = gtk_label_new ("Network interface : "); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); /* make a list of network interfaces */ iface_list = NULL; for(dev = (pcap_if_t *)GBL_PCAP->ifs; dev != NULL; dev = dev->next) { iface_list = g_list_append(iface_list, dev->description); } /* make a drop down box and assign the list to it */ iface_combo = gtk_combo_new(); gtk_combo_set_popdown_strings (GTK_COMBO (iface_combo), iface_list); gtk_box_pack_start (GTK_BOX (hbox), iface_combo, FALSE, FALSE, 0); /* hitting Enter in the drop down box clicks OK */ g_object_set_data(G_OBJECT (GTK_COMBO (iface_combo)->entry), "dialog", dialog); g_signal_connect(G_OBJECT (GTK_COMBO (iface_combo)->entry), "activate", G_CALLBACK (gtkui_dialog_enter), NULL); /* list is stored in the widget, can safely free this copy */ g_list_free(iface_list); /* render the contents of the dialog */ gtk_widget_show_all (hbox); /* show the dialog itself and become interactive */ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { iface_desc = gtk_entry_get_text(GTK_ENTRY (GTK_COMBO (iface_combo)->entry)); for(dev = (pcap_if_t *)GBL_PCAP->ifs; dev != NULL; dev = dev->next) { if(!strncmp(dev->description, iface_desc, IFACE_LEN)) { SAFE_FREE(GBL_OPTIONS->iface); SAFE_CALLOC(GBL_OPTIONS->iface, IFACE_LEN, sizeof(char)); strncpy(GBL_OPTIONS->iface, dev->name, IFACE_LEN); break; } } /* if no match in list */ if(GBL_OPTIONS->iface == NULL) { snprintf(err, 100, "Invalid interface: %s", iface_desc); gtkui_error(err); gtk_widget_destroy(dialog); return; } /* exit setup iterface */ gtk_widget_destroy(dialog); gtk_main_quit(); return; } gtk_widget_destroy(dialog); }
/* Make the insides of an about box. */ static void about_build( iDialog *idlg, GtkWidget *work ) { /* Translators: translate this to a credit for you, and it'll appear in * the About box. */ char *translator_credits = _( "translator_credits" ); GtkWidget *hb; GtkWidget *lab; char txt[MAX_DIALOG_TEXT]; char txt2[MAX_DIALOG_TEXT]; VipsBuf buf = VIPS_BUF_STATIC( txt ); GtkWidget *image; im_snprintf( txt2, MAX_DIALOG_TEXT, _( "About %s." ), PACKAGE ); vips_buf_appendf( &buf, "<b><big>%s</big></b>\n\n", txt2 ); im_snprintf( txt2, MAX_DIALOG_TEXT, _( "%s is an image processing package." ), PACKAGE ); vips_buf_appendf( &buf, "%s\n\n", txt2 ); im_snprintf( txt2, MAX_DIALOG_TEXT, _( "%s comes with ABSOLUTELY NO WARRANTY. This is " "free software and you are welcome to redistribute " "it under certain conditions, see http://www.gnu.org." ), PACKAGE ); vips_buf_appendf( &buf, "%s\n\n", txt2 ); im_snprintf( txt2, MAX_DIALOG_TEXT, _( NIP_COPYRIGHT ), PACKAGE ); vips_buf_appendf( &buf, "%s\n\n", txt2 ); { char buf1[FILENAME_MAX]; char buf2[FILENAME_MAX]; im_snprintf( buf1, FILENAME_MAX, "%s" G_DIR_SEPARATOR_S "start", get_savedir() ); expand_variables( buf1, buf2 ); nativeize_path( buf2 ); escape_markup( buf2, buf1, FILENAME_MAX ); vips_buf_appendf( &buf, "<b>%s:</b> %s\n", _( "Personal start folder" ), buf1 ); } vips_buf_appendf( &buf, "<b>%s:</b> %s\n", _( "Homepage" ), VIPS_HOMEPAGE ); escape_markup( im_version_string(), txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>%s:</b> %s\n", _( "Linked to VIPS" ), txt2 ); escape_markup( IM_VERSION_STRING, txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>%s:</b> %s\n", _( "Built against VIPS" ), txt2 ); escape_markup( PACKAGE, txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>$PACKAGE:</b> %s\n", txt2 ); escape_markup( VERSION, txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>$VERSION:</b> %s\n", txt2 ); escape_markup( NN( g_getenv( "VIPSHOME" ) ), txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>$VIPSHOME:</b> %s\n", txt2 ); escape_markup( NN( g_getenv( "HOME" ) ), txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>$HOME:</b> %s\n", txt2 ); escape_markup( NN( g_getenv( "SAVEDIR" ) ), txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>$SAVEDIR:</b> %s\n", txt2 ); escape_markup( PATH_TMP, txt2, MAX_DIALOG_TEXT ); vips_buf_appendf( &buf, "<b>%s:</b> %s\n", _( "Temp files in" ), txt2 ); if( strcmp( translator_credits, "translator_credits" ) != 0 ) { vips_buf_appendf( &buf, "\n" ); vips_buf_appends( &buf, translator_credits ); } vips_buf_appendf( &buf, "\n" ); mainw_find_disc( &buf ); /* Expands to (eg.) "14GB free in /pics/tmp" */ vips_buf_appendf( &buf, _( " in \"%s\"" ), PATH_TMP ); vips_buf_appends( &buf, "\n" ); vips_buf_appendf( &buf, _( "%d cells in heap, %d cells free, %d cells maximum" ), reduce_context->heap->ncells, reduce_context->heap->nfree, reduce_context->heap->max_fn( reduce_context->heap ) ); vips_buf_appends( &buf, "\n" ); vips_buf_appendf( &buf, _( "%d vips calls cached by nip2" ), cache_history_size ); vips_buf_appends( &buf, "\n" ); vips_buf_appendf( &buf, _( "%d vips operations cached by libvips" ), vips_cache_get_size() ); vips_buf_appends( &buf, "\n" ); vips_buf_appendf( &buf, _( "using %d threads" ), im_concurrency_get() ); vips_buf_appends( &buf, "\n" ); vips_buf_appendf( &buf, _( "%d pixel buffers in vips" ), vips_tracked_get_allocs() ); vips_buf_appends( &buf, "\n" ); vips_buf_append_size( &buf, vips_tracked_get_mem() ); vips_buf_appendf( &buf, _( " of ram in pixel buffers" ) ); vips_buf_appends( &buf, "\n" ); vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() ); vips_buf_appendf( &buf, _( " of ram highwater mark" ) ); vips_buf_appends( &buf, "\n" ); hb = gtk_hbox_new( FALSE, 0 ); gtk_container_border_width( GTK_CONTAINER( hb ), 10 ); gtk_container_add( GTK_CONTAINER( work ), hb ); gtk_widget_show( hb ); image = image_new_from_file( "$VIPSHOME/share/$PACKAGE/data/vips-128.png" ); gtk_box_pack_start( GTK_BOX( hb ), image, FALSE, FALSE, 2 ); gtk_widget_show( image ); lab = gtk_label_new( "" ); gtk_label_set_markup( GTK_LABEL( lab ), vips_buf_all( &buf ) ); gtk_label_set_justify( GTK_LABEL( lab ), GTK_JUSTIFY_LEFT ); gtk_label_set_selectable( GTK_LABEL( lab ), TRUE ); gtk_label_set_line_wrap( GTK_LABEL( lab ), TRUE ); gtk_box_pack_start( GTK_BOX( hb ), lab, FALSE, FALSE, 2 ); gtk_widget_show( lab ); }
int main(int argc, char *argv[]) { gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_window_set_title(GTK_WINDOW(window), "Label Demo"); GtkWidget *hbox = gtk_hbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_widget_show(hbox); GtkWidget *vbox = gtk_vbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); gtk_widget_show(vbox); GtkWidget *frame; GtkWidget *label; frame = gtk_frame_new("Normal Label"); label = gtk_label_new("This is a normal label."); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new("Multi-line Label"); label = gtk_label_new("This is a Multi-line \n label."); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new("Left Justed Label"); label = gtk_label_new("Left?.\nThis is the second line."); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new("Right Justed Label"); label = gtk_label_new("Right?.\nThis is the second line."); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new("Line wrapped label"); label = gtk_label_new("This is an example of a line-warpped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit."); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new("Filled, wrapped label"); label = gtk_label_new("This is an example of a line-warpped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit."); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_FILL); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); frame = gtk_frame_new("Filled, wrapped label"); label = gtk_label_new("This is an example of a line-warpped \nlabel. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit."); gtk_label_set_pattern(GTK_LABEL(label), "_ _ "); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); gtk_widget_show_all(window); gtk_main(); return 0; }
static void populate_spread_table_wrappy (EggSpreadTable *spread_table) { GList *children, *l; GtkWidget *widget, *frame; gsize i; const gchar *strings[] = { "These are", "some wrappy label", "texts", "of various", "lengths.", "They should always be", "shown", "consecutively. Except it's", "hard to say", "where exactly the", "label", "will wrap", "and where exactly", "the actual", "container", "will wrap.", "This label is really really really long !", "Let's add some more", "labels to the", "mix. Just to", "make sure we", "got something to work", "with here." }; /* Remove all children first */ children = gtk_container_get_children (GTK_CONTAINER (paper)); for (l = children; l; l = l->next) { GtkWidget *child = l->data; gtk_container_remove (GTK_CONTAINER (paper), child); } g_list_free (children); for (i = 0; i < G_N_ELEMENTS (strings); i++) { widget = gtk_label_new (strings[i]); frame = gtk_frame_new (NULL); gtk_widget_show (widget); gtk_widget_show (frame); gtk_container_add (GTK_CONTAINER (frame), widget); gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (widget), PANGO_WRAP_WORD); gtk_label_set_width_chars (GTK_LABEL (widget), 10); gtk_widget_set_halign (frame, child_halign); egg_spread_table_insert_child (EGG_SPREAD_TABLE (spread_table), frame, -1); } /* Insert an image into the mix */ if (test_image) { widget = gtk_image_new_from_file ("apple-red.png"); switch (test_image) { case IMAGE_SMALL: gtk_widget_set_size_request (widget, 100, 100); break; case IMAGE_LARGE: gtk_widget_set_size_request (widget, 150, 200); break; case IMAGE_HUGE: gtk_widget_set_size_request (widget, 200, 300); break; default: break; } frame = gtk_frame_new (NULL); gtk_widget_show (widget); gtk_widget_show (frame); gtk_container_add (GTK_CONTAINER (frame), widget); egg_spread_table_insert_child (EGG_SPREAD_TABLE (spread_table), frame, test_image_index); } }
static void * search_get_widget (void) { GtkWidget * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); entry = gtk_entry_new (); gtk_entry_set_icon_from_icon_name ((GtkEntry *) entry, GTK_ENTRY_ICON_PRIMARY, "edit-find"); gtk_entry_set_placeholder_text ((GtkEntry *) entry, _("Search library")); g_signal_connect (entry, "destroy", (GCallback) gtk_widget_destroyed, & entry); gtk_box_pack_start ((GtkBox *) vbox, entry, FALSE, FALSE, 0); help_label = gtk_label_new (_("To import your music library into " "Audacious, choose a folder and then click the \"refresh\" icon.")); gtk_widget_set_size_request (help_label, 194, -1); gtk_label_set_line_wrap ((GtkLabel *) help_label, TRUE); g_signal_connect (help_label, "destroy", (GCallback) gtk_widget_destroyed, & help_label); gtk_widget_set_no_show_all (help_label, TRUE); gtk_box_pack_start ((GtkBox *) vbox, help_label, TRUE, FALSE, 0); wait_label = gtk_label_new (_("Please wait ...")); g_signal_connect (wait_label, "destroy", (GCallback) gtk_widget_destroyed, & wait_label); gtk_widget_set_no_show_all (wait_label, TRUE); gtk_box_pack_start ((GtkBox *) vbox, wait_label, TRUE, FALSE, 0); scrolled = gtk_scrolled_window_new (NULL, NULL); g_signal_connect (scrolled, "destroy", (GCallback) gtk_widget_destroyed, & scrolled); gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) scrolled, GTK_SHADOW_IN); gtk_scrolled_window_set_policy ((GtkScrolledWindow *) scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_set_no_show_all (scrolled, TRUE); gtk_box_pack_start ((GtkBox *) vbox, scrolled, TRUE, TRUE, 0); results_list = audgui_list_new (& list_callbacks, NULL, items ? index_count (items) : 0); g_signal_connect (results_list, "destroy", (GCallback) gtk_widget_destroyed, & results_list); gtk_tree_view_set_headers_visible ((GtkTreeView *) results_list, FALSE); audgui_list_add_column (results_list, NULL, 0, G_TYPE_STRING, -1); gtk_container_add ((GtkContainer *) scrolled, results_list); GtkWidget * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_end ((GtkBox *) vbox, hbox, FALSE, FALSE, 0); GtkWidget * chooser = gtk_file_chooser_button_new (_("Choose Folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_box_pack_start ((GtkBox *) hbox, chooser, TRUE, TRUE, 0); char * path = get_path (); gtk_file_chooser_set_filename ((GtkFileChooser *) chooser, path); str_unref (path); GtkWidget * button = gtk_button_new (); gtk_container_add ((GtkContainer *) button, gtk_image_new_from_icon_name ("view-refresh", GTK_ICON_SIZE_BUTTON)); gtk_button_set_relief ((GtkButton *) button, GTK_RELIEF_NONE); gtk_box_pack_start ((GtkBox *) hbox, button, FALSE, FALSE, 0); g_signal_connect (entry, "changed", (GCallback) entry_cb, NULL); g_signal_connect (entry, "activate", (GCallback) action_play, NULL); g_signal_connect (button, "clicked", (GCallback) refresh_cb, chooser); gtk_widget_show_all (vbox); gtk_widget_show (results_list); show_hide_widgets (); return vbox; }
static GtkWidget * display_simple_dialog(gint type, gint btn_mask, char *message) { GtkWidget *win, *main_vb, *top_hb, *msg_vb, *type_pm, *msg_label, *ask_cb, *bbox, *ok_bt, *yes_bt, *bt, *save_bt, *dont_save_bt; /* Main window */ switch (type) { case ESD_TYPE_WARN : type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); break; case ESD_TYPE_CONFIRMATION: type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); break; case ESD_TYPE_ERROR: type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); break; case ESD_TYPE_STOP : type_pm = gtk_image_new_from_stock( GTK_STOCK_STOP, GTK_ICON_SIZE_DIALOG); break; case ESD_TYPE_INFO : default : type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); break; } /* * The GNOME HIG: * * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows * * says that the title should be empty for alert boxes, so there's "less * visual noise and confounding text." * * The Windows HIG: * * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch09f.asp * * says it should * * ...appropriately identify the source of the message -- usually * the name of the object. For example, if the message results * from editing a document, the title text is the name of the * document, optionally followed by the application name. If the * message results from a non-document object, then use the * application name." * * and notes that the title is important "because message boxes might * not always the the result of current user interaction" (e.g., some * app might randomly pop something up, e.g. some browser letting you * know that it couldn't fetch something because of a timeout). * * It also says not to use "warning" or "caution", as there's already * an icon that tells you what type of alert it is, and that you * shouldn't say "error", as that provides no useful information. * * So we give it a title on Win32, and don't give it one on UN*X. * For now, we give it a Win32 title of just "Wireshark"; we should * arguably take an argument for the title. */ if(btn_mask == ESD_BTN_NONE) { win = splash_window_new(); } else { #ifdef _WIN32 win = dlg_window_new("Wireshark"); #else win = dlg_window_new(""); #endif } gtk_window_set_modal(GTK_WINDOW(win), TRUE); gtk_container_set_border_width(GTK_CONTAINER(win), 6); /* Container for our rows */ main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE); gtk_container_add(GTK_CONTAINER(win), main_vb); gtk_widget_show(main_vb); /* Top row: Icon and message text */ top_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12, FALSE); gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6); gtk_box_pack_start(GTK_BOX(main_vb), top_hb, TRUE, TRUE, 0); gtk_widget_show(top_hb); gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f); gtk_box_pack_start(GTK_BOX(top_hb), type_pm, TRUE, TRUE, 0); gtk_widget_show(type_pm); /* column for message and optional check button */ msg_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); gtk_box_set_spacing(GTK_BOX(msg_vb), 24); gtk_box_pack_start(GTK_BOX(top_hb), msg_vb, TRUE, TRUE, 0); gtk_widget_show(msg_vb); /* message */ msg_label = gtk_label_new(message); gtk_label_set_markup(GTK_LABEL(msg_label), message); gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE); g_object_set(gtk_widget_get_settings(msg_label), "gtk-label-select-on-focus", FALSE, NULL); gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL); gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f); gtk_box_pack_start(GTK_BOX(msg_vb), msg_label, TRUE, TRUE, 0); gtk_label_set_line_wrap(GTK_LABEL(msg_label), TRUE); gtk_widget_show(msg_label); if(btn_mask == ESD_BTN_NONE) { gtk_widget_show(win); return win; } /* optional check button */ ask_cb = gtk_check_button_new_with_label("replace with text..."); gtk_box_pack_start(GTK_BOX(msg_vb), ask_cb, TRUE, TRUE, 0); g_object_set_data(G_OBJECT(win), CHECK_BUTTON, ask_cb); /* Button row */ switch(btn_mask) { case(ESD_BTN_OK): bbox = dlg_button_row_new(GTK_STOCK_OK, NULL); break; case(ESD_BTN_OK | ESD_BTN_CANCEL): bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL); break; case(ESD_BTN_CLEAR | ESD_BTN_CANCEL): bbox = dlg_button_row_new(GTK_STOCK_CLEAR, GTK_STOCK_CANCEL, NULL); break; case(ESD_BTNS_YES_NO_CANCEL): bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL, NULL); break; case(ESD_BTNS_SAVE_DONTSAVE): bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_DONT_SAVE, NULL); break; case(ESD_BTNS_SAVE_DONTSAVE_CANCEL): bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_DONT_SAVE, GTK_STOCK_CANCEL, NULL); break; case(ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL): bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_QUIT_DONT_SAVE, GTK_STOCK_CANCEL, NULL); break; case (ESD_BTNS_QUIT_DONTSAVE_CANCEL): bbox = dlg_button_row_new(WIRESHARK_STOCK_QUIT_DONT_SAVE, GTK_STOCK_CANCEL, NULL); break; case(ESD_BTNS_YES_NO): bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, NULL); break; default: g_assert_not_reached(); bbox = NULL; break; } gtk_box_pack_start(GTK_BOX(main_vb), bbox, TRUE, TRUE, 0); gtk_widget_show(bbox); ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK); if(ok_bt) { g_object_set_data(G_OBJECT(ok_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_OK)); g_signal_connect(ok_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } save_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE); if (save_bt) { g_object_set_data(G_OBJECT(save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_SAVE)); g_signal_connect(save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } dont_save_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_DONT_SAVE); if (dont_save_bt) { g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_DONT_SAVE)); g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } dont_save_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_QUIT_DONT_SAVE); if (dont_save_bt) { g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_QUIT_DONT_SAVE)); g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR); if(bt) { g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR)); g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } yes_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_YES); if(yes_bt) { g_object_set_data(G_OBJECT(yes_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_YES)); g_signal_connect(yes_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_NO); if(bt) { g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_NO)); g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win); } bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL); if(bt) { g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CANCEL)); window_set_cancel_button(win, bt, simple_dialog_cancel_cb); } if(!bt) { if(yes_bt) { window_set_cancel_button(win, yes_bt, simple_dialog_cancel_cb); } else { window_set_cancel_button(win, ok_bt, simple_dialog_cancel_cb); } } dlg_button_focus_nth(bbox, 0); gtk_widget_show(win); return win; }
void updater_app_ui_init(UpdaterAppState *app_state) { GtkWidget *vbox; GtkWidget *summary_label; GtkWidget *description_label; GtkWidget *frame; llassert(app_state != NULL); // set up window and main container std::string window_title = LLTrans::getString("UpdaterWindowTitle"); app_state->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(app_state->window), window_title.c_str()); gtk_window_set_resizable(GTK_WINDOW(app_state->window), FALSE); gtk_window_set_position(GTK_WINDOW(app_state->window), GTK_WIN_POS_CENTER_ALWAYS); gtk_container_set_border_width(GTK_CONTAINER(app_state->window), 12); g_signal_connect(G_OBJECT(app_state->window), "delete-event", G_CALLBACK(on_window_closed), app_state); vbox = gtk_vbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(app_state->window), vbox); // set top label std::ostringstream label_ostr; label_ostr << "<big><b>" << LLTrans::getString("UpdaterNowUpdating") << "</b></big>"; summary_label = gtk_label_new(NULL); gtk_label_set_use_markup(GTK_LABEL(summary_label), TRUE); gtk_label_set_markup(GTK_LABEL(summary_label), label_ostr.str().c_str()); gtk_misc_set_alignment(GTK_MISC(summary_label), 0, 0.5); gtk_box_pack_start(GTK_BOX(vbox), summary_label, FALSE, FALSE, 0); // create the description label description_label = gtk_label_new(LLTrans::getString("UpdaterUpdatingDescriptive").c_str()); gtk_label_set_line_wrap(GTK_LABEL(description_label), TRUE); gtk_misc_set_alignment(GTK_MISC(description_label), 0, 0.5); gtk_box_pack_start(GTK_BOX(vbox), description_label, FALSE, FALSE, 0); // If an image path has been set, load the background images if (!app_state->image_dir.empty()) { frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); // load the first image app_state->image = gtk_image_new_from_file (next_image_filename(app_state->image_dir, *app_state->image_dir_iter).c_str()); gtk_widget_set_size_request(app_state->image, 340, 310); gtk_container_add(GTK_CONTAINER(frame), app_state->image); // rotate the images every 5 seconds app_state->image_rotation_timeout_id = g_timeout_add (ROTATE_IMAGE_TIMEOUT, rotate_image_cb, app_state); } // set up progress bar, and update it roughly every 1/10 of a second app_state->progress_bar = gtk_progress_bar_new(); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(app_state->progress_bar), LLTrans::getString("UpdaterProgressBarTextWithEllipses").c_str()); gtk_box_pack_start(GTK_BOX(vbox), app_state->progress_bar, FALSE, TRUE, 0); app_state->progress_update_timeout_id = g_timeout_add (UPDATE_PROGRESS_TIMEOUT, progress_update_timeout, app_state); app_state->update_progress_text_timeout_id = g_timeout_add (UPDATE_PROGRESS_TEXT_TIMEOUT, update_progress_text_timeout, app_state); gtk_widget_show_all(app_state->window); }
static void ring_welcome_view_init(RingWelcomeView *self) { RingWelcomeViewPrivate *priv = RING_WELCOME_VIEW_GET_PRIVATE(self); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); auto box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 15); gtk_container_add(GTK_CONTAINER(self), box); gtk_box_set_baseline_position(GTK_BOX(box), GTK_BASELINE_POSITION_CENTER); gtk_widget_set_vexpand(GTK_WIDGET(box), TRUE); gtk_widget_set_hexpand(GTK_WIDGET(box), FALSE); gtk_widget_set_valign(GTK_WIDGET(box), GTK_ALIGN_CENTER); gtk_widget_set_halign(GTK_WIDGET(box), GTK_ALIGN_CENTER); /* get logo */ GError *error = NULL; GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-logo-blue", 350, -1, TRUE, &error); if (logo == NULL) { g_debug("Could not load logo: %s", error->message); g_clear_error(&error); } else { auto image_ring_logo = gtk_image_new_from_pixbuf(logo); gtk_box_pack_start(GTK_BOX(box), image_ring_logo, FALSE, TRUE, 0); } /* welcome text */ auto label_welcome_text = gtk_label_new(_("Ring is a secure and distributed voice, video, and chat communication platform that requires no centralized server and leaves the power of privacy in the hands of the user.")); gtk_label_set_justify(GTK_LABEL(label_welcome_text), GTK_JUSTIFY_CENTER); gtk_widget_override_font(label_welcome_text, pango_font_description_from_string("12")); gtk_label_set_line_wrap(GTK_LABEL(label_welcome_text), TRUE); /* the max width chars is to limit how much the text expands */ gtk_label_set_max_width_chars(GTK_LABEL(label_welcome_text), 50); gtk_label_set_selectable(GTK_LABEL(label_welcome_text), TRUE); gtk_box_pack_start(GTK_BOX(box), label_welcome_text, FALSE, TRUE, 0); /* RingID explanation */ auto label_explanation = gtk_label_new(C_("Do not translate \"RingID\"", "This is your RingID.\nCopy and share it with your friends!")); auto context = gtk_widget_get_style_context(label_explanation); gtk_style_context_add_class(context, GTK_STYLE_CLASS_DIM_LABEL); gtk_label_set_justify(GTK_LABEL(label_explanation), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label_explanation), TRUE); gtk_widget_set_margin_top(label_explanation, 20); /* we migth need to hide the label if a RING account doesn't exist */ gtk_widget_set_no_show_all(label_explanation, TRUE); gtk_box_pack_start(GTK_BOX(box), label_explanation, FALSE, TRUE, 0); /* RingID label */ auto label_ringid = gtk_label_new(NULL); gtk_label_set_selectable(GTK_LABEL(label_ringid), TRUE); gtk_widget_override_font(label_ringid, pango_font_description_from_string("monospace 12")); show_ring_id(GTK_LABEL(label_ringid), get_active_ring_account()); gtk_widget_set_no_show_all(label_ringid, TRUE); gtk_box_pack_start(GTK_BOX(box), label_ringid, FALSE, TRUE, 0); gtk_label_set_ellipsize(GTK_LABEL(label_ringid), PANGO_ELLIPSIZE_END); if (get_active_ring_account()) { gtk_widget_show(label_explanation); gtk_widget_show(label_ringid); } priv-> ringaccount_updated = QObject::connect( &AccountModel::instance(), &AccountModel::dataChanged, [label_explanation, label_ringid] () { /* check if the active ring account has changed, * eg: if it was deleted */ auto account = get_active_ring_account(); show_ring_id(GTK_LABEL(label_ringid), get_active_ring_account()); if (account) { gtk_widget_show(label_explanation); gtk_widget_show(label_ringid); } else { gtk_widget_hide(label_explanation); gtk_widget_hide(label_ringid); } } ); gtk_widget_show_all(GTK_WIDGET(self)); }
LPSTR create_keyval (HWND hwnd, LPCSTR attrs, BOOL *verify_conn) { GtkWidget *gensetup, *dialog_vbox1, *fixed1; GtkWidget *l_comment, *scrolledwindow1, *clist1; GtkWidget *l_key, *l_value, *t_keyword, *t_value, *l_copyright; GtkWidget *vbuttonbox1, *b_add, *b_update, *l_keyword, *l_valeur; GtkWidget *dialog_action_area1, *hbuttonbox1, *b_ok, *b_cancel; GtkWidget *cb_verify; guint button_key; GtkAccelGroup *accel_group; TGENSETUP gensetup_t; char buff[1024]; if (hwnd == NULL || !GTK_IS_WIDGET (hwnd)) return (LPSTR) attrs; accel_group = gtk_accel_group_new (); gensetup = gtk_dialog_new (); gtk_object_set_data (GTK_OBJECT (gensetup), "gensetup", gensetup); gtk_window_set_title (GTK_WINDOW (gensetup), "Advanced File DSN Creation Settings"); gtk_window_set_position (GTK_WINDOW (gensetup), GTK_WIN_POS_CENTER); gtk_window_set_modal (GTK_WINDOW (gensetup), TRUE); gtk_window_set_policy (GTK_WINDOW (gensetup), FALSE, FALSE, FALSE); #if GTK_CHECK_VERSION(2,0,0) gtk_widget_show (gensetup); #endif dialog_vbox1 = GTK_DIALOG (gensetup)->vbox; gtk_object_set_data (GTK_OBJECT (gensetup), "dialog_vbox1", dialog_vbox1); gtk_widget_show (dialog_vbox1); fixed1 = gtk_fixed_new (); gtk_widget_ref (fixed1); gtk_object_set_data_full (GTK_OBJECT (gensetup), "fixed1", fixed1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (fixed1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), fixed1, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (fixed1), 6); l_comment = gtk_label_new ("If you know the driver-specific keywords for this data source, you can type them and their values here. For more information on driver-specific keywords, please consult your ODBC driver documentation."); gtk_widget_ref (l_comment); gtk_object_set_data_full (GTK_OBJECT (gensetup), "l_comment", l_comment, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_comment); gtk_fixed_put (GTK_FIXED (fixed1), l_comment, 8, 7); gtk_widget_set_uposition (l_comment, 8, 7); gtk_widget_set_usize (l_comment, 330, 70); gtk_label_set_justify (GTK_LABEL (l_comment), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (l_comment), TRUE); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_ref (scrolledwindow1); gtk_object_set_data_full (GTK_OBJECT (gensetup), "scrolledwindow1", scrolledwindow1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scrolledwindow1); gtk_fixed_put (GTK_FIXED (fixed1), scrolledwindow1, 8, 88); gtk_widget_set_uposition (scrolledwindow1, 8, 88); gtk_widget_set_usize (scrolledwindow1, 320, 184); clist1 = gtk_clist_new (2); gtk_widget_ref (clist1); gtk_object_set_data_full (GTK_OBJECT (gensetup), "clist1", clist1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (clist1); gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1); gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 137); gtk_clist_set_column_width (GTK_CLIST (clist1), 1, 80); gtk_clist_column_titles_show (GTK_CLIST (clist1)); l_key = gtk_label_new (szKeysColumnNames[0]); gtk_widget_ref (l_key); gtk_object_set_data_full (GTK_OBJECT (gensetup), "l_key", l_key, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_key); gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, l_key); l_value = gtk_label_new (szKeysColumnNames[1]); gtk_widget_ref (l_value); gtk_object_set_data_full (GTK_OBJECT (gensetup), "l_value", l_value, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_value); gtk_clist_set_column_widget (GTK_CLIST (clist1), 1, l_value); t_keyword = gtk_entry_new (); gtk_widget_ref (t_keyword); gtk_object_set_data_full (GTK_OBJECT (gensetup), "t_keyword", t_keyword, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (t_keyword); gtk_fixed_put (GTK_FIXED (fixed1), t_keyword, 80, 288); gtk_widget_set_uposition (t_keyword, 80, 288); gtk_widget_set_usize (t_keyword, 158, 22); t_value = gtk_entry_new (); gtk_widget_ref (t_value); gtk_object_set_data_full (GTK_OBJECT (gensetup), "t_value", t_value, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (t_value); gtk_fixed_put (GTK_FIXED (fixed1), t_value, 80, 320); gtk_widget_set_uposition (t_value, 80, 320); gtk_widget_set_usize (t_value, 158, 22); vbuttonbox1 = gtk_vbutton_box_new (); gtk_widget_ref (vbuttonbox1); gtk_object_set_data_full (GTK_OBJECT (gensetup), "vbuttonbox1", vbuttonbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (vbuttonbox1); gtk_fixed_put (GTK_FIXED (fixed1), vbuttonbox1, 248, 280); gtk_widget_set_uposition (vbuttonbox1, 248, 280); gtk_widget_set_usize (vbuttonbox1, 85, 69); b_add = gtk_button_new_with_label (""); button_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_add)->child), szKeysButtons[0]); gtk_widget_add_accelerator (b_add, "clicked", accel_group, button_key, GDK_MOD1_MASK, 0); gtk_widget_ref (b_add); gtk_object_set_data_full (GTK_OBJECT (gensetup), "b_add", b_add, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (b_add); gtk_container_add (GTK_CONTAINER (vbuttonbox1), b_add); GTK_WIDGET_SET_FLAGS (b_add, GTK_CAN_DEFAULT); gtk_widget_add_accelerator (b_add, "clicked", accel_group, 'A', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); b_update = gtk_button_new_with_label (""); button_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_update)->child), szKeysButtons[1]); gtk_widget_add_accelerator (b_update, "clicked", accel_group, button_key, GDK_MOD1_MASK, 0); gtk_widget_ref (b_update); gtk_object_set_data_full (GTK_OBJECT (gensetup), "b_update", b_update, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (b_update); gtk_container_add (GTK_CONTAINER (vbuttonbox1), b_update); GTK_WIDGET_SET_FLAGS (b_update, GTK_CAN_DEFAULT); gtk_widget_add_accelerator (b_update, "clicked", accel_group, 'U', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); gtk_widget_set_sensitive (b_update, FALSE); l_keyword = gtk_label_new ("Keyword : "); gtk_widget_ref (l_keyword); gtk_object_set_data_full (GTK_OBJECT (gensetup), "l_keyword", l_keyword, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_keyword); gtk_fixed_put (GTK_FIXED (fixed1), l_keyword, 8, 290); gtk_widget_set_uposition (l_keyword, 8, 290); gtk_widget_set_usize (l_keyword, 69, 16); gtk_label_set_justify (GTK_LABEL (l_keyword), GTK_JUSTIFY_LEFT); l_valeur = gtk_label_new ("Value : "); gtk_widget_ref (l_valeur); gtk_object_set_data_full (GTK_OBJECT (gensetup), "l_valeur", l_valeur, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_valeur); gtk_fixed_put (GTK_FIXED (fixed1), l_valeur, 8, 323); gtk_widget_set_uposition (l_valeur, 8, 323); gtk_widget_set_usize (l_valeur, 51, 16); gtk_label_set_justify (GTK_LABEL (l_valeur), GTK_JUSTIFY_LEFT); cb_verify = gtk_check_button_new_with_label ("Verify this connection(recommended)"); gtk_widget_ref (cb_verify); gtk_object_set_data_full (GTK_OBJECT (gensetup), "cb_verify", cb_verify, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (cb_verify); gtk_fixed_put (GTK_FIXED (fixed1), cb_verify, 8, 350); gtk_widget_set_uposition (cb_verify, 8, 350); gtk_widget_set_usize (cb_verify, 230, 24); dialog_action_area1 = GTK_DIALOG (gensetup)->action_area; gtk_object_set_data (GTK_OBJECT (gensetup), "dialog_action_area1", dialog_action_area1); gtk_widget_show (dialog_action_area1); gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 5); hbuttonbox1 = gtk_hbutton_box_new (); gtk_widget_ref (hbuttonbox1); gtk_object_set_data_full (GTK_OBJECT (gensetup), "hbuttonbox1", hbuttonbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hbuttonbox1); gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbuttonbox1, TRUE, TRUE, 0); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END); gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 10); b_ok = gtk_button_new_with_label (""); button_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_ok)->child), "_Ok"); gtk_widget_add_accelerator (b_ok, "clicked", accel_group, button_key, GDK_MOD1_MASK, 0); gtk_widget_ref (b_ok); gtk_object_set_data_full (GTK_OBJECT (gensetup), "b_ok", b_ok, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (b_ok); gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_ok); GTK_WIDGET_SET_FLAGS (b_ok, GTK_CAN_DEFAULT); gtk_widget_add_accelerator (b_ok, "clicked", accel_group, 'O', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); b_cancel = gtk_button_new_with_label (""); button_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_cancel)->child), "_Cancel"); gtk_widget_add_accelerator (b_cancel, "clicked", accel_group, button_key, GDK_MOD1_MASK, 0); gtk_widget_ref (b_cancel); gtk_object_set_data_full (GTK_OBJECT (gensetup), "b_cancel", b_cancel, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (b_cancel); gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_cancel); GTK_WIDGET_SET_FLAGS (b_cancel, GTK_CAN_DEFAULT); gtk_widget_add_accelerator (b_cancel, "clicked", accel_group, 'C', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); /* Ok button events */ gtk_signal_connect (GTK_OBJECT (b_ok), "clicked", GTK_SIGNAL_FUNC (gensetup_ok_clicked), &gensetup_t); /* Cancel button events */ gtk_signal_connect (GTK_OBJECT (b_cancel), "clicked", GTK_SIGNAL_FUNC (gensetup_cancel_clicked), &gensetup_t); /* Add button events */ gtk_signal_connect (GTK_OBJECT (b_add), "clicked", GTK_SIGNAL_FUNC (gensetup_add_clicked), &gensetup_t); /* Update button events */ gtk_signal_connect (GTK_OBJECT (b_update), "clicked", GTK_SIGNAL_FUNC (gensetup_update_clicked), &gensetup_t); /* Close window button events */ gtk_signal_connect (GTK_OBJECT (gensetup), "delete_event", GTK_SIGNAL_FUNC (delete_event), &gensetup_t); gtk_signal_connect (GTK_OBJECT (gensetup), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); /* List events */ gtk_signal_connect (GTK_OBJECT (clist1), "select_row", GTK_SIGNAL_FUNC (gensetup_list_select), &gensetup_t); gtk_signal_connect (GTK_OBJECT (clist1), "unselect_row", GTK_SIGNAL_FUNC (gensetup_list_unselect), &gensetup_t); gtk_window_add_accel_group (GTK_WINDOW (gensetup), accel_group); gensetup_t.dsn_entry = NULL; gensetup_t.key_list = clist1; gensetup_t.bupdate = b_update; gensetup_t.key_entry = t_keyword; gensetup_t.value_entry = t_value; gensetup_t.mainwnd = gensetup; gensetup_t.verify_conn_cb = cb_verify; gensetup_t.verify_conn = *verify_conn; gtk_toggle_button_set_active(cb_verify, *verify_conn); /* Parse the attributes line */ parse_attribute_line (&gensetup_t, NULL, attrs, TRUE); gtk_widget_show_all (gensetup); gtk_main (); *verify_conn = gensetup_t.verify_conn; return gensetup_t.connstr; }
void DownloadUI::CreateDownloadUI(void) { m_downloadUI = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(m_downloadUI), BRANDING" - DownloadManager"); gtk_signal_connect(GTK_OBJECT(m_downloadUI), "destroy", GTK_SIGNAL_FUNC(toggle_vis_internal), this); gtk_container_set_border_width(GTK_CONTAINER(m_downloadUI), 5); GtkWidget *vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(m_downloadUI), vbox); gtk_widget_set_usize(vbox, 400, 400); gtk_widget_show(vbox); GtkWidget *text = gtk_label_new(NULL); gtk_label_set_line_wrap(GTK_LABEL(text), TRUE); if (!strncasecmp(BRANDING_COMPANY, "EMusic", 6)) gtk_label_set_text(GTK_LABEL(text), szEMusicText); else gtk_label_set_text(GTK_LABEL(text), szFreeAmpText); gtk_label_set_justify(GTK_LABEL(text), GTK_JUSTIFY_FILL); gtk_misc_set_alignment(GTK_MISC(text), (gfloat)0.0, (gfloat)0.0); gtk_box_pack_start(GTK_BOX(vbox), text, FALSE, FALSE, 2); gtk_widget_set_usize(text, 400, 46); gtk_widget_show(text); GtkWidget *emusic_button; if (!strncasecmp(BRANDING_COMPANY, "EMusic", 6)) emusic_button = gtk_button_new_with_label(szEMusicURLText); else emusic_button = gtk_button_new_with_label(szFreeAmpURLText); gtk_box_pack_start(GTK_BOX(vbox), emusic_button, FALSE, FALSE, 2); gtk_signal_connect(GTK_OBJECT(emusic_button), "clicked", GTK_SIGNAL_FUNC(emusic_click), this); gtk_widget_show(emusic_button); GtkWidget *listwindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(listwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(vbox), listwindow, TRUE, TRUE, 0); gtk_widget_set_usize(listwindow, 400, 140); gtk_widget_show(listwindow); GtkWidget *table = gtk_table_new(7, 2, FALSE); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); gtk_widget_show(table); GtkWidget *label = gtk_label_new("Artist:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); artist = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), artist, 1, 2, 0, 1); gtk_widget_show(artist); label = gtk_label_new("Album:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); album = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(album), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), album, 1, 2, 1, 2); gtk_widget_show(album); label = gtk_label_new("Title:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); title = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(title), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), title, 1, 2, 2, 3); gtk_widget_show(title); label = gtk_label_new("Genre:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); genre = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(genre), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), genre, 1, 2, 3, 4); gtk_widget_show(genre); label = gtk_label_new("Playlist:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); playlist = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(playlist), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), playlist, 1, 2, 4, 5); gtk_widget_show(playlist); label = gtk_label_new("File Name:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); name = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(name), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), name, 1, 2, 5, 6); gtk_widget_show(name); label = gtk_label_new("File Size:"); gtk_misc_set_alignment(GTK_MISC(label), (gfloat)0.0, (gfloat)0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 6, 7, GTK_FILL, GTK_FILL, 10, 1); gtk_widget_show(label); size = gtk_label_new(" "); gtk_misc_set_alignment(GTK_MISC(size), (gfloat)0.0, (gfloat)0.5); gtk_table_attach_defaults(GTK_TABLE(table), size, 1, 2, 6, 7); gtk_widget_show(size); CreateDownloadList(listwindow); GtkWidget *sep = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, TRUE, 2); gtk_widget_show(sep); m_closeComplete = gtk_check_button_new_with_label("Close the Download Manager when all downloads finish"); gtk_box_pack_start(GTK_BOX(vbox), m_closeComplete, FALSE, FALSE, 1); bool set = false; m_prefs->GetPrefBoolean(kCloseDLMOnCompletePref, &set); if (set) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_closeComplete), TRUE); gtk_widget_show(m_closeComplete); sep = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, TRUE, 5); gtk_widget_show(sep); GtkWidget *hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); m_CancelButton = gtk_button_new_with_label(" Cancel "); gtk_box_pack_start(GTK_BOX(hbox), m_CancelButton, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(m_CancelButton), "clicked", GTK_SIGNAL_FUNC(cancel_internal), this); gtk_widget_show(m_CancelButton); m_PauseButton = gtk_button_new_with_label(" Pause "); gtk_box_pack_start(GTK_BOX(hbox), m_PauseButton, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(m_PauseButton), "clicked", GTK_SIGNAL_FUNC(pause_internal), this); gtk_widget_show(m_PauseButton); m_ResumeButton = gtk_button_new(); m_ResumeLabel = gtk_label_new(" Resume "); gtk_container_add(GTK_CONTAINER(m_ResumeButton), m_ResumeLabel); gtk_box_pack_start(GTK_BOX(hbox), m_ResumeButton, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(m_ResumeButton), "clicked", GTK_SIGNAL_FUNC(resume_internal), this); gtk_widget_show(m_ResumeLabel); gtk_widget_show(m_ResumeButton); sep = gtk_vseparator_new(); gtk_box_pack_start(GTK_BOX(hbox), sep, TRUE, FALSE, 5); gtk_widget_show(sep); m_CloseButton = gtk_button_new_with_label(" Close "); gtk_box_pack_end(GTK_BOX(hbox), m_CloseButton, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(m_CloseButton), "clicked", GTK_SIGNAL_FUNC(close_internal), this); gtk_widget_show(m_CloseButton); m_helpButton = gtk_button_new_with_label(" Help "); gtk_box_pack_end(GTK_BOX(hbox), m_helpButton, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(m_helpButton), "clicked", GTK_SIGNAL_FUNC(help_button_click), this); gtk_widget_show(m_helpButton); gtk_widget_show(m_downloadUI); }
GtkWidget *create_dialog1 (void) { GtkWidget *dialog1; GtkWidget *dialog_vbox1; GtkWidget *table1; GtkWidget *label1; GtkWidget *label3; GtkWidget *label5; GtkWidget *label_19; GtkWidget *label_label; GtkWidget *label_labelfps; GtkWidget *dialog_action_area1; dialog1 = gtk_dialog_new (); gtk_object_set_data (GTK_OBJECT (dialog1), "dialog1", dialog1); gtk_window_set_title (GTK_WINDOW (dialog1), "Encoding"); gtk_window_set_policy (GTK_WINDOW (dialog1), TRUE, TRUE, FALSE); dialog_vbox1 = GTK_DIALOG (dialog1)->vbox; gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_vbox1", dialog_vbox1); gtk_widget_show (dialog_vbox1); gtk_window_set_modal(GTK_WINDOW(dialog1), 1); table1 = gtk_table_new (4, 2, FALSE); gtk_widget_ref (table1); gtk_object_set_data_full (GTK_OBJECT (dialog1), "table1", table1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0); label1 = gtk_label_new (" Phasis :"); gtk_widget_ref (label1); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label1", label1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label1); gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE); gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5); label_phasis = gtk_label_new ("Idling"); gtk_widget_ref (label_phasis); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_phasis", label_phasis, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_phasis); gtk_table_attach (GTK_TABLE (table1), label_phasis, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_phasis), 0, 0.5); label3 = gtk_label_new (" Frame # :"); gtk_widget_ref (label3); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label3", label3, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label3); gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5); label_frame = gtk_label_new ("0"); gtk_widget_ref (label_frame); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_frame", label_frame, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_frame); gtk_table_attach (GTK_TABLE (table1), label_frame, 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_frame), 0, 0.5); label5 = gtk_label_new (" Estimated time left :"); gtk_widget_ref (label5); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label5", label5, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label5); gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5); label_eta = gtk_label_new ("0"); gtk_widget_ref (label_eta); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_eta", label_eta, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_eta); gtk_table_attach (GTK_TABLE (table1), label_eta, 1, 2, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_eta), 0, 0.5); label_19 = gtk_label_new (" Codec used :"); gtk_widget_ref (label_19); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_19", label_19, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_19); gtk_table_attach (GTK_TABLE (table1), label_19, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_19), 0, 0.5); //-- label_codec = gtk_label_new ("None"); gtk_widget_ref (label_codec); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_codec", label_codec, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_codec); gtk_table_attach (GTK_TABLE (table1), label_codec, 1, 2, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_codec), 0, 0.5); // fps label_labelfps = gtk_label_new (" Fps"); gtk_widget_ref (label_labelfps); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_labelfps", label_labelfps, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_labelfps); gtk_table_attach (GTK_TABLE (table1), label_labelfps, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_labelfps), 0, 0.5); label_fps = gtk_label_new ("0"); gtk_widget_ref (label_fps); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_fps", label_fps, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_fps); gtk_table_attach (GTK_TABLE (table1), label_fps, 1, 2, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_fps), 0, 0.5); // size label_label label_label = gtk_label_new (" Size MB"); gtk_widget_ref (label_label); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_label", label_label, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_label); gtk_table_attach (GTK_TABLE (table1), label_label, 0, 1, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_label), 0, 0.5); label_size = gtk_label_new ("None"); gtk_widget_ref (label_size); gtk_object_set_data_full (GTK_OBJECT (dialog1), "label_size", label_size, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label_size); gtk_table_attach (GTK_TABLE (table1), label_size, 1, 2, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_size), 0, 0.5); // dialog_action_area1 = GTK_DIALOG (dialog1)->action_area; gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_action_area1", dialog_action_area1); gtk_widget_show (dialog_action_area1); // progress bar //________________ progressbar1 = gtk_progress_bar_new (); gtk_widget_ref (progressbar1); gtk_object_set_data_full (GTK_OBJECT (dialog1), "progressbar1", progressbar1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (progressbar1); gtk_box_pack_start (GTK_BOX (dialog_action_area1), progressbar1, FALSE, FALSE, 0); // / progress bar gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 10); // button_cancel = gtk_button_new_with_label ("Abort"); gtk_widget_ref (button_cancel); gtk_object_set_data_full (GTK_OBJECT (dialog1), "button_cancel", button_cancel, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (button_cancel); gtk_box_pack_start (GTK_BOX (dialog_action_area1), button_cancel, FALSE, FALSE, 0); // Call back gtk_object_set_data_full(GTK_OBJECT(dialog1), "dialog1", dialog1, (GtkDestroyNotify) cb_destroy); gtk_signal_connect(GTK_OBJECT(button_cancel), "button_press_event", GTK_SIGNAL_FUNC(cb_abort), 0); return dialog1; }
G_MODULE_EXPORT gboolean display_show(NOTIFICATION_INFO* ni) { GdkColor color; GtkWidget* vbox; GtkWidget* hbox; GtkWidget* label; GtkWidget* image; GdkScreen* screen; gint n, pos, len; gint x, y; gint monitor_num; GdkRectangle rect; DISPLAY_INFO* di = g_new0(DISPLAY_INFO, 1); if (!di) { perror("g_new0"); return FALSE; } di->ni = ni; len = g_list_length(notifications); for (pos = 0; pos < len; pos++) { DISPLAY_INFO* p = g_list_nth_data(notifications, pos); if (pos != p->pos) break; } screen = gdk_screen_get_default(); monitor_num = gdk_screen_get_primary_monitor(screen); gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); x = rect.x + rect.width - 250; y = rect.y + rect.height - 110; for (n = 0; n < pos; n++) { y -= 110; if (y < 0) { x -= 250; if (x < 0) { return FALSE; } y = rect.y + rect.height - 110; } } di->pos = pos; notifications = g_list_insert_sorted(notifications, di, notifications_compare); di->x = x; di->y = y; di->popup = gtk_window_new(GTK_WINDOW_POPUP); gtk_window_set_title(GTK_WINDOW(di->popup), "growl-for-linux"); gtk_window_set_resizable(GTK_WINDOW(di->popup), FALSE); gtk_window_set_decorated(GTK_WINDOW(di->popup), FALSE); gtk_window_set_keep_above(GTK_WINDOW(di->popup), TRUE); gtk_window_stick(GTK_WINDOW(di->popup)); vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(vbox), 18); gtk_container_add(GTK_CONTAINER(di->popup), vbox); hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); if (di->ni->icon && *di->ni->icon) { GdkPixbuf* pixbuf; if (di->ni->local) { gchar* newurl = g_filename_from_uri(di->ni->icon, NULL, NULL); GError* error = NULL; pixbuf = gdk_pixbuf_new_from_file(newurl ? newurl : di->ni->icon, &error); if (newurl) g_free(newurl); } else pixbuf = url2pixbuf(di->ni->icon, NULL); if (pixbuf) { GdkPixbuf* tmp = gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_TILES); if (tmp) { g_object_unref(pixbuf); pixbuf = tmp; } image = gtk_image_new_from_pixbuf(pixbuf); gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); g_object_unref(pixbuf); } } PangoFontDescription* font_desc; font_desc = pango_font_description_new(); pango_font_description_set_family(font_desc, "Sans"); pango_font_description_set_size(font_desc, 12 * PANGO_SCALE); label = gtk_label_new(di->ni->title); gdk_color_parse("white", &color); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color); gtk_widget_modify_font(label, font_desc); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); pango_font_description_free(font_desc); font_desc = pango_font_description_new(); pango_font_description_set_family(font_desc, "Sans"); pango_font_description_set_size(font_desc, 8 * PANGO_SCALE); label = gtk_label_new(di->ni->text); gdk_color_parse("white", &color); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color); gtk_widget_modify_font(label, font_desc); g_signal_connect(G_OBJECT(label), "size-allocate", G_CALLBACK(label_size_allocate), NULL); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_CHAR); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0); pango_font_description_free(font_desc); gtk_widget_set_events(di->popup, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(di->popup), "button-press-event", G_CALLBACK(display_clicked), di); di->offset = 0; di->timeout = 500; gtk_window_move(GTK_WINDOW(di->popup), di->x, di->y); gtk_window_set_opacity(GTK_WINDOW(di->popup), 0); gtk_widget_set_app_paintable(di->popup, TRUE); gtk_widget_show_all(di->popup); if (pixmap == NULL) { pixmap = gdk_pixmap_create_from_xpm_d(di->popup->window, &bitmap, NULL, balloon); } gdk_drawable_get_size(pixmap, &pixmap_width, &pixmap_height); gtk_widget_set_size_request(di->popup, pixmap_width, pixmap_height); gdk_window_shape_combine_mask(di->popup->window, bitmap, 0, 0); g_signal_connect(G_OBJECT(di->popup), "expose-event", G_CALLBACK(display_expose), di); g_timeout_add(10, display_animation_func, di); return FALSE; }
void FormDialog::single_choice (const std::string name, const std::string description, const std::string value, const std::map<std::string, std::string> choices, bool advanced) { GtkWidget *label = NULL; gchar* label_text = NULL; GtkListStore *model = NULL; GtkWidget *widget = NULL; GtkCellRenderer *renderer = NULL; GtkTreeIter iter; SingleChoiceSubmitter *submitter = NULL; grow_fields (advanced); label = gtk_label_new (NULL); gtk_size_group_add_widget (labels_group, label); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); label_text = g_strdup_printf ("<b>%s</b>", description.c_str ()); gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), label_text); g_free (label_text); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD); model = gtk_list_store_new (SingleChoiceSubmitter::COLUMN_NUMBER, G_TYPE_STRING, G_TYPE_STRING); widget = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model)); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", SingleChoiceSubmitter::COLUMN_NAME, NULL); for (std::map<std::string, std::string>::const_iterator map_iter = choices.begin (); map_iter != choices.end (); map_iter++) { gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, SingleChoiceSubmitter::COLUMN_VALUE, map_iter->first.c_str (), SingleChoiceSubmitter::COLUMN_NAME, map_iter->second.c_str (), -1); if (map_iter->first == value) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter); } if (advanced) { gtk_table_attach (GTK_TABLE (advanced_fields), label, 0, 1, advanced_rows -1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0,0); gtk_table_attach (GTK_TABLE (advanced_fields), widget, 1, 2, advanced_rows -1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0,0); } else { gtk_table_attach (GTK_TABLE (fields), label, 0, 1, rows -1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0,0); gtk_table_attach (GTK_TABLE (fields), widget, 1, 2, rows -1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0,0); } submitter = new SingleChoiceSubmitter (name, description, choices, advanced, widget); submitters.push_back (submitter); }
void bluetooth_connection_new (GtkWindow *parent, const char *detail, NMClient *client, PageNewConnectionResultFunc result_func, gpointer user_data) { gint response; NMAMobileWizard *wizard = NULL; WizardInfo *info; GtkWidget *dialog, *content, *alignment, *vbox, *label, *dun_radio, *panu_radio; info = g_malloc0 (sizeof (WizardInfo)); info->result_func = result_func; info->client = g_object_ref (client); info->user_data = user_data; info->type = NM_SETTING_BLUETOOTH_TYPE_PANU; dialog = gtk_dialog_new_with_buttons (_("Bluetooth Type"), parent, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); content = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); alignment = gtk_alignment_new (0, 0, 0.5, 0.5); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12); gtk_box_pack_start (GTK_BOX (content), alignment, TRUE, FALSE, 6); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (alignment), vbox); label = gtk_label_new (_("Select the type of the Bluetooth connection profile.")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 12); panu_radio = gtk_radio_button_new_with_mnemonic (NULL, _("_Personal Area Network")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panu_radio), TRUE); gtk_box_pack_start (GTK_BOX (vbox), panu_radio, FALSE, FALSE, 6); dun_radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (panu_radio), _("_Dial-Up Network")); gtk_box_pack_start (GTK_BOX (vbox), dun_radio, FALSE, FALSE, 6); gtk_widget_show_all (dialog); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_OK) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dun_radio))) { info->type = NM_SETTING_BLUETOOTH_TYPE_DUN; wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE, new_connection_mobile_wizard_done, info); } else { info->type = NM_SETTING_BLUETOOTH_TYPE_PANU; } } gtk_widget_destroy (dialog); if (wizard) nma_mobile_wizard_present (wizard); else new_connection_mobile_wizard_done (NULL, (response != GTK_RESPONSE_OK), NULL, info); }
GtkDialog* seahorse_passphrase_prompt_show (const gchar *title, const gchar *description, const gchar *prompt, const gchar *check, gboolean confirm) { GtkEntryBuffer *buffer; GtkEntry *entry; GtkDialog *dialog; GtkWidget *w; GtkWidget *box; GtkTable *table; GtkWidget *wvbox; GtkWidget *chbox; gchar *msg; if (!title) title = _("Passphrase"); if (!prompt) prompt = _("Password:"******"size-request", G_CALLBACK (constrain_size), NULL); g_signal_connect (G_OBJECT (dialog), "map-event", G_CALLBACK (grab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "unmap-event", G_CALLBACK (ungrab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "window-state-event", G_CALLBACK (window_state_changed), NULL); wvbox = gtk_vbox_new (FALSE, HIG_LARGE * 2); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)), 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); /* The image */ 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); /* The description text */ if (description) { msg = utf8_validate (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); } /* Two entries (usually on is hidden) in a vbox */ table = GTK_TABLE (gtk_table_new (3, 2, FALSE)); gtk_table_set_row_spacings (table, HIG_SMALL); gtk_table_set_col_spacings (table, HIG_LARGE); gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (table), FALSE, FALSE, 0); /* The first entry if we have one */ if (confirm) { msg = utf8_validate (prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_entry_set_visibility (entry, FALSE); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); g_object_set_data (G_OBJECT (dialog), "confirm-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (confirm_callback), dialog); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 0, 1); gtk_widget_grab_focus (GTK_WIDGET (entry)); } /* The second and main entry */ msg = utf8_validate (confirm ? _("Confirm:") : prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); gtk_entry_set_visibility (entry, FALSE); g_object_set_data (G_OBJECT (dialog), "secure-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 1, 2); if (!confirm) gtk_widget_grab_focus (GTK_WIDGET (entry)); else g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); /* The checkbox */ if (check) { w = gtk_check_button_new_with_mnemonic (check); gtk_table_attach_defaults (table, w, 1, 2, 2, 3); g_object_set_data (G_OBJECT (dialog), "check-option", w); } gtk_widget_show_all (GTK_WIDGET (table)); w = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_REJECT); gtk_widget_set_can_default (w, TRUE); w = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_ACCEPT); gtk_widget_set_can_default (w, TRUE); g_signal_connect_object (G_OBJECT (entry), "focus_in_event", G_CALLBACK (gtk_widget_grab_default), G_OBJECT (w), 0); gtk_widget_grab_default (w); g_signal_connect (dialog, "key_press_event", G_CALLBACK (key_press), NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); gtk_widget_show_all (GTK_WIDGET (dialog)); gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (dialog)), GDK_CURRENT_TIME); if (confirm) entry_changed (NULL, dialog); return dialog; }
static GtkWidget * do_image (const char *filename) { GtkWidget *frame; GtkWidget *vbox; GtkWidget *image; GtkWidget *label; GtkWidget *align; GtkWidget *window; gchar *str, *escaped; LoadContext *lc; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Image Loading"); gtk_container_set_border_width (GTK_CONTAINER (window), 8); vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 8); gtk_container_add (GTK_CONTAINER (window), vbox); label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); escaped = g_markup_escape_text (filename, -1); str = g_strdup_printf ("Progressively loading: <b>%s</b>", escaped); gtk_label_set_markup (GTK_LABEL (label), str); g_free (escaped); g_free (str); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); /* The alignment keeps the frame from growing when users resize * the window */ align = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (align), frame); gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0); image = gtk_image_new_from_pixbuf (NULL); gtk_container_add (GTK_CONTAINER (frame), image); lc = get_load_context (image); lc->window = window; lc->filename = g_strdup (filename); start_progressive_loading (image); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show_all (window); return window; }
GtkWidget *sat_pref_debug_create() { GtkWidget *vbox; /* vbox containing the list part and the details part */ GtkWidget *hbox; GtkWidget *rbut; GtkWidget *label; GtkWidget *butbox; gchar *msg; gchar *confdir; vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10); gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); gtk_container_set_border_width(GTK_CONTAINER(vbox), 20); gtk_box_set_spacing(GTK_BOX(vbox), 10); /* debug level */ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE); label = gtk_label_new(_("Debug level:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); level = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level), _("Level 0: None")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level), _("Level 1: Error")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level), _("Level 2: Warning")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level), _("Level 3: Info")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level), _("Level 4: Debug")); gtk_combo_box_set_active(GTK_COMBO_BOX(level), sat_cfg_get_int(SAT_CFG_INT_LOG_LEVEL)); g_signal_connect(G_OBJECT(level), "realize", G_CALLBACK(gpredict_set_combo_tooltips), _("Select the debug level. The higher the level, " "the more messages will be logged.")); g_signal_connect(G_OBJECT(level), "changed", G_CALLBACK(state_change_cb), NULL); gtk_box_pack_start(GTK_BOX(hbox), level, FALSE, FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); /* clean frequency */ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE); label = gtk_label_new(_("Delete log files older than:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); age = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("Always delete")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("1 day")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("1 week")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("1 month")); select_age(); g_signal_connect(G_OBJECT(age), "realize", G_CALLBACK(gpredict_set_combo_tooltips), _("Select how often gpredict should delete " "old log files.")); g_signal_connect(G_OBJECT(age), "changed", G_CALLBACK(state_change_cb), NULL); gtk_box_pack_start(GTK_BOX(hbox), age, FALSE, FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); /* separator */ gtk_box_pack_start(GTK_BOX(vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0); /* info label */ confdir = get_user_conf_dir(); msg = g_strdup_printf(_ ("Gpredict stores all run-time messages in the %s%slogs%s\n" "directory. The current log file is called gpredict.log and the file is\n" "always kept until the next execution, so that you can examine it in case\n" "of a failure. If old log files are kept, they are called gpredict-XYZ.log\n" "where XYZ is a unique timestamp."), confdir, G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S); label = gtk_label_new(msg); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); g_free(msg); /* reset button */ rbut = gtk_button_new_with_label(_("Reset")); gtk_widget_set_tooltip_text(rbut, _("Reset settings to the default values.")); g_signal_connect(G_OBJECT(rbut), "clicked", G_CALLBACK(reset_cb), NULL); butbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout(GTK_BUTTON_BOX(butbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(butbox), rbut, FALSE, TRUE, 10); gtk_box_pack_end(GTK_BOX(vbox), butbox, FALSE, TRUE, 0); return vbox; }
MessageDialogReturnEnum MessageDialog:: Show(const string &oMessage, const string &oTitle, MessageDialogEnum eType, bool InEventLoop) { if (!InEventLoop) gdk_threads_enter(); int iRet = 0; GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (InEventLoop) gtk_window_set_modal(GTK_WINDOW(window), TRUE); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(message_destroy), (gpointer)InEventLoop); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(kill_me), &iRet); gtk_window_set_title(GTK_WINDOW(window), oTitle.c_str()); gtk_container_set_border_width(GTK_CONTAINER(window), 5); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); GtkWidget *vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); GtkWidget *message = gtk_label_new(oMessage.c_str()); gtk_label_set_line_wrap(GTK_LABEL(message), TRUE); gtk_container_add(GTK_CONTAINER(vbox), message); gtk_widget_show(message); GtkWidget *hbox = gtk_hbox_new(FALSE, 10); gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); gtk_container_add(GTK_CONTAINER(vbox), hbox); gtk_widget_show(hbox); GtkWidget *button; switch (eType) { case kMessageOk: { button = gtk_button_new_with_label("OK"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); break; } case kMessageYesNo: { button = gtk_button_new_with_label("Yes"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(yes_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); button = gtk_button_new_with_label("No"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(no_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); break; } case kMessageOkCancel: { button = gtk_button_new_with_label("OK"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); button = gtk_button_new_with_label("Cancel"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); break; } case kMessageMonicaSucks: { button = gtk_button_new_with_label("Retry"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(retry_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); button = gtk_button_new_with_label("Cancel"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_click), &iRet); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); gtk_container_add(GTK_CONTAINER(hbox), button); gtk_widget_show(button); break; } } gtk_widget_show(window); if (!InEventLoop) { gdk_threads_leave(); while (iRet == 0) usleep(20); } else { gtk_main(); gdk_threads_leave(); } switch (iRet) { case 1: return kMessageReturnOk; case 2: return kMessageReturnYes; case 3: return kMessageReturnNo; case 4: return kMessageReturnCancel; case 5: return kMessageReturnMonicaDoesSuck; default: return kMessageReturnUnknown; } }
static GtkWidget * progress_widget_new (NautilusProgressInfo *info) { ProgressWidgetData *data; GtkWidget *label, *bar, *hbox, *vbox, *button, *image; data = g_new0 (ProgressWidgetData, 1); data->info = g_object_ref (info); hbox = gtk_hbox_new (FALSE, 0); data->widget = hbox; g_object_set_data_full (G_OBJECT (data->widget), "data", data, (GDestroyNotify)progress_widget_data_free); vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 2); gtk_widget_show (vbox); label = gtk_label_new ("details"); gtk_widget_set_size_request (label, 400, -1); data->status = GTK_LABEL (label); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2); bar = gtk_progress_bar_new (); data->progress_bar = GTK_PROGRESS_BAR (bar); gtk_progress_bar_set_pulse_step (data->progress_bar, 0.05); gtk_widget_show (bar); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 2); label = gtk_label_new ("status"); gtk_widget_set_size_request (label, 400, -1); data->details = GTK_LABEL (label); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON); gtk_widget_show (image); button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), image); gtk_widget_show (button); gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, FALSE, 0); g_signal_connect (button, "clicked", (GCallback)cancel_clicked, data); update_data (data); update_progress (data); g_signal_connect_swapped (data->info, "changed", (GCallback)update_data, data); g_signal_connect_swapped (data->info, "progress_changed", (GCallback)update_progress, data); g_signal_connect_swapped (data->info, "finished", (GCallback)op_finished, data); gtk_widget_show (data->widget); return data->widget; }
static void show_auth_dialog(WebKitAuthData* authData, const char* login, const char* password) { GtkWidget* toplevel; GtkWidget* widget; GtkDialog* dialog; GtkWindow* window; GtkWidget* entryContainer; GtkWidget* hbox; GtkWidget* mainVBox; GtkWidget* vbox; GtkWidget* icon; GtkWidget* table; GtkWidget* messageLabel; char* message; SoupURI* uri; GtkWidget* rememberBox; GtkWidget* checkButton; /* From GTK+ gtkmountoperation.c, modified and simplified. LGPL 2 license */ widget = gtk_dialog_new(); window = GTK_WINDOW(widget); dialog = GTK_DIALOG(widget); gtk_dialog_add_buttons(dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); /* Set the dialog up with HIG properties */ gtk_dialog_set_has_separator(dialog, FALSE); gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); gtk_box_set_spacing(GTK_BOX(dialog->vbox), 2); /* 2 * 5 + 2 = 12 */ gtk_container_set_border_width(GTK_CONTAINER(dialog->action_area), 5); gtk_box_set_spacing(GTK_BOX(dialog->action_area), 6); gtk_window_set_resizable(window, FALSE); gtk_window_set_title(window, ""); gtk_window_set_icon_name(window, GTK_STOCK_DIALOG_AUTHENTICATION); gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK); /* Get the current toplevel */ g_signal_emit(authData->manager, signals[CURRENT_TOPLEVEL], 0, authData->msg, &toplevel); if (toplevel) gtk_window_set_transient_for(window, GTK_WINDOW(toplevel)); /* Build contents */ hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); gtk_box_pack_start(GTK_BOX(dialog->vbox), hbox, TRUE, TRUE, 0); icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); mainVBox = gtk_vbox_new(FALSE, 18); gtk_box_pack_start(GTK_BOX(hbox), mainVBox, TRUE, TRUE, 0); uri = soup_message_get_uri(authData->msg); message = g_strdup_printf(_("A username and password are being requested by the site %s"), uri->host); messageLabel = gtk_label_new(message); g_free(message); gtk_misc_set_alignment(GTK_MISC(messageLabel), 0.0, 0.5); gtk_label_set_line_wrap(GTK_LABEL(messageLabel), TRUE); gtk_box_pack_start(GTK_BOX(mainVBox), GTK_WIDGET(messageLabel), FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(mainVBox), vbox, FALSE, FALSE, 0); /* The table that holds the entries */ entryContainer = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); gtk_alignment_set_padding(GTK_ALIGNMENT(entryContainer), 0, 0, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), entryContainer, FALSE, FALSE, 0); table = gtk_table_new(2, 2, FALSE); gtk_table_set_col_spacings(GTK_TABLE(table), 12); gtk_table_set_row_spacings(GTK_TABLE(table), 6); gtk_container_add(GTK_CONTAINER(entryContainer), table); authData->loginEntry = table_add_entry(table, 0, _("Username:"******"Password:"******"_Remember password")); if (login && password) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE); gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE); gtk_box_pack_start(GTK_BOX(rememberBox), checkButton, FALSE, FALSE, 0); authData->checkButton = checkButton; } g_signal_connect(dialog, "response", G_CALLBACK(response_callback), authData); gtk_widget_show_all(widget); }
static void scrollable_policy (void) { GtkWidget *window, *swindow, *hbox, *vbox, *frame, *cntl, *listbox; GtkWidget *viewport, *label, *expander, *widget, *popover; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_set_border_width (GTK_CONTAINER (window), 8); gtk_widget_show (vbox); gtk_widget_show (hbox); gtk_container_add (GTK_CONTAINER (window), hbox); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new ("Scrolled Window"); gtk_widget_show (frame); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); swindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show (swindow); gtk_container_add (GTK_CONTAINER (frame), swindow); viewport = gtk_viewport_new (NULL, NULL); label = gtk_label_new ("Here is a wrapping label with a minimum width-chars of 40 and " "a natural max-width-chars of 100 to demonstrate the usage of " "scrollable widgets \"hscroll-policy\" and \"vscroll-policy\" " "properties. Note also that when playing with the window height, " "one can observe that the vscrollbar disappears as soon as there " "is enough height to fit the content vertically if the window were " "to be allocated a width without a vscrollbar present"); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_width_chars (GTK_LABEL (label), 40); gtk_label_set_max_width_chars (GTK_LABEL (label), 100); gtk_widget_show (label); gtk_widget_show (viewport); gtk_container_add (GTK_CONTAINER (viewport), label); gtk_container_add (GTK_CONTAINER (swindow), viewport); /* Add controls here */ expander = gtk_expander_new ("Controls"); gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE); cntl = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_widget_show (cntl); gtk_widget_show (expander); gtk_container_add (GTK_CONTAINER (expander), cntl); gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0); /* Add Horizontal policy control here */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_show (hbox); widget = gtk_label_new ("hscroll-policy"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Minimum"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Natural"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (horizontal_policy_changed), viewport); /* Add Vertical policy control here */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_show (hbox); widget = gtk_label_new ("vscroll-policy"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Minimum"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Natural"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (vertical_policy_changed), viewport); /* Content size controls */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); widget = gtk_label_new ("min-content-width"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (100.0, 1000.0, 10.0); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (content_width_changed), swindow); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); widget = gtk_label_new ("min-content-height"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (100.0, 1000.0, 10.0); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (content_height_changed), swindow); /* Add Label orientation control here */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_show (hbox); widget = gtk_label_new ("label-flip"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (label_flip_changed), label); /* Add Kinetic scrolling control here */ widget = gtk_check_button_new_with_label ("Kinetic scrolling"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (cntl), widget, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (kinetic_scrolling_changed), swindow); gtk_widget_show (window); /* Popover */ popover = gtk_popover_new (NULL); widget = gtk_menu_button_new (); gtk_menu_button_set_popover (GTK_MENU_BUTTON (widget), popover); gtk_container_add (GTK_CONTAINER (widget), gtk_label_new ("Popover")); gtk_box_pack_start (GTK_BOX (cntl), widget, FALSE, FALSE, 0); gtk_widget_show_all (widget); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (popover), vbox); gtk_widget_show (vbox); /* Popover's scrolled window */ swindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_end (GTK_BOX (vbox), swindow, FALSE, FALSE, 0); gtk_widget_show (swindow); gtk_widget_show (hbox); /* Listbox */ listbox = gtk_list_box_new (); gtk_container_add (GTK_CONTAINER (swindow), listbox); gtk_widget_show (listbox); /* Min content */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); widget = gtk_label_new ("min-content-width"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (0.0, 150.0, 10.0); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)), "value", swindow, "min-content-width", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); widget = gtk_label_new ("min-content-height"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (0.0, 150.0, 10.0); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)), "value", swindow, "min-content-height", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); /* Max content */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); widget = gtk_label_new ("max-content-width"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (250.0, 1000.0, 10.0); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)), "value", swindow, "max-content-width", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); widget = gtk_label_new ("max-content-height"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); widget = gtk_spin_button_new_with_range (250.0, 1000.0, 10.0); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)), "value", swindow, "max-content-height", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); /* Add and Remove buttons */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); widget = gtk_button_new_with_label ("Remove"); gtk_widget_show (widget); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); g_signal_connect (widget, "clicked", G_CALLBACK (remove_row), listbox); widget = gtk_button_new_with_label ("Add"); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (widget); gtk_widget_show (hbox); g_signal_connect (widget, "clicked", G_CALLBACK (add_row), listbox); }
static int passphrase_dialog(char *message) { const char *failed; char *passphrase, *local; char **messages; int result, i, grab_server, grab_pointer; GtkWidget *dialog, *entry, *label; GdkGrabStatus status; grab_server = (getenv("GNOME_SSH_ASKPASS_GRAB_SERVER") != NULL); grab_pointer = (getenv("GNOME_SSH_ASKPASS_GRAB_POINTER") != NULL); dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, "%s", message); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), entry, FALSE, FALSE, 0); gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); gtk_widget_grab_focus(entry); gtk_widget_show(entry); gtk_window_set_title(GTK_WINDOW(dialog), "OpenSSH"); gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_label_set_line_wrap(GTK_LABEL((GTK_MESSAGE_DIALOG(dialog))->label), TRUE); /* Make <enter> close dialog */ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(ok_dialog), dialog); /* Grab focus */ gtk_widget_show_now(dialog); if (grab_server) { gdk_x11_grab_server(); } if (grab_pointer) { status = gdk_pointer_grab((GTK_WIDGET(dialog))->window, TRUE, 0, NULL, NULL, GDK_CURRENT_TIME); if (status != GDK_GRAB_SUCCESS) { failed = "mouse"; goto nograb; } } status = gdk_keyboard_grab((GTK_WIDGET(dialog))->window, FALSE, GDK_CURRENT_TIME); if (status != GDK_GRAB_SUCCESS) { failed = "keyboard"; goto nograbkb; } result = gtk_dialog_run(GTK_DIALOG(dialog)); /* Ungrab */ if (grab_server) XUngrabServer(GDK_DISPLAY()); if (grab_pointer) gdk_pointer_ungrab(GDK_CURRENT_TIME); gdk_keyboard_ungrab(GDK_CURRENT_TIME); gdk_flush(); /* Report passphrase if user selected OK */ passphrase = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); if (result == GTK_RESPONSE_OK) { local = g_locale_from_utf8(passphrase, strlen(passphrase), NULL, NULL, NULL); if (local != NULL) { puts(local); memset(local, '\0', strlen(local)); g_free(local); } else { puts(passphrase); } } /* Zero passphrase in memory */ memset(passphrase, '\b', strlen(passphrase)); gtk_entry_set_text(GTK_ENTRY(entry), passphrase); memset(passphrase, '\0', strlen(passphrase)); g_free(passphrase); gtk_widget_destroy(dialog); return (result == GTK_RESPONSE_OK ? 0 : -1); /* At least one grab failed - ungrab what we got, and report the failure to the user. Note that XGrabServer() cannot fail. */ nograbkb: gdk_pointer_ungrab(GDK_CURRENT_TIME); nograb: if (grab_server) XUngrabServer(GDK_DISPLAY()); gtk_widget_destroy(dialog); report_failed_grab(failed); return (-1); }
static void gimp_display_shell_close_dialog (GimpDisplayShell *shell, GimpImage *image) { GtkWidget *dialog; GimpMessageBox *box; GtkWidget *label; GtkAccelGroup *accel_group; GClosure *closure; GSource *source; guint accel_key; GdkModifierType accel_mods; gchar *title; gchar *accel_string; gchar *hint; gchar *markup; GFile *file; if (shell->close_dialog) { gtk_window_present (GTK_WINDOW (shell->close_dialog)); return; } file = gimp_image_get_file (image); title = g_strdup_printf (_("Close %s"), gimp_image_get_display_name (image)); shell->close_dialog = dialog = gimp_message_dialog_new (title, "document-save", GTK_WIDGET (shell), GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, NULL, NULL); g_free (title); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("_Discard Changes"), GTK_RESPONSE_CLOSE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, (file ? GTK_STOCK_SAVE : GTK_STOCK_SAVE_AS), RESPONSE_SAVE, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), RESPONSE_SAVE, GTK_RESPONSE_CLOSE, GTK_RESPONSE_CANCEL, -1); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &shell->close_dialog); g_signal_connect (dialog, "response", G_CALLBACK (gimp_display_shell_close_response), shell); /* connect <Primary>D to the quit/close button */ accel_group = gtk_accel_group_new (); gtk_window_add_accel_group (GTK_WINDOW (shell->close_dialog), accel_group); g_object_unref (accel_group); closure = g_closure_new_object (sizeof (GClosure), G_OBJECT (shell->close_dialog)); g_closure_set_marshal (closure, gimp_display_shell_close_accel_marshal); gtk_accelerator_parse ("<Primary>D", &accel_key, &accel_mods); gtk_accel_group_connect (accel_group, accel_key, accel_mods, 0, closure); box = GIMP_MESSAGE_DIALOG (dialog)->box; accel_string = gtk_accelerator_get_label (accel_key, accel_mods); hint = g_strdup_printf (_("Press %s to discard all changes and close the image."), accel_string); markup = g_strdup_printf ("<i><small>%s</small></i>", hint); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_markup (GTK_LABEL (label), markup); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (markup); g_free (hint); g_free (accel_string); g_signal_connect_object (image, "name-changed", G_CALLBACK (gimp_display_shell_close_name_changed), box, 0); g_signal_connect_object (image, "exported", G_CALLBACK (gimp_display_shell_close_exported), box, 0); gimp_display_shell_close_name_changed (image, box); closure = g_cclosure_new_object (G_CALLBACK (gimp_display_shell_close_time_changed), G_OBJECT (box)); /* update every 10 seconds */ source = g_timeout_source_new_seconds (10); g_source_set_closure (source, closure); g_source_attach (source, NULL); g_source_unref (source); /* The dialog is destroyed with the shell, so it should be safe * to hold an image pointer for the lifetime of the dialog. */ g_object_set_data (G_OBJECT (box), "gimp-image", image); gimp_display_shell_close_time_changed (box); gtk_widget_show (dialog); }
static void set_message_area_text_and_icon (GtkInfoBar *message_area, const gchar *icon_stock_id, const gchar *primary_text, const gchar *secondary_text) { GtkWidget *hbox_content; GtkWidget *image; GtkWidget *vbox; gchar *primary_markup; gchar *secondary_markup; GtkWidget *primary_label; GtkWidget *secondary_label; hbox_content = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox_content); image = gtk_image_new_from_stock (icon_stock_id, GTK_ICON_SIZE_DIALOG); gtk_widget_show (image); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); #if GTK_CHECK_VERSION (3, 14, 0) gtk_widget_set_valign (image, GTK_ALIGN_START); #else gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); #endif vbox = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0); primary_markup = g_markup_printf_escaped ("<b>%s</b>", primary_text); primary_label = gtk_label_new (primary_markup); g_free (primary_markup); gtk_widget_show (primary_label); gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), FALSE); #if GTK_CHECK_VERSION (3, 14, 0) gtk_widget_set_halign (primary_label, GTK_ALIGN_START); #else gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); #endif gtk_widget_set_can_focus (primary_label, TRUE); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); if (secondary_text != NULL) { secondary_markup = g_markup_printf_escaped ("<small>%s</small>", secondary_text); secondary_label = gtk_label_new (secondary_markup); g_free (secondary_markup); gtk_widget_show (secondary_label); gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); gtk_widget_set_can_focus (secondary_label, TRUE); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); #if GTK_CHECK_VERSION (3, 14, 0) gtk_widget_set_halign (secondary_label, GTK_ALIGN_START); #else gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); #endif } gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (message_area))), hbox_content, TRUE, TRUE, 0); }
static void file_list_ready_cb (GList *files, gpointer user_data) { NautilusFileConflictDialog *fcd = user_data; NautilusFile *src, *dest, *dest_dir; time_t src_mtime, dest_mtime; gboolean source_is_dir, dest_is_dir, should_show_type; NautilusFileConflictDialogDetails *details; char *primary_text, *message, *secondary_text; const gchar *message_extra; char *dest_name, *dest_dir_name, *edit_name; char *label_text; char *size, *date, *type = NULL; GdkPixbuf *pixbuf; GtkWidget *label; GString *str; PangoAttrList *attr_list; details = fcd->details; details->handle = NULL; dest_dir = g_list_nth_data (files, 0); dest = g_list_nth_data (files, 1); src = g_list_nth_data (files, 2); src_mtime = nautilus_file_get_mtime (src); dest_mtime = nautilus_file_get_mtime (dest); dest_name = nautilus_file_get_display_name (dest); dest_dir_name = nautilus_file_get_display_name (dest_dir); source_is_dir = nautilus_file_is_directory (src); dest_is_dir = nautilus_file_is_directory (dest); type = nautilus_file_get_mime_type (dest); should_show_type = !nautilus_file_is_mime_type (src, type); g_free (type); type = NULL; /* Set up the right labels */ if (dest_is_dir) { if (source_is_dir) { primary_text = g_strdup_printf (_("Merge folder \"%s\"?"), dest_name); message_extra = _("Merging will ask for confirmation before replacing any files in " "the folder that conflict with the files being copied."); if (src_mtime > dest_mtime) { message = g_strdup_printf ( _("An older folder with the same name already exists in \"%s\"."), dest_dir_name); } else if (src_mtime < dest_mtime) { message = g_strdup_printf ( _("A newer folder with the same name already exists in \"%s\"."), dest_dir_name); } else { message = g_strdup_printf ( _("Another folder with the same name already exists in \"%s\"."), dest_dir_name); } } else { message_extra = _("Replacing it will remove all files in the folder."); primary_text = g_strdup_printf (_("Replace folder \"%s\"?"), dest_name); message = g_strdup_printf (_("A folder with the same name already exists in \"%s\"."), dest_dir_name); } } else { primary_text = g_strdup_printf (_("Replace file \"%s\"?"), dest_name); message_extra = _("Replacing it will overwrite its content."); if (src_mtime > dest_mtime) { message = g_strdup_printf ( _("An older file with the same name already exists in \"%s\"."), dest_dir_name); } else if (src_mtime < dest_mtime) { message = g_strdup_printf ( _("A newer file with the same name already exists in \"%s\"."), dest_dir_name); } else { message = g_strdup_printf ( _("Another file with the same name already exists in \"%s\"."), dest_dir_name); } } secondary_text = g_strdup_printf ("%s\n%s", message, message_extra); g_free (message); label = gtk_label_new (primary_text); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (details->titles_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); attr_list = pango_attr_list_new (); pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_LARGE)); g_object_set (label, "attributes", attr_list, NULL); pango_attr_list_unref (attr_list); label = gtk_label_new (secondary_text); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (details->titles_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (primary_text); g_free (secondary_text); /* Set up file icons */ pixbuf = nautilus_file_get_icon_pixbuf (dest, NAUTILUS_ICON_SIZE_LARGE, TRUE, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); details->dest_image = gtk_image_new_from_pixbuf (pixbuf); gtk_box_pack_start (GTK_BOX (details->first_hbox), details->dest_image, FALSE, FALSE, 0); gtk_widget_show (details->dest_image); g_object_unref (pixbuf); pixbuf = nautilus_file_get_icon_pixbuf (src, NAUTILUS_ICON_SIZE_LARGE, TRUE, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); details->src_image = gtk_image_new_from_pixbuf (pixbuf); gtk_box_pack_start (GTK_BOX (details->second_hbox), details->src_image, FALSE, FALSE, 0); gtk_widget_show (details->src_image); g_object_unref (pixbuf); /* Set up labels */ label = gtk_label_new (NULL); date = nautilus_file_get_string_attribute (dest, "date_modified"); size = nautilus_file_get_string_attribute (dest, "size"); if (should_show_type) { type = nautilus_file_get_string_attribute (dest, "type"); } str = g_string_new (NULL); g_string_append_printf (str, "<b>%s</b>\n", _("Original file")); g_string_append_printf (str, "<i>%s</i> %s\n", _("Size:"), size); if (should_show_type) { g_string_append_printf (str, "<i>%s</i> %s\n", _("Type:"), type); } g_string_append_printf (str, "<i>%s</i> %s", _("Last modified:"), date); label_text = str->str; gtk_label_set_markup (GTK_LABEL (label), label_text); gtk_box_pack_start (GTK_BOX (details->first_hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (size); g_free (type); g_free (date); g_string_erase (str, 0, -1); /* Second label */ label = gtk_label_new (NULL); date = nautilus_file_get_string_attribute (src, "date_modified"); size = nautilus_file_get_string_attribute (src, "size"); if (should_show_type) { type = nautilus_file_get_string_attribute (src, "type"); } g_string_append_printf (str, "<b>%s</b>\n", _("Replace with")); g_string_append_printf (str, "<i>%s</i> %s\n", _("Size:"), size); if (should_show_type) { g_string_append_printf (str, "<i>%s</i> %s\n", _("Type:"), type); } g_string_append_printf (str, "<i>%s</i> %s", _("Last modified:"), date); label_text = g_string_free (str, FALSE); gtk_label_set_markup (GTK_LABEL (label), label_text); gtk_box_pack_start (GTK_BOX (details->second_hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (size); g_free (date); g_free (type); g_free (label_text); /* Populate the entry */ edit_name = nautilus_file_get_edit_name (dest); details->conflict_name = edit_name; gtk_entry_set_text (GTK_ENTRY (details->entry), edit_name); if (source_is_dir && dest_is_dir) { gtk_button_set_label (GTK_BUTTON (details->replace_button), _("Merge")); } nautilus_file_monitor_add (src, fcd, NAUTILUS_FILE_ATTRIBUTES_FOR_ICON); nautilus_file_monitor_add (dest, fcd, NAUTILUS_FILE_ATTRIBUTES_FOR_ICON); details->src_handler_id = g_signal_connect (src, "changed", G_CALLBACK (file_icons_changed), fcd); details->dest_handler_id = g_signal_connect (dest, "changed", G_CALLBACK (file_icons_changed), fcd); }