예제 #1
0
void create_win_pho_gui_simple()
{
//  dbg("create_win_pho .....\n");

  if (top_bin)
    return;

  GtkWidget *vbox_top = gtk_vbox_new (FALSE, 0);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL);

  GtkWidget *event_box_pho;
  if (gtab_in_area_button)
	event_box_pho = gtk_button_new();
  else {
	event_box_pho = gtk_event_box_new();
	gtk_event_box_set_visible_window (GTK_EVENT_BOX(event_box_pho), FALSE);
  }

  gtk_container_set_border_width (GTK_CONTAINER (event_box_pho), 0);

  if (hime_inner_frame) {
    GtkWidget *frame = top_bin = gtk_frame_new(NULL);
    gtk_container_set_border_width (GTK_CONTAINER (frame), 0);
    gtk_container_add (GTK_CONTAINER(gwin_pho), frame);
    gtk_container_add (GTK_CONTAINER (frame), vbox_top);
    gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
  } else {
    gtk_container_add (GTK_CONTAINER(gwin_pho), vbox_top);
    top_bin = vbox_top;
  }


  GtkWidget *align = gtk_alignment_new (0, 0, 0, 0);
  label_pho_sele = gtk_label_new(NULL);

  if (!pho_in_row1) {
    gtk_box_pack_start (GTK_BOX (vbox_top), align, FALSE, FALSE, 0);
    gtk_container_add (GTK_CONTAINER (align), label_pho_sele);
  } else {
    GtkWidget *hbox_row1 = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), hbox_row1, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox_row1), event_box_pho, FALSE, FALSE, 0);

    gtk_box_pack_start (GTK_BOX (hbox_row1), align, FALSE, FALSE, 0);
    gtk_container_add (GTK_CONTAINER (align), label_pho_sele);
  }


  hbox_row2 = gtk_hbox_new (FALSE, 0);
  /* This packs the button into the gwin_pho (a gtk container). */
  gtk_container_add (GTK_CONTAINER (vbox_top), hbox_row2);
  label_full = gtk_label_new(_("全"));
  gtk_container_add (GTK_CONTAINER (hbox_row2), label_full);


  if (!pho_in_row1)
    gtk_box_pack_start (GTK_BOX (hbox_row2), event_box_pho, FALSE, FALSE, 0);

  g_signal_connect(G_OBJECT(event_box_pho),"button-press-event",
                   G_CALLBACK(mouse_button_callback), NULL);


  label_pho = gtk_label_new(NULL);

  GtkWidget *frame_pho;
  if (gtab_in_area_button) {
	gtk_container_add (GTK_CONTAINER (event_box_pho), label_pho);
  }
  else {
	frame_pho = gtk_frame_new(NULL);
	gtk_frame_set_shadow_type(GTK_FRAME(frame_pho), GTK_SHADOW_OUT);
	gtk_container_add (GTK_CONTAINER (event_box_pho), frame_pho);
	gtk_container_set_border_width (GTK_CONTAINER (frame_pho), 0);
	gtk_container_add (GTK_CONTAINER (frame_pho), label_pho);
  }

#if 0
  if (left_right_button_tips) {
#if GTK_CHECK_VERSION(2,12,0)
    gtk_widget_set_tooltip_text (event_box_pho, _("左鍵符號,右鍵設定"));
#else
    GtkTooltips *button_gtab_tips = gtk_tooltips_new ();
    gtk_tooltips_set_tip (GTK_TOOLTIPS (button_gtab_tips), event_box_pho, _("左鍵符號,右鍵設定"),NULL);
#endif
  }
#endif

  label_key_codes  = gtk_label_new(NULL);
  gtk_label_set_selectable(GTK_LABEL(label_key_codes), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox_row2), label_key_codes, FALSE, FALSE, 2);

  change_pho_font_size();

  gtk_widget_show_all (gwin_pho);

  gtk_widget_hide(label_key_codes);

  gtk_widget_hide(label_full);
}
예제 #2
0
static void
add_route_row (CEPageIP6   *page,
               const gchar *address,
               gint         prefix,
               const gchar *gateway,
               gint         metric)
{
        GtkWidget *row;
        GtkWidget *row_grid;
        GtkWidget *label;
        GtkWidget *widget;
        GtkWidget *delete_button;
        GtkWidget *image;

        row = gtk_list_box_row_new ();

        row_grid = gtk_grid_new ();
        label = gtk_label_new (_("Address"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "address", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), address);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);

        label = gtk_label_new (_("Prefix"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "prefix", widget);
        if (prefix > 0) {
                gchar *s = g_strdup_printf ("%d", prefix);
                gtk_entry_set_text (GTK_ENTRY (widget), s);
                g_free (s);
        }
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);

        label = gtk_label_new (_("Gateway"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "gateway", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), gateway);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);

        /* Translators: Please see https://en.wikipedia.org/wiki/Metrics_(networking) */
        label = gtk_label_new (C_("network parameters", "Metric"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 4, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "metric", widget);
        if (metric > 0) {
                gchar *s = g_strdup_printf ("%d", metric);
                gtk_entry_set_text (GTK_ENTRY (widget), s);
                g_free (s);
        }
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 4, 1, 1);

        delete_button = gtk_button_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
        g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page);
        image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
        atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Route"));
        gtk_button_set_image (GTK_BUTTON (delete_button), image);
        gtk_widget_set_halign (delete_button, GTK_ALIGN_CENTER);
        gtk_widget_set_valign (delete_button, GTK_ALIGN_CENTER);
        gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 1, 1, 4);
        g_object_set_data (G_OBJECT (row), "delete-button", delete_button);

        gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
        gtk_widget_set_margin_left (row_grid, 10);
        gtk_widget_set_margin_right (row_grid, 10);
        gtk_widget_set_margin_top (row_grid, 10);
        gtk_widget_set_margin_bottom (row_grid, 10);
        gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);

        gtk_container_add (GTK_CONTAINER (row), row_grid);
        gtk_widget_show_all (row);
        gtk_container_add (GTK_CONTAINER (page->routes_list), row);

        update_row_sensitivity (page, page->routes_list);
}
/* Add notification action */
void
add_notification_action(GtkWindow *nw, const char *text, const char *key,
						ActionInvokedCb cb)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	GtkWidget *label;
	GtkWidget *button;
	GtkWidget *hbox;
	GdkPixbuf *pixbuf;
	char *buf;

	g_assert(windata != NULL);

	if (!GTK_WIDGET_VISIBLE(windata->actions_box))
	{
		GtkWidget *alignment;

		gtk_widget_show(windata->actions_box);
		update_content_hbox_visibility(windata);

		alignment = gtk_alignment_new(1, 0.5, 0, 0);
		gtk_widget_show(alignment);
		gtk_box_pack_end(GTK_BOX(windata->actions_box), alignment,
						   FALSE, TRUE, 0);

		windata->pie_countdown = gtk_drawing_area_new();
		gtk_widget_show(windata->pie_countdown);
		gtk_container_add(GTK_CONTAINER(alignment), windata->pie_countdown);
		gtk_widget_set_size_request(windata->pie_countdown,
									PIE_WIDTH, PIE_HEIGHT);
		g_signal_connect(G_OBJECT(windata->pie_countdown), "expose_event",
						 G_CALLBACK(countdown_expose_cb), windata);
	}

	button = gtk_button_new();
	gtk_widget_show(button);
	gtk_box_pack_start(GTK_BOX(windata->actions_box), button, FALSE, FALSE, 0);

	hbox = gtk_hbox_new(FALSE, 6);
	gtk_widget_show(hbox);
	gtk_container_add(GTK_CONTAINER(button), hbox);

	/* Try to be smart and find a suitable icon. */
	buf = g_strdup_printf("stock_%s", key);
	pixbuf = gtk_icon_theme_load_icon(
		gtk_icon_theme_get_for_screen(
			gdk_drawable_get_screen(GTK_WIDGET(nw)->window)),
		buf, 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
	g_free(buf);

	if (pixbuf != NULL)
	{
		GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf);
		gtk_widget_show(image);
		gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
		gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.5);
	}

	label = gtk_label_new(NULL);
	gtk_widget_show(label);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	buf = g_strdup_printf("<small>%s</small>", text);
	gtk_label_set_markup(GTK_LABEL(label), buf);
	g_free(buf);

	g_object_set_data(G_OBJECT(button), "_nw", nw);
	g_object_set_data_full(G_OBJECT(button),
						   "_action_key", g_strdup(key), g_free);
	g_signal_connect(G_OBJECT(button), "button-release-event",
					 G_CALLBACK(action_clicked_cb), cb);
}
void window_signal_init(void)	{

//	FILE *standard_song = fopen("/home/pi/gtk_drawing/standard_song", "r");
//	if(standard_song!=NULL)	{
//		fgets(music_path, MAX_PATH_LENGTH, standard_song);
//		fclose(standard_song);
//	}

	system("rm /tmp/cmd");
	system("mkfifo /tmp/cmd");
	
	/* uart initialisation and sound and so on must be included!
	+ this file must be configurable (speed and so on) */
	

	// set raspberry pi's uart
	system("sudo stty -onlcr -onlret -olcuc -ocrnl -echo 9600 -F /dev/ttyAMA0");
	//fprintf(uart, "Draw Area:\nWidth: %d, Height: %d", DRAW_AREA_WIDTH, DRAW_AREA_HEIGHT);

	// open the uart
	//uart = fopen("/dev/ttyUSB0", "r+"); // read and write!
	//if(uart==NULL)	{
//		g_print("Error could not open UART /dev/ttyAMA0\n");
//	}

	//define some colors
	// colors have to get allocated with gtk_collormap_alloc()
	red.red = 65535;
	red.blue = 0;
	red.green = 0;

	gdk_color_parse("black", &black);

	green.green = 40000;
	green.blue = 0;
	green.red = 0;

	// initalization of controls 

	image_volume_on = gtk_image_new_from_file("/home/pi/gtk_drawing/lautsprecher_mit.png");
	image_volume_off = gtk_image_new_from_file("/home/pi/gtk_drawing/lautsprecher_ohne.png");

	fixed_top = gtk_fixed_new();

	adj_volume = gtk_adjustment_new(VSCROLL_VOLUME_MAX-VSCROLL_VOLUME_INIT, 0, VSCROLL_VOLUME_MAX, 1, 1, 1);

	vscroll_volume = gtk_vscrollbar_new(GTK_ADJUSTMENT(adj_volume));
	g_signal_connect(G_OBJECT(vscroll_volume), "value-changed", G_CALLBACK(vscroll_volume_value_changed), NULL);

	cmd_pause = gtk_button_new_with_label("Pause");
	g_signal_connect(G_OBJECT(cmd_pause), "clicked", G_CALLBACK(cmd_pause_clicked), NULL);

	cmd_stop = gtk_button_new_with_label("Stop");
	g_signal_connect(G_OBJECT(cmd_stop), "clicked", G_CALLBACK(cmd_stop_clicked), NULL);

	cmd_mute = gtk_button_new(); // new label because of image!
	mute = FALSE;
	gtk_button_set_image(GTK_BUTTON(cmd_mute), image_volume_on);
	g_signal_connect(G_OBJECT(cmd_mute), "clicked", G_CALLBACK(cmd_mute_clicked), NULL);

	lbl_music_file = gtk_label_new("");
	gtk_misc_set_alignment(GTK_MISC(lbl_music_file), 0, 0.5);

	window_signal = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(window_signal), 3);
	gtk_window_set_default_size(GTK_WINDOW(window_signal), SCREENX, SCREENY);
	//g_signal_connect(G_OBJECT(window_signal), "destroy", G_CALLBACK(destroy), NULL);
	//gdk_window_set_cursor(GDK_WINDOW(window), GDK_BLANK_CURSOR);
	// gdk_window is needed, but we have gtk_window -> how to get gtk_window's gdk_window?
	
	draw_area = gtk_drawing_area_new();
	g_signal_connect (G_OBJECT (draw_area), "expose_event",
                    G_CALLBACK (expose_event_callback), NULL);
	
	// include controls 
	
	gtk_widget_set_size_request(cmd_pause, CMD_PAUSE_WIDTH, BUTTON_HEIGHT);
	gtk_widget_set_size_request(cmd_stop, CMD_STOP_WIDTH, BUTTON_HEIGHT);
	gtk_widget_set_size_request(vscroll_volume, BUTTON_HEIGHT, VSCROLL_VOLUME_HEIGHT);
	gtk_widget_set_size_request(cmd_mute, CMD_MUTE_WIDTH, BUTTON_HEIGHT);
	gtk_widget_set_size_request(draw_area, DRAW_AREA_WIDTH, DRAW_AREA_HEIGHT);
	gtk_widget_set_size_request(lbl_music_file, LBL_MUSIC_WIDTH, LBL_MUSIC_HEIGHT);

	gtk_fixed_put(GTK_FIXED(fixed_top), lbl_music_file, LBL_MUSIC_POSX, LBL_MUSIC_POSY);
	gtk_fixed_put(GTK_FIXED(fixed_top), cmd_pause, LEFT_SPACE, TOP_SPACE);
	gtk_fixed_put(GTK_FIXED(fixed_top), cmd_stop, CMD_STOP_POSX, TOP_SPACE);
	//gtk_fixed_put(GTK_FIXED(fixed_top), vscroll_volume, VSCROLL_VOLUME_POSX, VSCROLL_VOLUME_POSY);
	gtk_fixed_put(GTK_FIXED(fixed_top), cmd_mute, CMD_MUTE_POSX, TOP_SPACE);
	gtk_fixed_put(GTK_FIXED(fixed_top), draw_area, DRAW_AREA_POSX, DRAW_AREA_POSY);
		
	gtk_container_add(GTK_CONTAINER(window_signal), fixed_top);
	

	
	
	//
	//g_print("thread uart_received started\n");
	//pthread_t thread_uart;
	//pthread_create(&thread_uart, NULL, &uart_receive, NULL);

	//change_volume(volume);

	/* is this needed:?*/
	
	/*while(gtk_events_pending())	{
		gtk_main_iteration();
	}*/


}
예제 #5
0
void update_onscreen_w_ranges()
{
	GtkWidget *container = NULL;
	static GtkWidget *table = NULL;
	GtkWidget *dummy = NULL;
	GtkWidget *label = NULL;
	GtkWidget *button = NULL;
	GtkWidget *img = NULL;
	GtkAdjustment *adj = NULL;
	guint i = 0;
	gint y = 1;
	gfloat low = 0.0;
	gfloat high = 0.0;
	MtxWarningRange *range = NULL;
	GArray * array = NULL;

	if ((!toplevel) || (!GTK_IS_WIDGET(gauge)))
		return;
	array = (GArray *)mtx_gauge_face_get_warning_ranges(MTX_GAUGE_FACE(gauge));
	container = GTK_WIDGET (gtk_builder_get_object(toplevel,"warning_range_viewport"));
	if (!GTK_IS_WIDGET(container))
	{
		printf("color range viewport invalid!!\n");
		return;
	}
	y=1;
	if (GTK_IS_WIDGET(table))
		gtk_widget_destroy(table);

	table = gtk_table_new(2,7,FALSE);
	gtk_container_add(GTK_CONTAINER(container),table);
	if (array->len > 0)
	{
		/* Create headers */
		label = gtk_label_new("Low");
		gtk_table_attach(GTK_TABLE(table),label,1,2,0,1,GTK_EXPAND,GTK_SHRINK,0,0);
		label = gtk_label_new("High");
		gtk_table_attach(GTK_TABLE(table),label,2,3,0,1,GTK_EXPAND,GTK_SHRINK,0,0);
		label = gtk_label_new("Inset");
		gtk_table_attach(GTK_TABLE(table),label,3,4,0,1,GTK_EXPAND,GTK_SHRINK,0,0);
		label = gtk_label_new("LWidth");
		gtk_table_attach(GTK_TABLE(table),label,4,5,0,1,GTK_EXPAND,GTK_SHRINK,0,0);
		label = gtk_label_new("Day Color");
		gtk_table_attach(GTK_TABLE(table),label,5,6,0,1,GTK_EXPAND,GTK_SHRINK,0,0);
		label = gtk_label_new("Night Color");
		gtk_table_attach(GTK_TABLE(table),label,6,7,0,1,GTK_EXPAND,GTK_SHRINK,0,0);
	}
	/* Repopulate the table with the current ranges... */
	for (i=0;i<array->len; i++)
	{
		range = g_array_index(array,MtxWarningRange *, i);
		button = gtk_button_new();
		img = gtk_image_new_from_stock("gtk-close",GTK_ICON_SIZE_MENU);
		gtk_container_add(GTK_CONTAINER(button),img);
		OBJ_SET((button),"range_index",GINT_TO_POINTER(i));
		g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(remove_w_range),NULL);
		gtk_table_attach(GTK_TABLE(table),button,0,1,y,y+1,(GtkAttachOptions)0,(GtkAttachOptions)0,0,0);
		mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), LBOUND, &low);
		mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), UBOUND, &high);
		dummy = gtk_spin_button_new_with_range(low,high,(high-low)/100);
		OBJ_SET(dummy,"index",GINT_TO_POINTER(i));
		gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->lowpoint);
		g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_LOWPOINT));

		gtk_table_attach(GTK_TABLE(table),dummy,1,2,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0);

		dummy = gtk_spin_button_new_with_range(low,high,(high-low)/100);
		OBJ_SET(dummy,"index",GINT_TO_POINTER(i));
		gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->highpoint);
		g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_HIGHPOINT));
		gtk_table_attach(GTK_TABLE(table),dummy,2,3,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0);
		dummy = gtk_spin_button_new_with_range(0,1,0.001);
		OBJ_SET(dummy,"index",GINT_TO_POINTER(i));
		gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->inset);
		g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_INSET));
		gtk_table_attach(GTK_TABLE(table),dummy,3,4,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0);

		dummy = gtk_spin_button_new_with_range(0,1,0.001);
		OBJ_SET(dummy,"index",GINT_TO_POINTER(i));
		gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->lwidth);
		g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_LWIDTH));
		gtk_table_attach(GTK_TABLE(table),dummy,4,5,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0);

		dummy = gtk_color_button_new_with_color(&range->color[MTX_DAY]);
		OBJ_SET(dummy,"index",GINT_TO_POINTER(i));
		g_signal_connect(G_OBJECT(dummy),"color_set", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_COLOR_DAY));

		gtk_table_attach(GTK_TABLE(table),dummy,5,6,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0);

		dummy = gtk_color_button_new_with_color(&range->color[MTX_NITE]);
		OBJ_SET(dummy,"index",GINT_TO_POINTER(i));
		g_signal_connect(G_OBJECT(dummy),"color_set", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_COLOR_NITE));

		gtk_table_attach(GTK_TABLE(table),dummy,6,7,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0);
		y++;
	}
	/* Scroll to end */
	dummy = GTK_WIDGET (gtk_builder_get_object(toplevel,"crange_swin"));
	adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(dummy));
	gtk_adjustment_set_value(adj,gtk_adjustment_get_upper(adj));
	gtk_widget_show_all(container);
}
예제 #6
0
void create_TextSourceDialog (void)
{
    GtkWidget *TextSourceDialog;
    GtkWidget *dialog_vbox10;
    GtkWidget *table7;
    GtkWidget *label193;
    GtkWidget *TextSourceMenu;
    GtkWidget *menu17;
    GtkWidget *text_entry_dialog1;
    GtkWidget *timed_from_file1;
    GtkWidget *file_with_queued_dialog1;
    GtkWidget *label194;
    GtkWidget *hbox103;
    GtkWidget *TextFileEntry;
    GtkWidget *FileBrowseButton;
    GtkWidget *alignment27;
    GtkWidget *hbox104;
    GtkWidget *image33;
    GtkWidget *label195;
    GtkWidget *dialog_action_area9;
    GtkWidget *cancelbutton7;
    GtkWidget *okbutton9;

    TextSourceDialog = gtk_dialog_new();
    gtk_window_set_title(GTK_WINDOW(TextSourceDialog), _("Text Source"));
    gtk_window_set_modal(GTK_WINDOW(TextSourceDialog), TRUE);

    dialog_vbox10 = GTK_DIALOG(TextSourceDialog)->vbox;
    gtk_widget_show(dialog_vbox10);

    table7 = gtk_table_new(2, 2, FALSE);
    gtk_widget_show(table7);
    gtk_box_pack_start(GTK_BOX(dialog_vbox10), table7, TRUE, TRUE, 2);
    gtk_table_set_row_spacings(GTK_TABLE(table7), 9);
    gtk_table_set_col_spacings(GTK_TABLE(table7), 17);

    label193 = gtk_label_new(_("Text Source:"));
    gtk_widget_show(label193);
    gtk_table_attach(GTK_TABLE(table7), label193, 0, 1, 0, 1,
                     (GtkAttachOptions)(GTK_FILL),
                     (GtkAttachOptions)(0), 0, 0);
    gtk_misc_set_alignment(GTK_MISC(label193), 0, 0.5);

    TextSourceMenu = gtk_option_menu_new();
    gtk_widget_show(TextSourceMenu);
    gtk_table_attach(GTK_TABLE(table7), TextSourceMenu, 1, 2, 0, 1,
                     (GtkAttachOptions)(GTK_FILL),
                     (GtkAttachOptions)(0), 0, 0);

    menu17 = gtk_menu_new();

    text_entry_dialog1 = gtk_menu_item_new_with_mnemonic(_("Dialog with Text Entry"));
    gtk_widget_show(text_entry_dialog1);
    gtk_container_add(GTK_CONTAINER(menu17), text_entry_dialog1);

    timed_from_file1 = gtk_menu_item_new_with_mnemonic(_("File with Timing Info"));
    gtk_widget_show(timed_from_file1);
    gtk_container_add(GTK_CONTAINER(menu17), timed_from_file1);

    file_with_queued_dialog1 = gtk_menu_item_new_with_mnemonic(_("Dialog Using File"));
    gtk_widget_show(file_with_queued_dialog1);
    gtk_container_add(GTK_CONTAINER(menu17), file_with_queued_dialog1);

    gtk_option_menu_set_menu(GTK_OPTION_MENU(TextSourceMenu), menu17);

    label194 = gtk_label_new(_("File:"));
    gtk_widget_show(label194);
    gtk_table_attach(GTK_TABLE(table7), label194, 0, 1, 1, 2,
                     (GtkAttachOptions)(GTK_FILL),
                     (GtkAttachOptions)(0), 0, 0);
    gtk_misc_set_alignment(GTK_MISC(label194), 0, 0.5);

    hbox103 = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox103);
    gtk_table_attach(GTK_TABLE(table7), hbox103, 1, 2, 1, 2,
                     (GtkAttachOptions)(GTK_FILL),
                     (GtkAttachOptions)(GTK_FILL), 0, 0);

    TextFileEntry = gtk_entry_new();
    gtk_widget_show(TextFileEntry);
    gtk_box_pack_start(GTK_BOX(hbox103), TextFileEntry, TRUE, TRUE, 0);

    FileBrowseButton = gtk_button_new();
    gtk_widget_show(FileBrowseButton);
    gtk_box_pack_start(GTK_BOX(hbox103), FileBrowseButton, FALSE, FALSE, 0);

    alignment27 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment27);
    gtk_container_add(GTK_CONTAINER(FileBrowseButton), alignment27);

    hbox104 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox104);
    gtk_container_add(GTK_CONTAINER(alignment27), hbox104);

    image33 = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image33);
    gtk_box_pack_start(GTK_BOX(hbox104), image33, FALSE, FALSE, 0);

    label195 = gtk_label_new_with_mnemonic(_("Browse"));
    gtk_widget_show(label195);
    gtk_box_pack_start(GTK_BOX(hbox104), label195, FALSE, FALSE, 0);

    dialog_action_area9 = GTK_DIALOG(TextSourceDialog)->action_area;
    gtk_widget_show(dialog_action_area9);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area9), GTK_BUTTONBOX_END);

    cancelbutton7 = gtk_button_new_from_stock("gtk-cancel");
    gtk_widget_show(cancelbutton7);
    gtk_dialog_add_action_widget(GTK_DIALOG(TextSourceDialog), cancelbutton7, GTK_RESPONSE_CANCEL);
    GTK_WIDGET_SET_FLAGS(cancelbutton7, GTK_CAN_DEFAULT);

    okbutton9 = gtk_button_new_from_stock("gtk-ok");
    gtk_widget_show(okbutton9);
    gtk_dialog_add_action_widget(GTK_DIALOG(TextSourceDialog), okbutton9, GTK_RESPONSE_OK);
    GTK_WIDGET_SET_FLAGS(okbutton9, GTK_CAN_DEFAULT);

    g_signal_connect((gpointer) TextSourceDialog, "response",
                     G_CALLBACK(on_TextSourceDialog_response),
                     NULL);
    g_signal_connect((gpointer) TextSourceMenu, "changed",
                     G_CALLBACK(on_TextSourceMenu_changed),
                     TextSourceDialog);
    g_signal_connect((gpointer) FileBrowseButton, "clicked",
                     G_CALLBACK(on_FileBrowseButton_clicked),
                     TextSourceDialog);

    /* Store pointers to all widgets, for use by lookup_widget(). */
    GLADE_HOOKUP_OBJECT_NO_REF(TextSourceDialog, TextSourceDialog, "TextSourceDialog");
    GLADE_HOOKUP_OBJECT_NO_REF(TextSourceDialog, dialog_vbox10, "dialog_vbox10");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, table7, "table7");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, label193, "label193");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, TextSourceMenu, "TextSourceMenu");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, menu17, "menu17");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, text_entry_dialog1, "text_entry_dialog1");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, timed_from_file1, "timed_from_file1");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, file_with_queued_dialog1, "file_with_queued_dialog1");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, label194, "label194");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, hbox103, "hbox103");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, TextFileEntry, "TextFileEntry");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, FileBrowseButton, "FileBrowseButton");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, alignment27, "alignment27");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, hbox104, "hbox104");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, image33, "image33");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, label195, "label195");
    GLADE_HOOKUP_OBJECT_NO_REF(TextSourceDialog, dialog_action_area9, "dialog_action_area9");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, cancelbutton7, "cancelbutton7");
    GLADE_HOOKUP_OBJECT(TextSourceDialog, okbutton9, "okbutton9");

    const char *type = MyConfig->GetStringValue(CONFIG_TEXT_SOURCE_TYPE);
    uint index = 0;
    if (strcmp(type, TEXT_SOURCE_TIMED_FILE) == 0) {
        index = 1;
    } else if (strcmp(type, TEXT_SOURCE_DIALOG) == 0) {
        index = 0;
    } else if (strcmp(type, TEXT_SOURCE_FILE_WITH_DIALOG) == 0) {
        index = 2;
    }
    gtk_option_menu_set_history(GTK_OPTION_MENU(TextSourceMenu), index);
    const char *file = MyConfig->GetStringValue(CONFIG_TEXT_SOURCE_FILE_NAME);
    if (file != NULL) {
        gtk_entry_set_text(GTK_ENTRY(TextFileEntry), file);
    }
    EnableFromTextMenu(TextSourceDialog, index);
    gtk_widget_show(TextSourceDialog);
}
예제 #7
0
static void
build_dialog_ui (GtkAppChooserDialog *self)
{
  GtkWidget *vbox;
  GtkWidget *vbox2;
  GtkWidget *label;
  GtkWidget *button, *w;

  gtk_container_set_border_width (GTK_CONTAINER (self), 5);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0);
  gtk_widget_show (vbox2);

  self->priv->label = gtk_label_new ("");
  gtk_misc_set_alignment (GTK_MISC (self->priv->label), 0, 0.5);
  gtk_label_set_line_wrap (GTK_LABEL (self->priv->label), TRUE);
  gtk_box_pack_start (GTK_BOX (vbox2), self->priv->label,
                      FALSE, FALSE, 0);
  gtk_widget_show (self->priv->label);

  self->priv->app_chooser_widget =
    gtk_app_chooser_widget_new (self->priv->content_type);
  gtk_box_pack_start (GTK_BOX (vbox2), self->priv->app_chooser_widget, TRUE, TRUE, 0);
  gtk_widget_show (self->priv->app_chooser_widget);

  g_signal_connect (self->priv->app_chooser_widget, "application-selected",
                    G_CALLBACK (widget_application_selected_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "application-activated",
                    G_CALLBACK (widget_application_activated_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "notify::show-other",
                    G_CALLBACK (widget_notify_for_button_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "populate-popup",
                    G_CALLBACK (widget_populate_popup_cb), self);

  button = gtk_button_new_with_label (_("Show other applications"));
  self->priv->show_more_button = button;
  w = gtk_image_new_from_stock (GTK_STOCK_ADD,
                                GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (button), w);
  gtk_box_pack_start (GTK_BOX (self->priv->app_chooser_widget), button, FALSE, FALSE, 6);
  gtk_widget_show_all (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (show_more_button_clicked_cb), self);

  gtk_dialog_add_button (GTK_DIALOG (self),
                         GTK_STOCK_CANCEL,
                         GTK_RESPONSE_CANCEL);

  /* Create a custom stock icon */
  self->priv->button = gtk_button_new ();

  label = gtk_label_new_with_mnemonic (_("_Select"));
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (self->priv->button));
  gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
  gtk_widget_show (label);
  self->priv->open_label = label;

  gtk_container_add (GTK_CONTAINER (self->priv->button),
                     self->priv->open_label);

  gtk_widget_show (self->priv->button);
  gtk_widget_set_can_default (self->priv->button, TRUE);

  gtk_dialog_add_action_widget (GTK_DIALOG (self),
                                self->priv->button, GTK_RESPONSE_OK);

  gtk_dialog_set_default_response (GTK_DIALOG (self),
                                   GTK_RESPONSE_OK);
}
예제 #8
0
static GtkWidget *create_window(void)
{
    stwidgets.accel_group = gtk_accel_group_new();

    // Basic window
    stwidgets.startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), apptitle);	// NOTE: use global app title
    gtk_window_set_position(GTK_WINDOW(stwidgets.startwin), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable(GTK_WINDOW(stwidgets.startwin), FALSE);
    gtk_window_set_type_hint(GTK_WINDOW(stwidgets.startwin), GDK_WINDOW_TYPE_HINT_DIALOG);

    // Horizontal layout of banner and controls
    stwidgets.hlayout = gtk_hbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(stwidgets.startwin), stwidgets.hlayout);

    // banner
    {
        GdkPixbuf *pixbuf = load_banner();
        stwidgets.banner = gtk_image_new_from_pixbuf(pixbuf);
        g_object_unref((gpointer)pixbuf);
    }
    gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.banner, FALSE, FALSE, 0);
    gtk_misc_set_alignment(GTK_MISC(stwidgets.banner), 0.5, 0);

    // Vertical layout of tab control and start+cancel buttons
    stwidgets.vlayout = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.vlayout, TRUE, TRUE, 0);

    // Tab control
    stwidgets.tabs = gtk_notebook_new();
    gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.tabs, TRUE, TRUE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4);

    // layout table of config page
	stwidgets.configtlayout = gtk_table_new(4, 3, FALSE);
	gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout);

    // 2D video mode label
    stwidgets.vmode2dlabel = gtk_label_new_with_mnemonic("_2D Video mode:");
    gtk_misc_set_alignment (GTK_MISC(stwidgets.vmode2dlabel), 0.3, 0);
    gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 6);
    
    // 2D video mode combo
    {
        GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
        GtkCellRenderer *cell;

        stwidgets.vmode2dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
        g_object_unref(G_OBJECT(list));

        cell = gtk_cell_renderer_text_new();
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, FALSE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, "text", 0, NULL);
    }
    gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 6);
    gtk_widget_add_accelerator(stwidgets.vmode2dcombo, "grab_focus", stwidgets.accel_group,
                               GDK_2, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
	
	// Fullscreen checkbox
    stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
    gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.fullscreencheck, 2,3, 0,1, GTK_FILL, 0, 4, 6);
    gtk_widget_add_accelerator(stwidgets.fullscreencheck, "grab_focus", stwidgets.accel_group,
                               GDK_F, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
                               
    // 3D video mode label
    stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_3D Video mode:");
    gtk_misc_set_alignment (GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0);
    gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 1,2, GTK_FILL, 0, 4, 6);

    // 3D video mode combo
    {
        GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
        GtkCellRenderer *cell;

        stwidgets.vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
        g_object_unref(G_OBJECT(list));

        cell = gtk_cell_renderer_text_new();
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL);
    }
    gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0);
    gtk_widget_add_accelerator(stwidgets.vmode3dcombo, "grab_focus", stwidgets.accel_group,
                               GDK_3, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
	// Empty horizontal layout
	stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0);
	gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,1, 2,3, 0, GTK_EXPAND | GTK_FILL, 0, 0);
	
    // Always show config checkbox
    stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
    gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,2, 3,4, GTK_FILL, 0, 4, 6);
    gtk_widget_add_accelerator(stwidgets.alwaysshowcheck, "grab_focus", stwidgets.accel_group,
                               GDK_A, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);

    // Configuration tab
    stwidgets.configtab = gtk_label_new("Configuration");
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 0), stwidgets.configtab);

    // Messages scrollable area
    stwidgets.messagesscroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.messagesscroll);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(stwidgets.messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

    // Messages text area
    stwidgets.messagestext = gtk_text_view_new();
    gtk_container_add(GTK_CONTAINER(stwidgets.messagesscroll), stwidgets.messagestext);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(stwidgets.messagestext), GTK_WRAP_WORD);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE);
    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2);
    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2);

    // Messages tab
    stwidgets.messagestab = gtk_label_new("Messages");
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 1), stwidgets.messagestab);

    // Dialogue box buttons layout
    stwidgets.buttons = gtk_hbutton_box_new();
    gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.buttons, FALSE, TRUE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(stwidgets.buttons), 3);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(stwidgets.buttons), GTK_BUTTONBOX_END);

    // Cancel button
    stwidgets.cancelbutton = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.cancelbutton);
    GTK_WIDGET_SET_FLAGS(stwidgets.cancelbutton, GTK_CAN_DEFAULT);
    gtk_widget_add_accelerator(stwidgets.cancelbutton, "grab_focus", stwidgets.accel_group,
                               GDK_C, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(stwidgets.cancelbutton, "clicked", stwidgets.accel_group,
                               GDK_Escape, 0,
                               GTK_ACCEL_VISIBLE);

    stwidgets.cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_container_add(GTK_CONTAINER(stwidgets.cancelbutton), stwidgets.cancelbuttonalign);

    stwidgets.cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
    gtk_container_add(GTK_CONTAINER(stwidgets.cancelbuttonalign), stwidgets.cancelbuttonlayout);

    stwidgets.cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
    gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonicon, FALSE, FALSE, 0);

    stwidgets.cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
    gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonlabel, FALSE, FALSE, 0);

    // Start button
    stwidgets.startbutton = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.startbutton);
    GTK_WIDGET_SET_FLAGS(stwidgets.startbutton, GTK_CAN_DEFAULT);
    gtk_widget_add_accelerator(stwidgets.startbutton, "grab_focus", stwidgets.accel_group,
                               GDK_S, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(stwidgets.startbutton, "clicked", stwidgets.accel_group,
                               GDK_Return, 0,
                               GTK_ACCEL_VISIBLE);

    stwidgets.startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_container_add(GTK_CONTAINER(stwidgets.startbutton), stwidgets.startbuttonalign);

    stwidgets.startbuttonlayout = gtk_hbox_new(FALSE, 2);
    gtk_container_add(GTK_CONTAINER(stwidgets.startbuttonalign), stwidgets.startbuttonlayout);

    stwidgets.startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON);
    gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonicon, FALSE, FALSE, 0);

    stwidgets.startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
    gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonlabel, FALSE, FALSE, 0);

    // Wire up the signals
    g_signal_connect((gpointer) stwidgets.startwin, "delete_event",
                     G_CALLBACK(on_startwin_delete_event),
                     NULL);
    g_signal_connect((gpointer) stwidgets.vmode2dcombo, "changed",
                     G_CALLBACK(on_vmode2dcombo_changed),
                     NULL);
    g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed",
                     G_CALLBACK(on_vmode3dcombo_changed),
                     NULL);
    g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled",
                     G_CALLBACK(on_fullscreencheck_toggled),
                     NULL);
    g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled",
                     G_CALLBACK(on_alwaysshowcheck_toggled),
                     NULL);
    g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked",
                     G_CALLBACK(on_cancelbutton_clicked),
                     NULL);
    g_signal_connect((gpointer) stwidgets.startbutton, "clicked",
                     G_CALLBACK(on_startbutton_clicked),
                     NULL);

    // Associate labels with their controls
    gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode2dlabel), stwidgets.vmode2dcombo);
    gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode3dlabel), stwidgets.vmode3dcombo);

    gtk_window_add_accel_group(GTK_WINDOW(stwidgets.startwin), stwidgets.accel_group);

    return stwidgets.startwin;
}
예제 #9
0
WebkitBrowser::WebkitBrowser(GtkWidget * parent_vbox)
{
  // Save and initialize variables.
  vbox = parent_vbox;
  last_focused_time = 0;

  toolbar = gtk_toolbar_new ();
  gtk_widget_show (toolbar);
  gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH);

  toolitem_back = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_back);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_back);

  button_back = gtk_button_new ();
  gtk_widget_show (button_back);
  gtk_container_add (GTK_CONTAINER (toolitem_back), button_back);

  image_back = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image_back);
  gtk_container_add (GTK_CONTAINER (button_back), image_back);

  toolitem_forward = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_forward);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_forward);

  button_forward = gtk_button_new ();
  gtk_widget_show (button_forward);
  gtk_container_add (GTK_CONTAINER (toolitem_forward), button_forward);

  image_forward = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image_forward);
  gtk_container_add (GTK_CONTAINER (button_forward), image_forward);

  toolitem_refresh = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_refresh);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_refresh);

  button_refresh = gtk_button_new ();
  gtk_widget_show (button_refresh);
  gtk_container_add (GTK_CONTAINER (toolitem_refresh), button_refresh);

  image_refresh = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image_refresh);
  gtk_container_add (GTK_CONTAINER (button_refresh), image_refresh);

  toolitem_stop = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_stop);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_stop);

  button_stop = gtk_button_new ();
  gtk_widget_show (button_stop);
  gtk_container_add (GTK_CONTAINER (toolitem_stop), button_stop);

  image_stop = gtk_image_new_from_stock ("gtk-stop", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image_stop);
  gtk_container_add (GTK_CONTAINER (button_stop), image_stop);

  toolitem_home = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_home);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_home);

  button_home = gtk_button_new ();
  gtk_widget_show (button_home);
  gtk_container_add (GTK_CONTAINER (toolitem_home), button_home);
  gtk_button_set_focus_on_click (GTK_BUTTON (button_home), FALSE);

  image_home = gtk_image_new_from_stock ("gtk-home", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image_home);
  gtk_container_add (GTK_CONTAINER (button_home), image_home);

  toolitem_url = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_url);
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem_url), TRUE);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_url);

  entry_url = gtk_entry_new ();
  gtk_widget_show (entry_url);
  gtk_container_add (GTK_CONTAINER (toolitem_url), entry_url);
  gtk_entry_set_invisible_char (GTK_ENTRY (entry_url), 9679);

  toolitem_enter = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem_enter);
  gtk_container_add (GTK_CONTAINER (toolbar), toolitem_enter);

  button_enter = gtk_button_new ();
  gtk_widget_show (button_enter);
  gtk_container_add (GTK_CONTAINER (toolitem_enter), button_enter);

  image_enter = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image_enter);
  gtk_container_add (GTK_CONTAINER (button_enter), image_enter);

  scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow);
  gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_SHADOW_IN);

  webview = webkit_web_view_new();
  gtk_widget_show(webview);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), webview);

  notebook = gtk_notebook_new ();
  gtk_widget_show (notebook);
  gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
  gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);

  label_status = gtk_label_new ("");
  gtk_widget_show (label_status);
  gtk_container_add (GTK_CONTAINER (notebook), label_status);
  gtk_label_set_ellipsize (GTK_LABEL (label_status), PANGO_ELLIPSIZE_MIDDLE);

  progressbar = gtk_progress_bar_new ();
  gtk_widget_show (progressbar);
  gtk_container_add (GTK_CONTAINER (notebook), progressbar);
  gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (progressbar), PANGO_ELLIPSIZE_MIDDLE);

  // Set gui as if loading has finished, so that the sensitivitiy of buttons gets right.
  load_finished (NULL, NULL);

  // Signals.
  g_signal_connect ((gpointer) button_back, "clicked", G_CALLBACK (on_button_back_clicked), gpointer (this));
  g_signal_connect ((gpointer) button_forward, "clicked", G_CALLBACK (on_button_forward_clicked), gpointer (this));
  g_signal_connect ((gpointer) button_refresh, "clicked", G_CALLBACK (on_button_refresh_clicked), gpointer (this));
  g_signal_connect ((gpointer) button_stop, "clicked", G_CALLBACK (on_button_stop_clicked), gpointer (this));
  g_signal_connect ((gpointer) button_home, "clicked", G_CALLBACK (on_button_home_clicked), gpointer (this));
  g_signal_connect ((gpointer) entry_url, "activate", G_CALLBACK (on_entry_url_activate), gpointer (this));
  g_signal_connect ((gpointer) button_enter, "clicked", G_CALLBACK (on_button_enter_clicked), gpointer (this));
  g_signal_connect(G_OBJECT(webview), "grab_focus", G_CALLBACK(on_webview_grab_focus), gpointer(this));
  g_signal_connect (G_OBJECT (webview), "load-committed", G_CALLBACK (load_commit_cb), gpointer(this));
  g_signal_connect (G_OBJECT (webview), "load-started", G_CALLBACK (load_started_cb), gpointer(this));
  g_signal_connect (G_OBJECT (webview), "load-progress-changed", G_CALLBACK (progress_change_cb), gpointer(this));
  g_signal_connect (G_OBJECT (webview), "load-finished", G_CALLBACK (load_finished_cb), gpointer(this));
  g_signal_connect (G_OBJECT (webview), "hovering-over-link", G_CALLBACK (link_hover_cb), gpointer(this));
}
예제 #10
0
GtkWidget*
create_bsv_viewer_pref_dlg (void)
{
  GtkWidget *bsv_viewer_pref_dlg;
  GtkWidget *dialog_vbox1;
  GtkWidget *notebook1;
  GtkWidget *vbox2;
  GtkWidget *hbox19;
  GtkWidget *label3;
  GtkObject *chanperscreen_spinb_adj;
  GtkWidget *chanperscreen_spinb;
  GtkWidget *hbox20;
  GtkWidget *label4;
  GtkObject *hrange_spinb_adj;
  GtkWidget *hrange_spinb;
  GtkWidget *label5;
  GtkWidget *label1;
  GtkWidget *vbox3;
  GtkWidget *hbox21;
  GtkWidget *label6;
  GtkWidget *logfile_entry;
  GtkWidget *button15;
  GtkWidget *image17;
  GtkWidget *hbox22;
  GtkWidget *label7;
  GtkWidget *patid_entry;
  GtkWidget *hbox23;
  GtkWidget *label8;
  GtkWidget *recid_entry;
  GtkWidget *label2;
  GtkWidget *dialog_action_area1;
  GtkWidget *okbutton1;

  bsv_viewer_pref_dlg = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (bsv_viewer_pref_dlg), _("Viewer Preferences"));

  dialog_vbox1 = GTK_DIALOG (bsv_viewer_pref_dlg)->vbox;
  gtk_widget_show (dialog_vbox1);

  notebook1 = gtk_notebook_new ();
  gtk_widget_show (notebook1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), notebook1, TRUE, TRUE, 0);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);
  gtk_container_add (GTK_CONTAINER (notebook1), vbox2);

  hbox19 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox19);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox19, FALSE, TRUE, 0);

  label3 = gtk_label_new (_("Channels per Screen: "));
  gtk_widget_show (label3);
  gtk_box_pack_start (GTK_BOX (hbox19), label3, FALSE, FALSE, 0);

  chanperscreen_spinb_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
  chanperscreen_spinb = gtk_spin_button_new (GTK_ADJUSTMENT (chanperscreen_spinb_adj), 1, 0);
  gtk_widget_show (chanperscreen_spinb);
  gtk_box_pack_start (GTK_BOX (hbox19), chanperscreen_spinb, FALSE, TRUE, 0);

  hbox20 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox20);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox20, FALSE, TRUE, 0);

  label4 = gtk_label_new (_("Horizontal Time Range: "));
  gtk_widget_show (label4);
  gtk_box_pack_start (GTK_BOX (hbox20), label4, FALSE, FALSE, 0);

  hrange_spinb_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
  hrange_spinb = gtk_spin_button_new (GTK_ADJUSTMENT (hrange_spinb_adj), 1, 0);
  gtk_widget_show (hrange_spinb);
  gtk_box_pack_start (GTK_BOX (hbox20), hrange_spinb, FALSE, TRUE, 0);

  label5 = gtk_label_new (_(" sec"));
  gtk_widget_show (label5);
  gtk_box_pack_start (GTK_BOX (hbox20), label5, FALSE, FALSE, 0);

  label1 = gtk_label_new (_("Viewer"));
  gtk_widget_show (label1);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label1);

  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox3);
  gtk_container_add (GTK_CONTAINER (notebook1), vbox3);

  hbox21 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox21);
  gtk_box_pack_start (GTK_BOX (vbox3), hbox21, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox21), 2);

  label6 = gtk_label_new (_("GDF Logfile: "));
  gtk_widget_show (label6);
  gtk_box_pack_start (GTK_BOX (hbox21), label6, FALSE, FALSE, 0);

  logfile_entry = gtk_entry_new ();
  gtk_widget_show (logfile_entry);
  gtk_box_pack_start (GTK_BOX (hbox21), logfile_entry, TRUE, TRUE, 0);

  button15 = gtk_button_new ();
  gtk_widget_show (button15);
  gtk_box_pack_start (GTK_BOX (hbox21), button15, FALSE, FALSE, 0);

  image17 = gtk_image_new_from_stock ("gtk-floppy", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image17);
  gtk_container_add (GTK_CONTAINER (button15), image17);

  hbox22 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox22);
  gtk_box_pack_start (GTK_BOX (vbox3), hbox22, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox22), 2);

  label7 = gtk_label_new (_("Patient ID: "));
  gtk_widget_show (label7);
  gtk_box_pack_start (GTK_BOX (hbox22), label7, FALSE, FALSE, 0);

  patid_entry = gtk_entry_new ();
  gtk_widget_show (patid_entry);
  gtk_box_pack_start (GTK_BOX (hbox22), patid_entry, TRUE, TRUE, 0);

  hbox23 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox23);
  gtk_box_pack_start (GTK_BOX (vbox3), hbox23, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox23), 2);

  label8 = gtk_label_new (_("Record ID: "));
  gtk_widget_show (label8);
  gtk_box_pack_start (GTK_BOX (hbox23), label8, FALSE, FALSE, 0);

  recid_entry = gtk_entry_new ();
  gtk_widget_show (recid_entry);
  gtk_box_pack_start (GTK_BOX (hbox23), recid_entry, TRUE, TRUE, 0);

  label2 = gtk_label_new (_("Logfile"));
  gtk_widget_show (label2);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), label2);

  dialog_action_area1 = GTK_DIALOG (bsv_viewer_pref_dlg)->action_area;
  gtk_widget_show (dialog_action_area1);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

  okbutton1 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (bsv_viewer_pref_dlg), okbutton1, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);

  g_signal_connect ((gpointer) bsv_viewer_pref_dlg, "delete_event",
                    G_CALLBACK (update_viewer_settings),
                    NULL);
  g_signal_connect ((gpointer) button15, "clicked",
                    G_CALLBACK (show_fs_dlg),
                    NULL);
  g_signal_connect ((gpointer) okbutton1, "clicked",
                    G_CALLBACK (update_viewer_settings_but),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (bsv_viewer_pref_dlg, bsv_viewer_pref_dlg, "bsv_viewer_pref_dlg");
  GLADE_HOOKUP_OBJECT_NO_REF (bsv_viewer_pref_dlg, dialog_vbox1, "dialog_vbox1");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, notebook1, "notebook1");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, vbox2, "vbox2");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, hbox19, "hbox19");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label3, "label3");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, chanperscreen_spinb, "chanperscreen_spinb");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, hbox20, "hbox20");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label4, "label4");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, hrange_spinb, "hrange_spinb");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label5, "label5");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label1, "label1");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, vbox3, "vbox3");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, hbox21, "hbox21");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label6, "label6");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, logfile_entry, "logfile_entry");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, button15, "button15");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, image17, "image17");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, hbox22, "hbox22");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label7, "label7");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, patid_entry, "patid_entry");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, hbox23, "hbox23");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label8, "label8");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, recid_entry, "recid_entry");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, label2, "label2");
  GLADE_HOOKUP_OBJECT_NO_REF (bsv_viewer_pref_dlg, dialog_action_area1, "dialog_action_area1");
  GLADE_HOOKUP_OBJECT (bsv_viewer_pref_dlg, okbutton1, "okbutton1");

  return bsv_viewer_pref_dlg;
}
예제 #11
0
파일: tweet-window.c 프로젝트: patoh/tweet
static void
tweet_window_init (TweetWindow *window)
{
  TweetWindowPrivate *priv;
  GtkWidget *hbox, *button;

  GTK_WINDOW (window)->type = GTK_WINDOW_TOPLEVEL;
  gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
  gtk_window_set_title (GTK_WINDOW (window), "Tweet");
  gtk_widget_set_size_request (GTK_WIDGET (window), WINDOW_WIDTH, -1);

  window->priv = priv = TWEET_WINDOW_GET_PRIVATE (window);

  priv->vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (window), priv->vbox);
  gtk_widget_show (priv->vbox);

  priv->canvas = gtk_clutter_embed_new ();
  gtk_widget_set_size_request (priv->canvas, CANVAS_WIDTH, CANVAS_HEIGHT);
  gtk_container_add (GTK_CONTAINER (priv->vbox), priv->canvas);
  gtk_widget_show (priv->canvas);

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_box_pack_end (GTK_BOX (priv->vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  priv->entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (hbox), priv->entry, TRUE, TRUE, 0);
  gtk_widget_set_tooltip_text (priv->entry, "Update your status");
  gtk_widget_show (priv->entry);
  g_signal_connect (priv->entry,
                    "activate", G_CALLBACK (on_entry_activate),
                    window);
  g_signal_connect (priv->entry,
                    "changed", G_CALLBACK (on_entry_changed),
                    window);

  priv->counter = gtk_label_new ("<span color='green'>0</span>");
  gtk_label_set_use_markup (GTK_LABEL (priv->counter), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox), priv->counter, FALSE, FALSE, 0);
  gtk_widget_show (priv->counter);

  button = gtk_button_new ();
  gtk_button_set_image (GTK_BUTTON (button),
                        gtk_image_new_from_stock (GTK_STOCK_JUMP_TO,
                                                  GTK_ICON_SIZE_BUTTON));
  gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  gtk_widget_set_sensitive (button, FALSE);
  gtk_widget_show (button);
  g_signal_connect_swapped (button,
                            "clicked", G_CALLBACK (gtk_widget_activate),
                            priv->entry);
  priv->send_button = button;

  priv->status_model = TWEET_STATUS_MODEL (tweet_status_model_new ());

  priv->config = tweet_config_get_default ();
  priv->client = twitter_client_new_for_user (tweet_config_get_username (priv->config),
                                              tweet_config_get_password (priv->config));
  g_signal_connect (priv->client,
                    "status-received", G_CALLBACK (on_status_received),
                    window);
  g_signal_connect (priv->client,
                    "timeline-complete", G_CALLBACK (on_timeline_complete),
                    window);
}
예제 #12
0
GtkWidget*
create_bsv_main_win (void)
{
  GtkWidget *bsv_main_win;
  GtkWidget *vbox1;
  GtkWidget *menubar1;
  GtkWidget *menuitem4;
  GtkWidget *menuitem4_menu;
  GtkWidget *preferences_main;
  GtkWidget *image18;
  GtkWidget *separatormenuitem1;
  GtkWidget *quit1;
  GtkWidget *menuitem5;
  GtkWidget *menuitem5_menu;
  GtkWidget *preferences_driver;
  GtkWidget *image19;
  GtkWidget *information2;
  GtkWidget *handlebox1;
  GtkWidget *toolbar1;
  GtkWidget *start_but;
  GtkWidget *alignment1;
  GtkWidget *hbox24;
  GtkWidget *image20;
  GtkWidget *label10;
  GtkWidget *stop_but;
  GtkWidget *alignment2;
  GtkWidget *hbox25;
  GtkWidget *image21;
  GtkWidget *label11;
  GtkWidget *handlebox2;
  GtkWidget *toolbar2;
  GtkWidget *chansel_combo;
  GtkWidget *combo_entry1;
  GtkWidget *label12;
  GtkObject *mag_spinbut_adj;
  GtkWidget *mag_spinbut;
  GtkWidget *label13;
  GtkWidget *combo1;
  GtkWidget *combo_entry2;
  GtkWidget *apply_but;
  GtkWidget *hbox18;
  GtkWidget *drawingarea;
  GtkWidget *vscrollbar1;
  GtkWidget *statusbar;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  bsv_main_win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (bsv_main_win), _("BSView"));
  gtk_window_set_default_size (GTK_WINDOW (bsv_main_win), 500, 300);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (bsv_main_win), vbox1);

  menubar1 = gtk_menu_bar_new ();
  gtk_widget_show (menubar1);
  gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);

  menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Viewer"));
  gtk_widget_show (menuitem4);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);

  menuitem4_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

  preferences_main = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
  gtk_widget_show (preferences_main);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), preferences_main);

  image18 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
  gtk_widget_show (image18);
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (preferences_main), image18);

  separatormenuitem1 = gtk_menu_item_new ();
  gtk_widget_show (separatormenuitem1);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), separatormenuitem1);
  gtk_widget_set_sensitive (separatormenuitem1, FALSE);

  quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
  gtk_widget_show (quit1);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit1);

  menuitem5 = gtk_menu_item_new_with_mnemonic (_("_Driver"));
  gtk_widget_show (menuitem5);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem5);

  menuitem5_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem5), menuitem5_menu);

  preferences_driver = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
  gtk_widget_show (preferences_driver);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), preferences_driver);

  image19 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
  gtk_widget_show (image19);
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (preferences_driver), image19);

  information2 = gtk_image_menu_item_new_from_stock ("gtk-dialog-info", accel_group);
  gtk_widget_show (information2);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), information2);

  handlebox1 = gtk_handle_box_new ();
  gtk_widget_show (handlebox1);
  gtk_box_pack_start (GTK_BOX (vbox1), handlebox1, FALSE, FALSE, 0);

  toolbar1 = gtk_toolbar_new ();
  gtk_widget_show (toolbar1);
  gtk_container_add (GTK_CONTAINER (handlebox1), toolbar1);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_ICONS);

  start_but = gtk_button_new ();
  gtk_widget_show (start_but);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar1), start_but, _("Start Aquistion"), NULL);

  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (start_but), alignment1);

  hbox24 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox24);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox24);

  image20 = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image20);
  gtk_box_pack_start (GTK_BOX (hbox24), image20, FALSE, FALSE, 0);

  label10 = gtk_label_new_with_mnemonic (_("_Start"));
  gtk_widget_show (label10);
  gtk_box_pack_start (GTK_BOX (hbox24), label10, FALSE, FALSE, 0);

  stop_but = gtk_button_new ();
  gtk_widget_show (stop_but);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar1), stop_but, _("Stop Aquistion"), NULL);
  gtk_widget_set_sensitive (stop_but, FALSE);

  alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment2);
  gtk_container_add (GTK_CONTAINER (stop_but), alignment2);

  hbox25 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox25);
  gtk_container_add (GTK_CONTAINER (alignment2), hbox25);

  image21 = gtk_image_new_from_stock ("gtk-no", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image21);
  gtk_box_pack_start (GTK_BOX (hbox25), image21, FALSE, FALSE, 0);

  label11 = gtk_label_new_with_mnemonic (_("St_op"));
  gtk_widget_show (label11);
  gtk_box_pack_start (GTK_BOX (hbox25), label11, FALSE, FALSE, 0);

  handlebox2 = gtk_handle_box_new ();
  gtk_widget_show (handlebox2);
  gtk_box_pack_start (GTK_BOX (vbox1), handlebox2, FALSE, FALSE, 0);

  toolbar2 = gtk_toolbar_new ();
  gtk_widget_show (toolbar2);
  gtk_container_add (GTK_CONTAINER (handlebox2), toolbar2);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_ICONS);

  chansel_combo = gtk_combo_box_new_text();
  gtk_widget_show(chansel_combo);
  gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar2), chansel_combo, NULL, NULL);
  gtk_widget_set_sensitive(chansel_combo, FALSE);		

/*
  chansel_combo = gtk_combo_new ();
  g_object_set_data (G_OBJECT (GTK_COMBO (chansel_combo)->popwin),
                     "GladeParentKey", chansel_combo);
  gtk_widget_show (chansel_combo);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar2), chansel_combo, NULL, NULL);
  gtk_widget_set_sensitive (chansel_combo, FALSE);

  combo_entry1 = GTK_COMBO (chansel_combo)->entry;
  gtk_widget_show (combo_entry1);
*/

  label12 = gtk_label_new (_(" Mag in %: "));
  gtk_widget_show (label12);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar2), label12, NULL, NULL);

  mag_spinbut_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 10);
  mag_spinbut = gtk_spin_button_new (GTK_ADJUSTMENT (mag_spinbut_adj), 1, 0);
  gtk_widget_show (mag_spinbut);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar2), mag_spinbut, NULL, NULL);
  gtk_widget_set_sensitive (mag_spinbut, FALSE);

  label13 = gtk_label_new (_(" Notch: "));
  gtk_widget_show (label13);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar2), label13, NULL, NULL);

  combo1 = gtk_combo_box_new_text();
  gtk_widget_show(combo1);
  gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar2), combo1, NULL, NULL);
  gtk_widget_set_sensitive(combo1, FALSE);
	  
/*
  combo1 = gtk_combo_new ();
  g_object_set_data (G_OBJECT (GTK_COMBO (combo1)->popwin),
                     "GladeParentKey", combo1);
  gtk_widget_show (combo1);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar2), combo1, NULL, NULL);

  combo_entry2 = GTK_COMBO (combo1)->entry;
  gtk_widget_show (combo_entry2);
*/

  apply_but = gtk_button_new_from_stock ("gtk-apply");
  gtk_widget_show (apply_but);
  gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar2), apply_but, _("Start Aquistion"), NULL);
  gtk_widget_set_sensitive (apply_but, FALSE);

  hbox18 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox18);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox18, TRUE, TRUE, 0);

  drawingarea = gtk_drawing_area_new ();
  gtk_widget_show (drawingarea);
  gtk_box_pack_start (GTK_BOX (hbox18), drawingarea, TRUE, TRUE, 0);

  vscrollbar1 = gtk_vscrollbar_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 10, 1, 1, 1)));
  gtk_widget_show (vscrollbar1);
  gtk_box_pack_start (GTK_BOX (hbox18), vscrollbar1, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (vscrollbar1, FALSE);

  statusbar = gtk_statusbar_new ();
  gtk_widget_show (statusbar);
  gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) bsv_main_win, "delete-event",
                    G_CALLBACK (main_quit),
                    NULL);
  g_signal_connect ((gpointer) preferences_main, "activate",
                    G_CALLBACK (run_viewer_preference_dlg),
                    NULL);
  g_signal_connect ((gpointer) quit1, "activate",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect ((gpointer) preferences_driver, "activate",
                    G_CALLBACK (run_driver_perferences_dlg),
                    NULL);
  g_signal_connect ((gpointer) information2, "activate",
                    G_CALLBACK (run_driver_info_dlg),
                    NULL);
  g_signal_connect ((gpointer) start_but, "clicked",
                    G_CALLBACK (start_acquistion),
                    NULL);
  g_signal_connect ((gpointer) stop_but, "clicked",
                    G_CALLBACK (stop_acquistion),
                    NULL);
  g_signal_connect ((gpointer) apply_but, "clicked",
                    G_CALLBACK (apply_but_clicked),
                    NULL);
  g_signal_connect ((gpointer) drawingarea, "expose_event",
                    G_CALLBACK (resize_area),
                    NULL);
  g_signal_connect ((gpointer) vscrollbar1, "value_changed",
                    G_CALLBACK (vsbar_value_changed),
                    NULL);
  g_signal_connect ((gpointer) chansel_combo, "changed",
  					G_CALLBACK (chansel_combo_changed),
					NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (bsv_main_win, bsv_main_win, "bsv_main_win");
  GLADE_HOOKUP_OBJECT (bsv_main_win, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, menubar1, "menubar1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, menuitem4, "menuitem4");
  GLADE_HOOKUP_OBJECT (bsv_main_win, menuitem4_menu, "menuitem4_menu");
  GLADE_HOOKUP_OBJECT (bsv_main_win, preferences_main, "preferences_main");
  GLADE_HOOKUP_OBJECT (bsv_main_win, image18, "image18");
  GLADE_HOOKUP_OBJECT (bsv_main_win, separatormenuitem1, "separatormenuitem1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, quit1, "quit1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, menuitem5, "menuitem5");
  GLADE_HOOKUP_OBJECT (bsv_main_win, menuitem5_menu, "menuitem5_menu");
  GLADE_HOOKUP_OBJECT (bsv_main_win, preferences_driver, "preferences_driver");
  GLADE_HOOKUP_OBJECT (bsv_main_win, image19, "image19");
  GLADE_HOOKUP_OBJECT (bsv_main_win, information2, "information2");
  GLADE_HOOKUP_OBJECT (bsv_main_win, handlebox1, "handlebox1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, toolbar1, "toolbar1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, start_but, "start_but");
  GLADE_HOOKUP_OBJECT (bsv_main_win, alignment1, "alignment1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, hbox24, "hbox24");
  GLADE_HOOKUP_OBJECT (bsv_main_win, image20, "image20");
  GLADE_HOOKUP_OBJECT (bsv_main_win, label10, "label10");
  GLADE_HOOKUP_OBJECT (bsv_main_win, stop_but, "stop_but");
  GLADE_HOOKUP_OBJECT (bsv_main_win, alignment2, "alignment2");
  GLADE_HOOKUP_OBJECT (bsv_main_win, hbox25, "hbox25");
  GLADE_HOOKUP_OBJECT (bsv_main_win, image21, "image21");
  GLADE_HOOKUP_OBJECT (bsv_main_win, label11, "label11");
  GLADE_HOOKUP_OBJECT (bsv_main_win, handlebox2, "handlebox2");
  GLADE_HOOKUP_OBJECT (bsv_main_win, toolbar2, "toolbar2");
  GLADE_HOOKUP_OBJECT (bsv_main_win, chansel_combo, "chansel_combo");
//  GLADE_HOOKUP_OBJECT (bsv_main_win, combo_entry1, "combo_entry1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, label12, "label12");
  GLADE_HOOKUP_OBJECT (bsv_main_win, mag_spinbut, "mag_spinbut");
  GLADE_HOOKUP_OBJECT (bsv_main_win, label13, "label13");
  GLADE_HOOKUP_OBJECT (bsv_main_win, combo1, "combo1");
//  GLADE_HOOKUP_OBJECT (bsv_main_win, combo_entry2, "combo_entry2");
  GLADE_HOOKUP_OBJECT (bsv_main_win, apply_but, "apply_but");
  GLADE_HOOKUP_OBJECT (bsv_main_win, hbox18, "hbox18");
  GLADE_HOOKUP_OBJECT (bsv_main_win, drawingarea, "drawingarea");
  GLADE_HOOKUP_OBJECT (bsv_main_win, vscrollbar1, "vscrollbar1");
  GLADE_HOOKUP_OBJECT (bsv_main_win, statusbar, "statusbar");

  gtk_window_add_accel_group (GTK_WINDOW (bsv_main_win), accel_group);

  return bsv_main_win;
}
예제 #13
0
static void
vnr_properties_dialog_init (VnrPropertiesDialog * dialog)
{
    GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    GtkWidget *action_area = gtk_dialog_get_action_area(GTK_DIALOG(dialog));
    GtkWidget *temp_box;
    GtkWidget *temp_label;

    gtk_window_set_title(GTK_WINDOW(dialog), _("Image Properties"));

    /* VBox containing the Location labels */
    temp_box = gtk_vbox_new(FALSE,0);
    gtk_container_set_border_width (GTK_CONTAINER(temp_box), 10);
    gtk_box_pack_start (GTK_BOX(content_area), temp_box, FALSE,FALSE,0);

    temp_label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(temp_label), _("<b>Location:</b>"));
    gtk_misc_set_alignment (GTK_MISC(temp_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), temp_label, FALSE,FALSE,0);

    dialog->location_label = gtk_label_new(NULL);
    gtk_misc_set_alignment (GTK_MISC(dialog->location_label), 0, 0);
    gtk_label_set_selectable (GTK_LABEL(dialog->location_label), TRUE);
    gtk_label_set_ellipsize (GTK_LABEL(dialog->location_label), PANGO_ELLIPSIZE_END);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->location_label, FALSE,FALSE,0);

    /* VBox containing the image and meta data */
    dialog->layout = gtk_vbox_new(FALSE,10);
    gtk_container_set_border_width (GTK_CONTAINER(dialog->layout), 10);
    gtk_box_pack_start ( GTK_BOX (content_area) , dialog->layout, FALSE,FALSE,0);

    /* HBox containing the image and the two columns with labels */
    dialog->image_layout = gtk_hbox_new(FALSE,10);
    gtk_container_set_border_width (GTK_CONTAINER(dialog->image_layout), 10);
    gtk_box_pack_start ( GTK_BOX (dialog->layout) , dialog->image_layout, FALSE,FALSE,0);

    /* The frame around the image */
    temp_box = gtk_frame_new(NULL);
    gtk_widget_set_size_request (temp_box, 105, 105);
    gtk_box_pack_start (GTK_BOX (dialog->image_layout), temp_box, FALSE,FALSE,0);

    dialog->image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_DIALOG);
    gtk_container_add (GTK_CONTAINER (temp_box), dialog->image);


    /* Buttons */
    dialog->prev_button = gtk_button_new();
    gtk_button_set_image (GTK_BUTTON(dialog->prev_button),
                          gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
    gtk_container_add (GTK_CONTAINER (action_area), dialog->prev_button);

    dialog->next_button = gtk_button_new();
    gtk_button_set_image (GTK_BUTTON(dialog->next_button),
                          gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
    gtk_container_add (GTK_CONTAINER (action_area), dialog->next_button);

    dialog->close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
    gtk_container_add (GTK_CONTAINER (action_area), dialog->close_button);


    /* Image Data Labels */
    temp_box = gtk_vbox_new(FALSE,0);
    gtk_box_pack_start (GTK_BOX (dialog->image_layout), temp_box, FALSE,FALSE,0);

    temp_label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(temp_label), _("<b>Name:</b>"));
    gtk_misc_set_alignment (GTK_MISC(temp_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), temp_label, FALSE,FALSE,0);
    temp_label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(temp_label), _("<b>Type:</b>"));
    gtk_misc_set_alignment (GTK_MISC(temp_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), temp_label, FALSE,FALSE,0);
    temp_label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(temp_label), _("<b>Size:</b>"));
    gtk_misc_set_alignment (GTK_MISC(temp_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), temp_label, FALSE,FALSE,0);
    temp_label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(temp_label), _("<b>Width:</b>"));
    gtk_misc_set_alignment (GTK_MISC(temp_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), temp_label, FALSE,FALSE,0);
    temp_label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(temp_label), _("<b>Height:</b>"));
    gtk_misc_set_alignment (GTK_MISC(temp_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), temp_label, FALSE,FALSE,0);


    temp_box = gtk_vbox_new(FALSE,0);
    gtk_box_pack_start (GTK_BOX (dialog->image_layout), temp_box, FALSE,FALSE,0);

    dialog->name_label = gtk_label_new(NULL);
    gtk_label_set_selectable (GTK_LABEL(dialog->name_label), TRUE);
    gtk_misc_set_alignment (GTK_MISC(dialog->name_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->name_label, FALSE,FALSE,0);
    dialog->type_label = gtk_label_new(NULL);
    gtk_label_set_selectable (GTK_LABEL(dialog->type_label), TRUE);
    gtk_misc_set_alignment (GTK_MISC(dialog->type_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->type_label, FALSE,FALSE,0);
    dialog->size_label = gtk_label_new(NULL);
    gtk_label_set_selectable (GTK_LABEL(dialog->size_label), TRUE);
    gtk_misc_set_alignment (GTK_MISC(dialog->size_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->size_label, FALSE,FALSE,0);
    dialog->width_label = gtk_label_new(NULL);
    gtk_label_set_selectable (GTK_LABEL(dialog->width_label), TRUE);
    gtk_misc_set_alignment (GTK_MISC(dialog->width_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->width_label, FALSE,FALSE,0);
    dialog->height_label = gtk_label_new(NULL);
    gtk_label_set_selectable (GTK_LABEL(dialog->height_label), TRUE);
    gtk_misc_set_alignment (GTK_MISC(dialog->height_label), 0, 0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->height_label, FALSE,FALSE,0);

    /* Metadata Labels */

    temp_box = gtk_hbox_new(FALSE,10);
    gtk_box_pack_start (GTK_BOX (dialog->layout), temp_box, FALSE,FALSE,0);

    dialog->meta_names_box = gtk_vbox_new(FALSE,0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->meta_names_box, FALSE,FALSE,0);

    dialog->meta_values_box = gtk_vbox_new(FALSE,0);
    gtk_box_pack_start (GTK_BOX (temp_box), dialog->meta_values_box, FALSE,FALSE,0);

    /* Events and rest */

    g_signal_connect(G_OBJECT(dialog), "delete-event",
                     G_CALLBACK(gtk_widget_hide_on_delete), NULL);
    g_signal_connect_swapped(G_OBJECT(dialog->close_button), "clicked",
                             G_CALLBACK(gtk_widget_hide_on_delete), dialog);

    g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(key_press_cb), NULL);

    gtk_widget_show_all(content_area);
    gtk_widget_show_all(action_area);
}
예제 #14
0
void create_kbm_window()
{
  if (hime_kbm_window) {
    gtk_window_present(GTK_WINDOW(hime_kbm_window));
    return;
  }

  load_setttings();

  hime_kbm_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(hime_kbm_window), GTK_WIN_POS_MOUSE);
  gtk_window_set_has_resize_grip(GTK_WINDOW(hime_kbm_window), FALSE);

  g_signal_connect (G_OBJECT (hime_kbm_window), "delete_event",
                    G_CALLBACK (close_kbm_window),
                    NULL);

  gtk_window_set_title (GTK_WINDOW (hime_kbm_window), _("HIME 注音/詞音設定"));
  gtk_container_set_border_width (GTK_CONTAINER (hime_kbm_window), 1);

  GtkWidget *vbox_top = gtk_vbox_new (FALSE, 3);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (hime_kbm_window), vbox_top);


  GtkWidget *hbox_lr = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox_top), hbox_lr, TRUE, TRUE, 0);


  GtkWidget *vbox_l = gtk_vbox_new (FALSE, 3);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_l), GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (hbox_lr), vbox_l, TRUE, TRUE, 10);

  GtkWidget *vbox_r = gtk_vbox_new (FALSE, 3);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_r), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_homogeneous(GTK_GRID(vbox_r), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox_lr), vbox_r, TRUE, TRUE, 10);


  GtkWidget *frame_kbm = gtk_frame_new(_("鍵盤排列方式/選擇鍵/選單每列字數"));
  gtk_box_pack_start (GTK_BOX (vbox_l), frame_kbm, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_kbm), 1);
  gtk_container_add (GTK_CONTAINER (frame_kbm), create_kbm_opts());

  gtk_box_pack_start (GTK_BOX (vbox_l), create_en_pho_key_sel(_("(詞音) 切換[中/英]輸入")), TRUE, TRUE, 0);

  GtkWidget *frame_tsin_space_opt = gtk_frame_new(_("(詞音) 鍵入空白鍵"));
  gtk_box_pack_start (GTK_BOX (vbox_l), frame_tsin_space_opt, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_tsin_space_opt), 1);

  GtkWidget *box_tsin_space_opt = gtk_vbox_new (FALSE, 0);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(box_tsin_space_opt), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (frame_tsin_space_opt), box_tsin_space_opt);
  gtk_container_set_border_width (GTK_CONTAINER (box_tsin_space_opt), 1);

  GSList *group_tsin_space_opt = NULL;
  int current_idx = get_currnet_tsin_space_option_idx();
  new_select_idx_tsin_space_opt = current_idx;

  gsize i;
  for(i=0; i< tsin_space_optionsN; i++) {
    GtkWidget *button = gtk_radio_button_new_with_label (group_tsin_space_opt, _(tsin_space_options[i].name));
    gtk_box_pack_start (GTK_BOX (box_tsin_space_opt), button, TRUE, TRUE, 0);

    group_tsin_space_opt = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));

    g_signal_connect (G_OBJECT (button), "clicked",
       G_CALLBACK (callback_button_clicked_tsin_space_opt), (gpointer) i);

    if (i==current_idx)
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  }

  GtkWidget *hbox_tsin_phrase_pre_select = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_tsin_phrase_pre_select , TRUE, TRUE, 1);
  check_button_tsin_phrase_pre_select = gtk_check_button_new_with_label(_("詞音輸入預選詞視窗"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_phrase_pre_select), check_button_tsin_phrase_pre_select, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_phrase_pre_select), tsin_phrase_pre_select);


  GtkWidget *hbox_phonetic_char_dynamic_sequence = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_phonetic_char_dynamic_sequence , TRUE, TRUE, 1);
  check_button_phonetic_char_dynamic_sequence = gtk_check_button_new_with_label(_("依使用頻率調整字的順序"));
  gtk_box_pack_start (GTK_BOX (hbox_phonetic_char_dynamic_sequence), check_button_phonetic_char_dynamic_sequence, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_phonetic_char_dynamic_sequence), phonetic_char_dynamic_sequence);


  GtkWidget *hbox_pho_hide_row2 = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_pho_hide_row2 , TRUE, TRUE, 1);
  check_button_pho_hide_row2 = gtk_check_button_new_with_label(_("注音隱藏第二列 (注音符號)"));
  gtk_box_pack_start (GTK_BOX (hbox_pho_hide_row2), check_button_pho_hide_row2, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_pho_hide_row2), pho_hide_row2);


  GtkWidget *hbox_pho_in_row1 = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_pho_in_row1 , TRUE, TRUE, 1);
  check_button_pho_in_row1 = gtk_check_button_new_with_label(_("注音符號移至第一列"));
  gtk_box_pack_start (GTK_BOX (hbox_pho_in_row1), check_button_pho_in_row1, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_pho_in_row1), pho_in_row1);


  GtkWidget *hbox_phonetic_huge_tab = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_phonetic_huge_tab , TRUE, TRUE, 1);
  check_button_phonetic_huge_tab = gtk_check_button_new_with_label(_("使用巨大 UTF-8 字集"));
  gtk_box_pack_start (GTK_BOX (hbox_phonetic_huge_tab), check_button_phonetic_huge_tab, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_phonetic_huge_tab), phonetic_huge_tab);


  GtkWidget *hbox_tsin_tone_char_input = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_tone_char_input , TRUE, TRUE, 1);
  check_button_tsin_tone_char_input = gtk_check_button_new_with_label(_("(詞音) 輸入注音聲調符號"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_tone_char_input), check_button_tsin_tone_char_input, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_tone_char_input), tsin_tone_char_input);


  GtkWidget *hbox_tsin_tab_phrase_end = gtk_hbox_new(FALSE, 1);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_tab_phrase_end , TRUE, TRUE, 1);
  check_button_tsin_tab_phrase_end = gtk_check_button_new_with_label(_("(詞音) 使用 Escape/Tab 斷詞"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_tab_phrase_end), check_button_tsin_tab_phrase_end, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_tab_phrase_end), tsin_tab_phrase_end);

  GtkWidget *hbox_tsin_tail_select_key = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_tail_select_key , TRUE, TRUE, 1);
  check_button_tsin_tail_select_key = gtk_check_button_new_with_label(_("選擇鍵顯示於候選字(詞)後方"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_tail_select_key), check_button_tsin_tail_select_key, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_tail_select_key), tsin_tail_select_key);

  GtkWidget *hbox_tsin_buffer_editing_mode = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_buffer_editing_mode , TRUE, TRUE, 1);
  check_button_tsin_buffer_editing_mode = gtk_check_button_new_with_label(_("\\ 鍵可切換 jkx 鍵編輯模式"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_buffer_editing_mode), check_button_tsin_buffer_editing_mode, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_buffer_editing_mode), tsin_buffer_editing_mode);

  GtkWidget *hbox_tsin_use_pho_near = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_use_pho_near , TRUE, TRUE, 1);
  check_button_tsin_use_pho_near = gtk_check_button_new_with_label(_("按下 ↑ 鍵查詢近似音"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_use_pho_near), check_button_tsin_use_pho_near, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_use_pho_near), tsin_use_pho_near);

  GtkWidget *frame_tsin_buffer_size = gtk_frame_new(_("(詞音) 的編輯緩衝區大小"));
  gtk_box_pack_start (GTK_BOX (vbox_r), frame_tsin_buffer_size, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_tsin_buffer_size), 1);
  GtkAdjustment *adj_gtab_in =
   (GtkAdjustment *) gtk_adjustment_new (tsin_buffer_size, 10.0, MAX_PH_BF, 1.0, 1.0, 0.0);
  spinner_tsin_buffer_size = gtk_spin_button_new (adj_gtab_in, 0, 0);
  gtk_container_add (GTK_CONTAINER (frame_tsin_buffer_size), spinner_tsin_buffer_size);

  GtkWidget *frame_tsin_cursor_color = gtk_frame_new(_("詞音游標的顏色"));
  gtk_box_pack_start (GTK_BOX (vbox_r), frame_tsin_cursor_color, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_tsin_cursor_color), 1);
  GtkWidget *button_tsin_cursor_color = gtk_button_new();
  g_signal_connect (G_OBJECT (button_tsin_cursor_color), "clicked",
                    G_CALLBACK (cb_tsin_cursor_color), G_OBJECT (hime_kbm_window));
  da_cursor =  gtk_drawing_area_new();
  gtk_container_add (GTK_CONTAINER (button_tsin_cursor_color), da_cursor);
  gdk_color_parse(tsin_cursor_color, &tsin_cursor_gcolor);
#if !GTK_CHECK_VERSION(2,91,6)
  gtk_widget_modify_bg(da_cursor, GTK_STATE_NORMAL, &tsin_cursor_gcolor);
#else
  GdkRGBA rgbbg;
  gdk_rgba_parse(&rgbbg, gdk_color_to_string(&tsin_cursor_gcolor));
  gtk_widget_override_background_color(da_cursor, GTK_STATE_FLAG_NORMAL, &rgbbg);
#endif
  gtk_widget_set_size_request(da_cursor, 16, 2);
  gtk_container_add (GTK_CONTAINER (frame_tsin_cursor_color), button_tsin_cursor_color);

  GtkWidget *hbox_cancel_ok = gtk_hbox_new (FALSE, 10);
  gtk_grid_set_column_homogeneous(GTK_GRID(hbox_cancel_ok), TRUE);
  gtk_box_pack_start (GTK_BOX (vbox_top), hbox_cancel_ok , FALSE, FALSE, 5);
  GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  if (button_order)
    gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
  else
    gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
  GtkWidget *button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
#if !GTK_CHECK_VERSION(2,91,2)
  if (button_order)
    gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5);
  else
    gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5);
#else
  if (button_order)
    gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_LEFT, 1, 1);
  else
    gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_RIGHT, 1, 1);
#endif

  g_signal_connect (G_OBJECT (button_cancel), "clicked",
                            G_CALLBACK (close_kbm_window),
                            G_OBJECT (hime_kbm_window));

  g_signal_connect_swapped (G_OBJECT (button_ok), "clicked",
                            G_CALLBACK (cb_ok),
                            G_OBJECT (hime_kbm_window));

  GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button_cancel);

  gtk_widget_show_all (hime_kbm_window);

  return;
}
예제 #15
0
파일: project.c 프로젝트: cirne100/geany
void project_new(void)
{
	GtkWidget *vbox;
	GtkWidget *table;
	GtkWidget *image;
	GtkWidget *button;
	GtkWidget *bbox;
	GtkWidget *label;
	PropertyDialogElements *e;

	if (! project_ask_close())
		return;

	g_return_if_fail(app->project == NULL);

	e = g_new0(PropertyDialogElements, 1);
	e->dialog = gtk_dialog_new_with_buttons(_("New Project"), GTK_WINDOW(main_widgets.window),
										 GTK_DIALOG_DESTROY_WITH_PARENT,
										 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);

	gtk_widget_set_name(e->dialog, "GeanyDialogProject");
	bbox = gtk_hbox_new(FALSE, 0);
	button = gtk_button_new();
	image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON);
	label = gtk_label_new_with_mnemonic(_("C_reate"));
	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 3);
	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 3);
	gtk_container_add(GTK_CONTAINER(button), bbox);
	gtk_dialog_add_action_widget(GTK_DIALOG(e->dialog), button, GTK_RESPONSE_OK);

	vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog));

	entries_modified = FALSE;

	table = gtk_table_new(3, 2, FALSE);
	gtk_table_set_row_spacings(GTK_TABLE(table), 5);
	gtk_table_set_col_spacings(GTK_TABLE(table), 10);

	label = gtk_label_new(_("Name:"));
	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);

	e->name = gtk_entry_new();
	ui_entry_add_clear_icon(GTK_ENTRY(e->name));
	gtk_entry_set_max_length(GTK_ENTRY(e->name), MAX_NAME_LEN);

	ui_table_add_row(GTK_TABLE(table), 0, label, e->name, NULL);

	label = gtk_label_new(_("Filename:"));
	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);

	e->file_name = gtk_entry_new();
	ui_entry_add_clear_icon(GTK_ENTRY(e->file_name));
	gtk_entry_set_width_chars(GTK_ENTRY(e->file_name), 30);
	button = gtk_button_new();
	g_signal_connect(button, "clicked", G_CALLBACK(on_file_save_button_clicked), e);
	image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
	gtk_container_add(GTK_CONTAINER(button), image);
	bbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start_defaults(GTK_BOX(bbox), e->file_name);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);

	ui_table_add_row(GTK_TABLE(table), 1, label, bbox, NULL);

	label = gtk_label_new(_("Base path:"));
	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);

	e->base_path = gtk_entry_new();
	ui_entry_add_clear_icon(GTK_ENTRY(e->base_path));
	gtk_widget_set_tooltip_text(e->base_path,
		_("Base directory of all files that make up the project. "
		"This can be a new path, or an existing directory tree. "
		"You can use paths relative to the project filename."));
	bbox = ui_path_box_new(_("Choose Project Base Path"),
		GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));

	ui_table_add_row(GTK_TABLE(table), 2, label, bbox, NULL);

	gtk_container_add(GTK_CONTAINER(vbox), table);

	/* signals */
	g_signal_connect(e->name, "changed", G_CALLBACK(on_name_entry_changed), e);
	/* run the callback manually to initialise the base_path and file_name fields */
	on_name_entry_changed(GTK_EDITABLE(e->name), e);

	g_signal_connect(e->file_name, "changed", G_CALLBACK(on_entries_changed), e);
	g_signal_connect(e->base_path, "changed", G_CALLBACK(on_entries_changed), e);

	gtk_widget_show_all(e->dialog);

	while (gtk_dialog_run(GTK_DIALOG(e->dialog)) == GTK_RESPONSE_OK)
	{
		if (update_config(e, TRUE))
		{
			if (!write_config(TRUE))
				SHOW_ERR(_("Project file could not be written"));
			else
			{
				ui_set_statusbar(TRUE, _("Project \"%s\" created."), app->project->name);

				ui_add_recent_project_file(app->project->file_name);
				break;
			}
		}
	}
	gtk_widget_destroy(e->dialog);
	g_free(e);
}
예제 #16
0
static gboolean
append_menu (RBButtonBar *bar, GMenuModel *menu, gboolean need_separator)
{
	int i;
	gulong id;

	id = g_signal_connect (menu, "items-changed", G_CALLBACK (items_changed_cb), bar);
	g_hash_table_insert (bar->priv->handlers, (gpointer)id, g_object_ref (menu));

	for (i = 0; i < g_menu_model_get_n_items (menu); i++) {
		char *label_text;
		char *accel;
		GtkWidget *button;
		GtkWidget *label;
		GMenuModel *submenu;

		/* recurse into sections */
		submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SECTION);
		if (submenu != NULL) {
			need_separator = append_menu (bar, submenu, TRUE);
			continue;
		}

		/* if this item and the previous item are in different sections, add
		 * a separator between them.  this may not be a good idea.
		 */
		if (need_separator) {
			GtkWidget *sep;

			if (bar->priv->position > 0) {
				sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
				gtk_widget_show (sep);
				g_object_set (sep, "margin-start", 6, "margin-end", 6, NULL);
				gtk_grid_attach (GTK_GRID (bar), sep, bar->priv->position++, 0, 1, 1);
			}

			need_separator = FALSE;
		}

		button = NULL;

		/* submenus become menu buttons, normal items become buttons */
		submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SUBMENU);

		if (submenu != NULL) {
			button = gtk_menu_button_new ();
			gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), submenu);

			g_object_set_data_full (G_OBJECT (button), "rb-menu-model", g_object_ref (submenu), (GDestroyNotify)g_object_unref);
		} else {
			GMenuAttributeIter *iter;
			const char *name;
			GVariant *value;
			char *str;
			guint signal_id;
		
			/* we can't do more than one of action and rb-property-bind
			 * and rb-signal-bind, so just do whichever turns up first
			 * in the iterator
			 */
			iter = g_menu_model_iterate_item_attributes (menu, i);
			while (g_menu_attribute_iter_get_next (iter, &name, &value)) {
				if (g_str_equal (name, "action")) {
					button = gtk_button_new ();
					g_variant_get (value, "s", &str, NULL);
					gtk_actionable_set_action_name (GTK_ACTIONABLE (button), str);
					/* action target too somehow? */
					g_free (str);
					break;
				} else if (g_str_equal (name, "rb-property-bind")) {
					/* property has to be a boolean, can't do inverts, etc. etc. */
					button = gtk_toggle_button_new ();
					g_variant_get (value, "s", &str, NULL);
					g_object_bind_property (bar->priv->target, str,
								button, "active",
								G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
					g_free (str);
					break;
				} else if (g_str_equal (name, "rb-signal-bind")) {
					button = gtk_button_new ();
					g_variant_get (value, "s", &str, NULL);
					signal_id = g_signal_lookup (str, G_OBJECT_TYPE (bar->priv->target));
					if (signal_id != 0) {
						g_object_set_data (G_OBJECT (button), "rb-signal-bind-id", GUINT_TO_POINTER (signal_id));
						g_signal_connect (button, "clicked", G_CALLBACK (signal_button_clicked_cb), bar);
					}
					g_free (str);
					break;
				}
			}

			g_object_unref (iter);
		}

		if (button == NULL) {
			g_warning ("no idea what's going on here");
			continue;
		}

		gtk_widget_set_hexpand (button, FALSE);
		gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);

		label_text = NULL;
		g_menu_model_get_item_attribute (menu, i, "label", "s", &label_text);
		label = gtk_label_new (g_dgettext (NULL, label_text));
		g_object_set (label, "margin-left", 6, "margin-right", 6, NULL);
		gtk_container_add (GTK_CONTAINER (button), label);

		if (g_menu_model_get_item_attribute (menu, i, "accel", "s", &accel)) {
			g_object_set_data_full (G_OBJECT (button), "rb-accel", accel, (GDestroyNotify) g_free);
		}

		gtk_widget_show_all (button);
		gtk_size_group_add_widget (bar->priv->size_group, button);
		gtk_grid_attach (GTK_GRID (bar), button, bar->priv->position++, 0, 1, 1);

		g_free (label_text);
	}

	return need_separator;
}
예제 #17
0
GtkWidget *create_TextFileDialog (bool do_file)
{
    GtkWidget *TextFileDialog;
    GtkWidget *vbox42;
    GtkWidget *hbox105 = NULL;
    GtkWidget *label196 = NULL;
    GtkWidget *FileNameLabel = NULL;
    GtkWidget *LineEntry;
    GtkWidget *hbox111;
    GtkWidget *vbox43;
    GtkWidget *StartButton;
    GtkWidget *alignment32;
    GtkWidget *hbox112;
    GtkWidget *image38;
    GtkWidget *label204;
    GtkWidget *vbox44;
    GtkWidget *vbox45;
    GtkWidget *PrevButton;
    GtkWidget *alignment33;
    GtkWidget *hbox113;
    GtkWidget *image39;
    GtkWidget *label205;
    GtkWidget *label206;
    GtkWidget *vbox46;
    GtkWidget *NextButton;
    GtkWidget *alignment34;
    GtkWidget *hbox114;
    GtkWidget *label207;
    GtkWidget *image40;
    GtkWidget *vbox47;
    GtkWidget *EndButton;
    GtkWidget *alignment35;
    GtkWidget *hbox115;
    GtkWidget *label208;
    GtkWidget *image41;
    GtkWidget *label209;
    GtkWidget *vbox48;
    GtkWidget *SendButton;
    GtkWidget *alignment36;
    GtkWidget *hbox116;
    GtkWidget *label210;
    GtkWidget *image42;
    GtkWidget *statusbar2;
    GtkTooltips *tooltips;

    tooltips = gtk_tooltips_new();

    TextFileDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(TextFileDialog), _("Text File Transmission"));
    gtk_window_set_position(GTK_WINDOW(TextFileDialog), GTK_WIN_POS_CENTER);

    vbox42 = gtk_vbox_new(FALSE, 13);
    gtk_widget_show(vbox42);
    gtk_container_add(GTK_CONTAINER(TextFileDialog), vbox42);

    if (do_file) {
        hbox105 = gtk_hbox_new(FALSE, 0);
        gtk_widget_show(hbox105);
        gtk_box_pack_start(GTK_BOX(vbox42), hbox105, FALSE, FALSE, 0);

        label196 = gtk_label_new(_("File Name:"));
        gtk_widget_show(label196);
        gtk_box_pack_start(GTK_BOX(hbox105), label196, TRUE, TRUE, 0);
        gtk_misc_set_padding(GTK_MISC(label196), 0, 9);


        FileNameLabel = gtk_label_new("");
        gtk_widget_show(FileNameLabel);
        gtk_box_pack_start(GTK_BOX(hbox105), FileNameLabel, TRUE, TRUE, 0);
    }
    LineEntry = gtk_entry_new();
    gtk_widget_show(LineEntry);
    gtk_box_pack_start(GTK_BOX(vbox42), LineEntry, FALSE, FALSE, 0);

    hbox111 = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox111);
    gtk_box_pack_start(GTK_BOX(vbox42), hbox111, TRUE, TRUE, 0);

    vbox43 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox43);
    gtk_box_pack_start(GTK_BOX(hbox111), vbox43, FALSE, TRUE, 0);

    StartButton = gtk_button_new();
    gtk_widget_show(StartButton);
    gtk_box_pack_start(GTK_BOX(vbox43), StartButton, TRUE, FALSE, 0);
    gtk_tooltips_set_tip(tooltips, StartButton, _("Move to beginning of file"), NULL);

    alignment32 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment32);
    gtk_container_add(GTK_CONTAINER(StartButton), alignment32);

    hbox112 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox112);
    gtk_container_add(GTK_CONTAINER(alignment32), hbox112);

    image38 = gtk_image_new_from_stock("gtk-goto-first", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image38);
    gtk_box_pack_start(GTK_BOX(hbox112), image38, FALSE, FALSE, 0);

    label204 = gtk_label_new_with_mnemonic(_("Start"));
    gtk_widget_show(label204);
    gtk_box_pack_start(GTK_BOX(hbox112), label204, FALSE, FALSE, 0);

    vbox44 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox44);
    gtk_box_pack_start(GTK_BOX(hbox111), vbox44, FALSE, TRUE, 0);

    vbox45 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox45);
    gtk_box_pack_start(GTK_BOX(vbox44), vbox45, TRUE, FALSE, 0);

    PrevButton = gtk_button_new();
    gtk_widget_show(PrevButton);
    gtk_box_pack_start(GTK_BOX(vbox45), PrevButton, TRUE, FALSE, 0);
    gtk_tooltips_set_tip(tooltips, PrevButton, _("Move to previous entry"), NULL);

    alignment33 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment33);
    gtk_container_add(GTK_CONTAINER(PrevButton), alignment33);

    hbox113 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox113);
    gtk_container_add(GTK_CONTAINER(alignment33), hbox113);

    image39 = gtk_image_new_from_stock("gtk-go-back", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image39);
    gtk_box_pack_start(GTK_BOX(hbox113), image39, FALSE, FALSE, 0);

    label205 = gtk_label_new_with_mnemonic(_("Previous"));
    gtk_widget_show(label205);
    gtk_box_pack_start(GTK_BOX(hbox113), label205, FALSE, FALSE, 0);

    label206 = gtk_label_new("");
    gtk_widget_show(label206);
    gtk_box_pack_start(GTK_BOX(hbox111), label206, TRUE, TRUE, 11);

    vbox46 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox46);
    gtk_box_pack_start(GTK_BOX(hbox111), vbox46, TRUE, TRUE, 0);

    NextButton = gtk_button_new();
    gtk_widget_show(NextButton);
    gtk_box_pack_start(GTK_BOX(vbox46), NextButton, TRUE, FALSE, 0);
    gtk_tooltips_set_tip(tooltips, NextButton, _("Move to next entry"), NULL);

    alignment34 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment34);
    gtk_container_add(GTK_CONTAINER(NextButton), alignment34);

    hbox114 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox114);
    gtk_container_add(GTK_CONTAINER(alignment34), hbox114);

    label207 = gtk_label_new_with_mnemonic(_("Next"));
    gtk_widget_show(label207);
    gtk_box_pack_start(GTK_BOX(hbox114), label207, FALSE, FALSE, 0);

    image40 = gtk_image_new_from_stock("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image40);
    gtk_box_pack_start(GTK_BOX(hbox114), image40, FALSE, FALSE, 0);

    vbox47 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox47);
    gtk_box_pack_start(GTK_BOX(hbox111), vbox47, TRUE, TRUE, 0);

    EndButton = gtk_button_new();
    gtk_widget_show(EndButton);
    gtk_box_pack_start(GTK_BOX(vbox47), EndButton, TRUE, FALSE, 0);
    gtk_tooltips_set_tip(tooltips, EndButton, _("Move to last entry in file"), NULL);

    alignment35 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment35);
    gtk_container_add(GTK_CONTAINER(EndButton), alignment35);

    hbox115 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox115);
    gtk_container_add(GTK_CONTAINER(alignment35), hbox115);

    label208 = gtk_label_new_with_mnemonic(_("End"));
    gtk_widget_show(label208);
    gtk_box_pack_start(GTK_BOX(hbox115), label208, FALSE, FALSE, 0);

    image41 = gtk_image_new_from_stock("gtk-goto-last", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image41);
    gtk_box_pack_start(GTK_BOX(hbox115), image41, FALSE, FALSE, 0);

    label209 = gtk_label_new("");
    gtk_widget_show(label209);
    gtk_box_pack_start(GTK_BOX(hbox111), label209, TRUE, TRUE, 26);

    vbox48 = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox48);
    gtk_box_pack_start(GTK_BOX(hbox111), vbox48, TRUE, FALSE, 0);

    SendButton = gtk_button_new();
    gtk_widget_show(SendButton);
    gtk_box_pack_start(GTK_BOX(vbox48), SendButton, TRUE, FALSE, 0);
    gtk_tooltips_set_tip(tooltips, SendButton, _("Transmit file"), NULL);

    alignment36 = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(alignment36);
    gtk_container_add(GTK_CONTAINER(SendButton), alignment36);

    hbox116 = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(hbox116);
    gtk_container_add(GTK_CONTAINER(alignment36), hbox116);

    label210 = gtk_label_new_with_mnemonic(_("Send"));
    gtk_widget_show(label210);
    gtk_box_pack_start(GTK_BOX(hbox116), label210, FALSE, FALSE, 0);

    image42 = gtk_image_new_from_stock("gtk-ok", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(image42);
    gtk_box_pack_start(GTK_BOX(hbox116), image42, FALSE, FALSE, 0);

    statusbar2 = gtk_statusbar_new ();
    gtk_widget_show (statusbar2);
    gtk_box_pack_start (GTK_BOX (vbox42), statusbar2, FALSE, FALSE, 0);

    g_signal_connect((gpointer) TextFileDialog, "delete_event",
                     G_CALLBACK(on_TextFileDialog_delete_event),
                     NULL);
    g_signal_connect((gpointer) TextFileDialog, "destroy",
                     G_CALLBACK(on_TextFileDialog_destroy),
                     NULL);
    if (do_file) {
        g_signal_connect((gpointer) StartButton, "clicked",
                         G_CALLBACK(on_StartButton_clicked),
                         TextFileDialog);
        g_signal_connect((gpointer) PrevButton, "clicked",
                         G_CALLBACK(on_PrevButton_clicked),
                         TextFileDialog);
        g_signal_connect((gpointer) NextButton, "clicked",
                         G_CALLBACK(on_NextButton_clicked),
                         TextFileDialog);
        g_signal_connect((gpointer) EndButton, "clicked",
                         G_CALLBACK(on_EndButton_clicked),
                         TextFileDialog);
    }
    g_signal_connect((gpointer) SendButton, "clicked",
                     G_CALLBACK(on_SendButton_clicked),
                     TextFileDialog);
    g_signal_connect((gpointer)LineEntry, "activate",
                     G_CALLBACK(on_LineEntry_activate),
                     TextFileDialog);

    /* Store pointers to all widgets, for use by lookup_widget(). */
    GLADE_HOOKUP_OBJECT_NO_REF(TextFileDialog, TextFileDialog, "TextFileDialog");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox42, "vbox42");
    if (hbox105 != NULL) {
        GLADE_HOOKUP_OBJECT(TextFileDialog, hbox105, "hbox105");
        GLADE_HOOKUP_OBJECT(TextFileDialog, label196, "label196");
        GLADE_HOOKUP_OBJECT(TextFileDialog, FileNameLabel, "FileNameLabel");
    }
    GLADE_HOOKUP_OBJECT(TextFileDialog, LineEntry, "LineEntry");
    GLADE_HOOKUP_OBJECT(TextFileDialog, hbox111, "hbox111");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox43, "vbox43");
    GLADE_HOOKUP_OBJECT(TextFileDialog, StartButton, "StartButton");
    GLADE_HOOKUP_OBJECT(TextFileDialog, alignment32, "alignment32");
    GLADE_HOOKUP_OBJECT(TextFileDialog, hbox112, "hbox112");
    GLADE_HOOKUP_OBJECT(TextFileDialog, image38, "image38");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label204, "label204");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox44, "vbox44");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox45, "vbox45");
    GLADE_HOOKUP_OBJECT(TextFileDialog, PrevButton, "PrevButton");
    GLADE_HOOKUP_OBJECT(TextFileDialog, alignment33, "alignment33");
    GLADE_HOOKUP_OBJECT(TextFileDialog, hbox113, "hbox113");
    GLADE_HOOKUP_OBJECT(TextFileDialog, image39, "image39");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label205, "label205");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label206, "label206");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox46, "vbox46");
    GLADE_HOOKUP_OBJECT(TextFileDialog, NextButton, "NextButton");
    GLADE_HOOKUP_OBJECT(TextFileDialog, alignment34, "alignment34");
    GLADE_HOOKUP_OBJECT(TextFileDialog, hbox114, "hbox114");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label207, "label207");
    GLADE_HOOKUP_OBJECT(TextFileDialog, image40, "image40");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox47, "vbox47");
    GLADE_HOOKUP_OBJECT(TextFileDialog, EndButton, "EndButton");
    GLADE_HOOKUP_OBJECT(TextFileDialog, alignment35, "alignment35");
    GLADE_HOOKUP_OBJECT(TextFileDialog, hbox115, "hbox115");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label208, "label208");
    GLADE_HOOKUP_OBJECT(TextFileDialog, image41, "image41");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label209, "label209");
    GLADE_HOOKUP_OBJECT(TextFileDialog, vbox48, "vbox48");
    GLADE_HOOKUP_OBJECT(TextFileDialog, SendButton, "SendButton");
    GLADE_HOOKUP_OBJECT(TextFileDialog, alignment36, "alignment36");
    GLADE_HOOKUP_OBJECT(TextFileDialog, hbox116, "hbox116");
    GLADE_HOOKUP_OBJECT(TextFileDialog, label210, "label210");
    GLADE_HOOKUP_OBJECT(TextFileDialog, image42, "image42");
    GLADE_HOOKUP_OBJECT_NO_REF(TextFileDialog, tooltips, "tooltips");
    GLADE_HOOKUP_OBJECT (TextFileDialog, statusbar2, "statusbar2");

    if (do_file) {
        text_file_data_t *tptr = MALLOC_STRUCTURE(text_file_data_t);
        memset(tptr, 0, sizeof(*tptr));
        const char *fname =
            MyConfig->GetStringValue(CONFIG_TEXT_SOURCE_FILE_NAME);

        tptr->m_file = fopen(fname, "r");
        if (tptr->m_file == NULL) {
            char buffer[PATH_MAX];
            snprintf(buffer, PATH_MAX, "Can't open file %s", fname);
            ShowMessage("Can't open file",buffer);
            gtk_widget_destroy(TextFileDialog);
            return NULL;
        }
        gtk_label_set_text(GTK_LABEL(FileNameLabel), fname);
        ReadNextLine(tptr);
        DisplayLineInBuffer(TextFileDialog, tptr);
        GLADE_HOOKUP_OBJECT_NO_REF(TextFileDialog, tptr, "TextFileData");
    } else {
        gtk_widget_set_sensitive(StartButton, false);
        gtk_widget_set_sensitive(PrevButton, false);
        gtk_widget_set_sensitive(NextButton, false);
        gtk_widget_set_sensitive(EndButton, false);
        GLADE_HOOKUP_OBJECT_NO_REF(TextFileDialog, NULL, "TextFileData");
    }

    gtk_drag_dest_set(TextFileDialog,
                      GTK_DEST_DEFAULT_ALL,
                      drop_types,
                      NUM_ELEMENTS_IN_ARRAY(drop_types),
                      GDK_ACTION_COPY);
    gtk_drag_dest_set(LineEntry,
                      GTK_DEST_DEFAULT_ALL,
                      drop_types,
                      NUM_ELEMENTS_IN_ARRAY(drop_types),
                      GDK_ACTION_COPY);

    g_signal_connect((gpointer)TextFileDialog, "drag_data_received",
                     G_CALLBACK(on_drag_data_received),
                     TextFileDialog);

    g_signal_connect((gpointer)LineEntry, "drag_data_received",
                     G_CALLBACK(on_drag_data_received_entry),
                     TextFileDialog);

    gtk_widget_show(TextFileDialog);

    if (do_file) {
        gtk_widget_grab_focus(SendButton);
        on_SendButton_clicked(GTK_BUTTON(SendButton), TextFileDialog);
    } else {
        gtk_widget_grab_focus(LineEntry);
    }
    return TextFileDialog;
}
예제 #18
0
GtkWidget *ui_create_status_bar(GtkWidget *pane)
{
    /* Create the status bar on the bottom.  */
    GdkWindow *window = gtk_widget_get_window(get_active_toplevel());
    GtkWidget *speed_label, *drive_box, *joystick_box, *frame, *event_box, *pcb, *vcb, *tmp, *pal_ctrl_checkbox, *status_bar;
    int i;
    app_shell_type *as;
    char *empty = util_concat("<", _("empty"), ">", NULL);
    int num_app_shells = get_num_shells();

    status_bar = gtk_hbox_new(FALSE, 0);

    gtk_box_pack_end(GTK_BOX(pane), status_bar, FALSE, FALSE, 0);
    gtk_widget_show(status_bar);

    /* speed menu */
    event_box = gtk_event_box_new();
    gtk_box_pack_start(GTK_BOX(status_bar), event_box, TRUE, TRUE,0);
    gtk_widget_show(event_box);
    g_signal_connect(G_OBJECT(event_box), "button-press-event", G_CALLBACK(speed_popup_cb), (gpointer)NULL);

    frame = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
    gtk_container_add(GTK_CONTAINER(event_box), frame);
    gtk_widget_show(frame);

    gdk_window_set_cursor(gtk_widget_get_window(event_box), gdk_cursor_new(GDK_HAND1)); 

    /* speed label */
    speed_label = gtk_label_new("");
    app_shells[num_app_shells - 1].speed_label = (GtkLabel*)speed_label;
    gtk_misc_set_alignment (GTK_MISC(speed_label), 0, 0.5f);
    gtk_misc_set_padding(GTK_MISC(speed_label), 1, 1);
    gtk_container_add(GTK_CONTAINER(frame), speed_label);
    gtk_widget_show(speed_label);

    /* spacer */
    frame = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);

    tmp = gtk_label_new("");
    app_shells[num_app_shells - 1].statustext = (GtkLabel*)tmp;
    gtk_misc_set_alignment(GTK_MISC(tmp), 0, 0.5f);
    gtk_misc_set_padding(GTK_MISC(tmp), 1, 1);
    gtk_container_add(GTK_CONTAINER(frame), tmp);
    gtk_widget_show(tmp);
    gtk_box_pack_start(GTK_BOX(status_bar), frame, TRUE, TRUE,0);
    gtk_widget_show(frame);

    as = &app_shells[num_app_shells - 1];

    /* PAL Control checkbox */
    pal_ctrl_checkbox = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(pal_ctrl_checkbox), GTK_SHADOW_IN);
    pcb = gtk_check_button_new_with_label((machine_class != VICE_MACHINE_VSID) ? _("CRT Controls") : _("Mixer"));
    gtk_widget_set_can_focus(pcb, 0);
    g_signal_connect(G_OBJECT(pcb), "toggled", G_CALLBACK(ui_update_pal_checkbox), as);
    gtk_container_add(GTK_CONTAINER(pal_ctrl_checkbox), pcb);
    gtk_widget_show(pcb);
    gtk_box_pack_start(GTK_BOX(status_bar), pal_ctrl_checkbox, FALSE, FALSE, 0);
    gtk_widget_show(pal_ctrl_checkbox);

    /* Video Control checkbox */
    video_ctrl_checkbox = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(video_ctrl_checkbox), GTK_SHADOW_IN);

    video_ctrl_checkbox_label = gtk_label_new(_("audio/video recording"));
    vcb = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(vcb), video_ctrl_checkbox_label);
    gtk_widget_show(video_ctrl_checkbox_label);
    gtk_widget_set_can_focus(pcb, 0);
    g_signal_connect(G_OBJECT(vcb), "clicked", G_CALLBACK(ui_update_video_checkbox), vcb);
    gtk_container_add(GTK_CONTAINER(video_ctrl_checkbox), vcb);
    gtk_widget_show(vcb);
    gtk_box_pack_start(GTK_BOX(status_bar), video_ctrl_checkbox, FALSE, FALSE, 0);
    gtk_widget_set_tooltip_text(GTK_WIDGET(vcb), _("click to stop recording"));

    /* additional controls */
    if (machine_class != VICE_MACHINE_VSID) {

        /* Event record control checkbox */
        event_rec_checkbox = gtk_frame_new(NULL);
        gtk_frame_set_shadow_type(GTK_FRAME(event_rec_checkbox), GTK_SHADOW_IN);

        event_rec_checkbox_label = gtk_label_new(_("event recording"));
        vcb = gtk_button_new();
        gtk_container_add(GTK_CONTAINER(vcb), event_rec_checkbox_label);
        gtk_widget_show(event_rec_checkbox_label);
        gtk_widget_set_can_focus(pcb, 0);
        g_signal_connect(G_OBJECT(vcb), "clicked", G_CALLBACK(ui_update_event_checkbox), (gpointer)0);
        gtk_container_add(GTK_CONTAINER(event_rec_checkbox), vcb);
        gtk_widget_show(vcb);
        gtk_box_pack_start(GTK_BOX(status_bar), event_rec_checkbox, FALSE, FALSE, 0);
        gtk_widget_set_tooltip_text(GTK_WIDGET(vcb), _("click to stop recording"));

        /* Event playback control checkbox */
        event_playback_checkbox = gtk_frame_new(NULL);
        gtk_frame_set_shadow_type(GTK_FRAME(event_playback_checkbox), GTK_SHADOW_IN);

        event_playback_checkbox_label = gtk_label_new(_("event playback"));
        vcb = gtk_button_new();
        gtk_container_add(GTK_CONTAINER(vcb), event_playback_checkbox_label);
        gtk_widget_show(event_playback_checkbox_label);
        gtk_widget_set_can_focus(pcb, 0);
        g_signal_connect(G_OBJECT(vcb), "clicked", G_CALLBACK(ui_update_event_checkbox), (gpointer)1);
        gtk_container_add(GTK_CONTAINER(event_playback_checkbox), vcb);
        gtk_widget_show(vcb);
        gtk_box_pack_start(GTK_BOX(status_bar), event_playback_checkbox, FALSE, FALSE, 0);
        gtk_widget_set_tooltip_text(GTK_WIDGET(vcb), _("click to stop playback"));

        if (machine_class != VICE_MACHINE_VSID) {
            joystick_box = build_joystick_status_widget(as, window);
            gtk_widget_show(joystick_box);
            gtk_box_pack_start(GTK_BOX(status_bar), joystick_box, FALSE, FALSE, 0);
            drive_box = build_drive_status_widget(as, window);
            gtk_widget_show(drive_box);
            gtk_box_pack_start(GTK_BOX(status_bar), drive_box, FALSE, FALSE, 0);

            if ((machine_class != VICE_MACHINE_C64DTV) &&
                (machine_class != VICE_MACHINE_SCPU64)) {
                build_tape_status_widget(as, window);
                gtk_box_pack_start(GTK_BOX(status_bar), as->tape_status.event_box, FALSE, FALSE, 0);
                gtk_widget_show(as->tape_status.event_box);
                gdk_window_set_cursor(gtk_widget_get_window(as->tape_status.event_box), gdk_cursor_new(GDK_HAND1));
            }
        }

        gtk_widget_show(status_bar);

        for (i = 0; i < NUM_DRIVES; i++) {
#if 0
            int ih, iw;

            gdk_window_get_size_request(((GtkWidget *)as->drive_status[i].image)->window, &iw, &ih);
            gtk_widget_set_size_request(as->drive_status[i].image, width / 3, ih);
#endif
            gtk_widget_hide(as->drive_status[i].event_box);     /* Hide Drive widget */
            gdk_window_set_cursor(gtk_widget_get_window(as->drive_status[i].event_box), gdk_cursor_new (GDK_HAND1)); 
        }
    } else {
        gtk_widget_show(status_bar);
    }

    /* finalize event-box */
#if 0
    gdk_window_set_cursor(event_box->window, gdk_cursor_new(GDK_HAND1)); 
#endif

    lib_free(empty);

    return status_bar;
}
예제 #19
0
GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlSystem *pCtrlSystem)
{
    gint i;
    GObject *object;
    CtkConfig *ctk_config;
    GtkWidget *hbox;
    GtkWidget *vbox;
    GtkWidget *banner;
    GtkWidget *label;
    GtkWidget *hseparator;
    GtkWidget *check_button;
    GtkWidget *alignment;
    gboolean b;

    struct {
        const char *label;
        unsigned int mask;
        GCallback toggled_callback;
        const char *help_text;
    } config_check_button_entries[] =
    {
        {
            "Display Status Bar",
            CONFIG_PROPERTIES_DISPLAY_STATUS_BAR,
            G_CALLBACK(display_status_bar_toggled),
            __status_bar_help
        },
        {
            "Slider Text Entries",
            CONFIG_PROPERTIES_SLIDER_TEXT_ENTRIES,
            G_CALLBACK(slider_text_entries_toggled),
            __slider_text_entries_help
        },
        {
            "Include X Display Names in the Config File",
            CONFIG_PROPERTIES_INCLUDE_DISPLAY_NAME_IN_CONFIG_FILE,
            G_CALLBACK(display_name_toggled),
            __x_display_names_help
        },
        {
            "Show \"Really Quit?\" Dialog",
            CONFIG_PROPERTIES_SHOW_QUIT_DIALOG,
            G_CALLBACK(show_quit_dialog_toggled),
            __show_quit_dialog_help
        },
        {
            "Update Rules when an Application Profile Name changes",
            CONFIG_PROPERTIES_UPDATE_RULES_ON_PROFILE_NAME_CHANGE,
            G_CALLBACK(update_rules_on_profile_name_change_toggled),
            __update_rules_on_profile_name_change_help
        },

    };

    object = g_object_new(CTK_TYPE_CONFIG, NULL);

    ctk_config = CTK_CONFIG(object);

    ctk_config->conf = conf;
    ctk_config->pCtrlSystem = pCtrlSystem;

    gtk_box_set_spacing(GTK_BOX(ctk_config), 10);
    

    /* initialize the statusbar widget */
    ctk_statusbar_init(&ctk_config->status_bar);

#ifndef CTK_GTK3
    /* initialize the tooltips widget */

    ctk_config->tooltips.object = gtk_tooltips_new();
#endif

    /* banner */

    banner = ctk_banner_image_new(BANNER_ARTWORK_CONFIG);
    gtk_box_pack_start(GTK_BOX(ctk_config), banner, FALSE, FALSE, 0);
    
    /* "nvidia-settings Configuration" */

    hbox = gtk_hbox_new (FALSE, 5);
    gtk_box_pack_start(GTK_BOX(ctk_config), hbox, FALSE, FALSE, 0);

    label = gtk_label_new("nvidia-settings Configuration");
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 0);
    
    /* check buttons: Enable tooltips, Display statusbar, and Display
       slider text entries */

    vbox = gtk_vbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(ctk_config), vbox, FALSE, FALSE, 0);

    ctk_config->help_data = NULL;

    for (i = 0; i < ARRAY_LEN(config_check_button_entries); i++) {
        label = gtk_label_new(config_check_button_entries[i].label);

        check_button = gtk_check_button_new();
        gtk_container_add(GTK_CONTAINER(check_button), label);

        b = !!(ctk_config->conf->booleans & config_check_button_entries[i].mask);

        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), b);
        gtk_box_pack_start(GTK_BOX(vbox), check_button, FALSE, FALSE, 0);
        g_signal_connect(G_OBJECT(check_button), "toggled",
                         config_check_button_entries[i].toggled_callback,
                         ctk_config);
        ctk_config_set_tooltip_and_add_help_data(ctk_config,
                                                 check_button,
                                                 &ctk_config->help_data,
                                                 config_check_button_entries[i].label,
                                                 config_check_button_entries[i].help_text,
                                                 NULL);
    }

    ctk_config->help_data = g_list_reverse(ctk_config->help_data);
    
    /* timer list */
    
    ctk_config->timer_list_box = gtk_hbox_new(FALSE, 0);
    ctk_config->timer_list = create_timer_list(ctk_config);
    g_object_ref(ctk_config->timer_list);
    ctk_config->timer_list_visible = FALSE;

    gtk_box_pack_start(GTK_BOX(ctk_config), ctk_config->timer_list_box,
                       TRUE, TRUE, 0); 


    /* "Save Current Configuration" button */

    label = gtk_label_new("Save Current Configuration");
    hbox  = gtk_hbox_new(FALSE, 0);
    ctk_config->button_save_rc = gtk_button_new();
    alignment = gtk_alignment_new(1, 1, 0, 0);

    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
    gtk_container_add(GTK_CONTAINER(ctk_config->button_save_rc), hbox);
    gtk_container_add(GTK_CONTAINER(alignment), ctk_config->button_save_rc);
    gtk_box_pack_start(GTK_BOX(ctk_config), alignment, TRUE, TRUE, 0);

    /* Create the file selector for rc file */
    g_signal_connect(G_OBJECT(ctk_config->button_save_rc), "clicked",
                     G_CALLBACK(save_rc_clicked),
                     (gpointer) ctk_config);

    ctk_config_set_tooltip(ctk_config, ctk_config->button_save_rc,
                           __save_current_config_help);

    ctk_config->rc_filename = NULL;

    gtk_widget_show_all(GTK_WIDGET(ctk_config));

    return GTK_WIDGET(ctk_config);
}
FcitxSubConfigWidget*
fcitx_sub_config_widget_new(FcitxSubConfig* subconfig)
{
    FcitxSubConfigWidget* widget = g_object_new(FCITX_TYPE_SUB_CONFIG_WIDGET, NULL);

    widget->subconfig = subconfig;
    switch (subconfig->type) {
    case SC_ConfigFile: {
        gtk_orientable_set_orientation(GTK_ORIENTABLE(widget), GTK_ORIENTATION_VERTICAL);
        g_object_set(G_OBJECT(widget), "expand", TRUE, NULL);
        GtkWidget* view = gtk_tree_view_new();

        GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
        GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", 0, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
        GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
        gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);

        GtkWidget* swin = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
        gtk_container_add(GTK_CONTAINER(swin), view);
        gtk_box_pack_start(GTK_BOX(widget), swin, TRUE, TRUE, 0);
        g_object_set(G_OBJECT(swin), "margin-left", 5, "margin-right", 5, "shadow-type", GTK_SHADOW_IN, NULL);

        GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);

        gtk_tree_view_set_model(GTK_TREE_VIEW(view),
                                GTK_TREE_MODEL(store));

        g_hash_table_foreach(widget->subconfig->filelist, push_into_store_cb, store);

        GtkWidget* button = gtk_button_new();
        gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_BUTTON));
        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(open_subconfig_file), widget);
        GtkWidget* hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
        g_object_set(G_OBJECT(hbuttonbox), "margin", 5, NULL);
        gtk_box_pack_start(GTK_BOX(hbuttonbox), button, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(widget), hbuttonbox, FALSE, TRUE, 0);
        widget->view = view;
    }
    break;
    case SC_NativeFile: {
        GtkWidget* button = gtk_button_new();
        gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON));
        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(open_native_file), widget);
        gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE, 0);
    }
    break;
    case SC_Program: {
        GtkWidget* button = gtk_button_new();
        gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_BUTTON));
        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(run_program), widget);
        gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE, 0);
    }
    break;
    case SC_Plugin: {
        GtkWidget* button = gtk_button_new();
        gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_BUTTON));
        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(run_plugin), widget);
        gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE, 0);
    }
    break;
    default:
        break;
    }

    return widget;
}
예제 #21
0
/* Calculate the requested minimum size of the item */
static void
greeter_item_size_request (GreeterItemInfo *item,
			   GtkRequisition  *requisition_out,
			   gint             parent_width,
			   gint             parent_height,
			   GnomeCanvas     *canvas)
{
  GtkRequisition *req;
  GtkRequisition box_requisition = {0, 0}; 
  int set_width = 0;
  int set_height = 0;
  
  if (item->has_requisition)
    {
      *requisition_out = item->requisition;
      return;
    }

  req = &item->requisition;
  
  req->width = 0;
  req->height = 0;

  if (item->width_type == GREETER_ITEM_SIZE_BOX ||
      item->height_type == GREETER_ITEM_SIZE_BOX)
    {
      greeter_size_request_box (item,
				&box_requisition,
				canvas);
    }

  switch (item->width_type)
    {
    case GREETER_ITEM_SIZE_ABSOLUTE:
      set_width = (item->width > 0) ? item->width : parent_width + item->width;
      break;
    case GREETER_ITEM_SIZE_RELATIVE:
      set_width = item->width*parent_width / 100.0;
      break;
    case GREETER_ITEM_SIZE_BOX:
      set_width = box_requisition.width;
      break;
    case GREETER_ITEM_SIZE_SCALE:
    case GREETER_ITEM_SIZE_UNSET:
      break;
    }

  switch (item->height_type)
    {
    case GREETER_ITEM_SIZE_ABSOLUTE:
      set_height = (item->height > 0) ? item->height : parent_height + item->height;
      break;
    case GREETER_ITEM_SIZE_RELATIVE:
      set_height = item->height*parent_height / 100.0;
      break;
    case GREETER_ITEM_SIZE_BOX:
      set_height = box_requisition.height;
      break;
    case GREETER_ITEM_SIZE_SCALE:
    case GREETER_ITEM_SIZE_UNSET:
      break;
    }

  if (item->item_type == GREETER_ITEM_TYPE_LABEL)
    {
      int width, height;
      char *text;
      int max_width = G_MAXINT;

      /* This is not the ugly hack you're looking for.
       * You can go about your business.
       * Move Along
       */
      text = mdm_common_expand_text (item->data.text.orig_text);

      if (set_width > 0)
	      max_width = set_width;

      if (item->data.text.max_width < max_width)
	      max_width = item->data.text.max_width;

      if (item->data.text.max_screen_percent_width/100.0 * mdm_wm_screen.width < max_width)
	      max_width = item->data.text.max_screen_percent_width/100.0 * mdm_wm_screen.width;

      greeter_canvas_item_break_set_string (item,
					    text,
					    TRUE /* markup */,
					    max_width,
					    &width,
					    &height,
					    canvas,
					    NULL /* real_item */);

      req->width = width;
      req->height = height;

      g_free (text);
    }

  if (item->item_type == GREETER_ITEM_TYPE_PIXMAP)
    {
      req->width = gdk_pixbuf_get_width (item->data.pixmap.pixbufs[0]);
      req->height = gdk_pixbuf_get_height (item->data.pixmap.pixbufs[0]);
    }

  if (item->item_type == GREETER_ITEM_TYPE_SVG)
    {
      GdkPixbuf *svg;

      svg = rsvg_pixbuf_from_file (item->data.pixmap.files[0], NULL);
      req->width = gdk_pixbuf_get_width (svg);
      req->height = gdk_pixbuf_get_height (svg);
      g_object_unref (svg);
    }

  if (item->item_type == GREETER_ITEM_TYPE_BUTTON)
    {
#define ITEM_BUTTON_MIN_RECOMMANDED_WIDTH_OFFSET 15      
#define ITEM_BUTTON_MIN_RECOMMANDED_HEIGHT_OFFSET 10
      PangoLayout *layout;
      int pango_width, pango_height;
      int pix_width, pix_height;
      
      GtkWidget *dummy_w = gtk_button_new ();
      
      layout = gtk_widget_create_pango_layout (dummy_w, item->data.text.orig_text);
       
      pango_layout_get_size (layout, &pango_width, &pango_height);
      
      pix_height = PANGO_PIXELS (pango_height) + ITEM_BUTTON_MIN_RECOMMANDED_HEIGHT_OFFSET;
      pix_width = PANGO_PIXELS (pango_width) + ITEM_BUTTON_MIN_RECOMMANDED_WIDTH_OFFSET;

      if (pix_width > item->parent->box_min_width)
	req->width = pix_width;
      else
	req->width = item->parent->box_min_width;

      if (pix_height > item->parent->box_min_height)
	req->height = pix_height;
      else
	req->height = item->parent->box_min_height;
    }
 
  if (req->width > 0 && req->height > 0)
    {
      if (item->width_type == GREETER_ITEM_SIZE_SCALE && set_height > 0)
        set_width = (req->width * set_height) / req->height;
      else if (item->height_type == GREETER_ITEM_SIZE_SCALE && set_width > 0)
        set_height = (req->height * set_width) / req->width;
    }
  
  if (set_width > 0)
    req->width = set_width;
  if (set_height > 0)
    req->height = set_height;

  *requisition_out = item->requisition;
  item->has_requisition = TRUE;
}
예제 #22
0
static TBEditorWidget *tb_editor_create_dialog(MarlinViewWindow *mvw)
{
    GtkWidget *dialog, *vbox, *hbox, *vbox_buttons, *button_add, *button_remove;
    GtkWidget *swin_available, *swin_used, *tree_available, *tree_used, *label;
    GtkCellRenderer *text_renderer, *icon_renderer;
    GtkTreeViewColumn *column;
    TBEditorWidget *tbw = g_new(TBEditorWidget, 1);

    dialog = gtk_dialog_new_with_buttons(_("Customize Toolbar"),
                                         GTK_WINDOW (mvw),
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
    vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
    gtk_widget_set_name(dialog, "GeanyDialog");
    gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 300);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);

    tbw->store_available = gtk_list_store_new(TB_EDITOR_COLS_MAX,
                                              G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF);
    tbw->store_used = gtk_list_store_new(TB_EDITOR_COLS_MAX,
                                         G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF);

    label = gtk_label_new(_("Select items to be displayed on the toolbar. Items can be reordered by drag and drop."));
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);

    tree_available = gtk_tree_view_new();
    gtk_tree_view_set_model(GTK_TREE_VIEW(tree_available), GTK_TREE_MODEL(tbw->store_available));
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_available), TRUE);
    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(tbw->store_available), TB_EDITOR_COL_LABEL, GTK_SORT_ASCENDING);

    icon_renderer = gtk_cell_renderer_pixbuf_new();
    column = gtk_tree_view_column_new_with_attributes(NULL, icon_renderer, "pixbuf", TB_EDITOR_COL_ICON, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);

    text_renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Available Items"), text_renderer, "text", TB_EDITOR_COL_LABEL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);

    swin_available = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin_available),
                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin_available), GTK_SHADOW_ETCHED_IN);
    gtk_container_add(GTK_CONTAINER(swin_available), tree_available);

    tree_used = gtk_tree_view_new();
    gtk_tree_view_set_model(GTK_TREE_VIEW(tree_used), GTK_TREE_MODEL(tbw->store_used));
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_used), TRUE);
    gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_used), TRUE);

    icon_renderer = gtk_cell_renderer_pixbuf_new();
    column = gtk_tree_view_column_new_with_attributes(NULL, icon_renderer, "pixbuf", TB_EDITOR_COL_ICON, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);

    text_renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("Displayed Items"), text_renderer, "text", TB_EDITOR_COL_LABEL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);

    swin_used = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin_used),
                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin_used), GTK_SHADOW_ETCHED_IN);
    gtk_container_add(GTK_CONTAINER(swin_used), tree_used);

    /* drag'n'drop */
    gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tree_available), GDK_BUTTON1_MASK,
                                           tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tree_available),
                                         tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    g_signal_connect(tree_available, "drag-data-get",
                     G_CALLBACK(tb_editor_drag_data_get_cb), tbw);
    g_signal_connect(tree_available, "drag-data-received",
                     G_CALLBACK(tb_editor_drag_data_rcvd_cb), tbw);
    g_signal_connect(tree_available, "drag-motion",
                     G_CALLBACK(tb_editor_drag_motion_cb), tbw);

    gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tree_used), GDK_BUTTON1_MASK,
                                           tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tree_used),
                                         tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
    g_signal_connect(tree_used, "drag-data-get",
                     G_CALLBACK(tb_editor_drag_data_get_cb), tbw);
    g_signal_connect(tree_used, "drag-data-received",
                     G_CALLBACK(tb_editor_drag_data_rcvd_cb), tbw);
    g_signal_connect(tree_used, "drag-motion",
                     G_CALLBACK(tb_editor_drag_motion_cb), tbw);


    button_add = gtk_button_new();
    gtk_button_set_image(GTK_BUTTON(button_add),
                         gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
    button_remove = gtk_button_new();
    g_signal_connect(button_add, "clicked", G_CALLBACK(tb_editor_btn_add_clicked_cb), tbw);
    gtk_button_set_image(GTK_BUTTON(button_remove),
                         gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
    g_signal_connect(button_remove, "clicked", G_CALLBACK(tb_editor_btn_remove_clicked_cb), tbw);

    vbox_buttons = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
    /* FIXME this is a little hack'ish, any better ideas? */
    gtk_box_pack_start(GTK_BOX(vbox_buttons), gtk_label_new(""), TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox_buttons), button_add, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox_buttons), button_remove, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox_buttons), gtk_label_new(""), TRUE, TRUE, 0);

    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(hbox), swin_available, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), vbox_buttons, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), swin_used, TRUE, TRUE, 0);

    g_object_set (label, "margin", 5, NULL);
    g_object_set (hbox, "margin", 5, NULL);

    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

    gtk_widget_show_all(vbox);

    g_object_unref(tbw->store_available);
    g_object_unref(tbw->store_used);

    tbw->dialog = dialog;
    tbw->tree_available = GTK_TREE_VIEW(tree_available);
    tbw->tree_used = GTK_TREE_VIEW(tree_used);

    tbw->last_drag_path = NULL;

    return tbw;
}
예제 #23
0
파일: about.c 프로젝트: prodigeni/geany
static GtkWidget *create_dialog(void)
{
	GtkWidget *dialog;
	GtkWidget *header_image;
	GtkWidget *header_label;
	GtkWidget *label_info;
	GtkWidget *codename_label;
	GtkWidget *builddate_label;
	GtkWidget *url_button;
	GtkWidget *cop_label;
	GtkWidget *label;
	GtkWidget *license_textview;
	GtkWidget *notebook;
	GtkWidget *box;
	GtkWidget *credits_scrollwin;
	GtkWidget *table;
	GtkWidget *license_scrollwin;
	GtkWidget *info_box;
	GtkWidget *header_hbox;
	GtkWidget *header_eventbox;
	GtkTextBuffer* tb;
	gchar *license_text = NULL;
	gchar buffer[512];
	gchar buffer2[128];
	guint i, row = 0;
	gchar *build_date;

	dialog = gtk_dialog_new();

	/* configure dialog */
	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_widgets.window));
	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_window_set_title(GTK_WINDOW(dialog), _("About Geany"));
	gtk_window_set_icon_name(GTK_WINDOW(dialog), "geany");
	gtk_widget_set_name(dialog, "GeanyDialog");
	gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
	gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
	g_signal_connect(dialog, "key-press-event", G_CALLBACK(gb_on_key_pressed), NULL);

	/* create header */
	header_eventbox = gtk_event_box_new();
	gtk_widget_show(header_eventbox);
	header_hbox = gtk_hbox_new(FALSE, 12);
	gtk_container_set_border_width(GTK_CONTAINER(header_hbox), 4);
	gtk_widget_show(header_hbox);
	gtk_container_add(GTK_CONTAINER(header_eventbox), header_hbox);
	header_image = gtk_image_new_from_icon_name("geany", GTK_ICON_SIZE_DIALOG);
	gtk_box_pack_start(GTK_BOX(header_hbox), header_image, FALSE, FALSE, 0);
	header_label = gtk_label_new(NULL);
	gtk_label_set_use_markup(GTK_LABEL(header_label), TRUE);
	/* print the subversion revision generated by ./configure if it is available */
	g_snprintf(buffer, sizeof(buffer), HEADER, main_get_version_string());
	gtk_label_set_markup(GTK_LABEL(header_label), buffer);
	gtk_widget_show(header_label);
	gtk_box_pack_start(GTK_BOX(header_hbox), header_label, FALSE, FALSE, 0);
	gtk_widget_set_state(header_eventbox, GTK_STATE_SELECTED);
	gtk_widget_set_state(header_label, GTK_STATE_SELECTED);
	gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), header_eventbox, FALSE, FALSE, 0);

	/* create notebook */
	notebook = gtk_notebook_new();
	gtk_widget_show(notebook);
	gtk_container_set_border_width(GTK_CONTAINER(notebook), 2);
	gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), notebook, TRUE, TRUE, 0);

	/* create "Info" tab */
	info_box = gtk_vbox_new(FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(info_box), 6);
	gtk_widget_show(info_box);

	label_info = gtk_label_new(NULL);
	gtk_label_set_justify(GTK_LABEL(label_info), GTK_JUSTIFY_CENTER);
	gtk_label_set_selectable(GTK_LABEL(label_info), TRUE);
	gtk_label_set_use_markup(GTK_LABEL(label_info), TRUE);
	g_snprintf(buffer, sizeof(buffer), INFO, _("A fast and lightweight IDE"));
	gtk_label_set_markup(GTK_LABEL(label_info), buffer);
	gtk_misc_set_padding(GTK_MISC(label_info), 2, 11);
	gtk_widget_show(label_info);
	gtk_box_pack_start(GTK_BOX(info_box), label_info, FALSE, FALSE, 0);

	/* Codename label */
	codename_label = gtk_label_new(NULL);
	gtk_label_set_justify(GTK_LABEL(codename_label), GTK_JUSTIFY_CENTER);
	gtk_label_set_selectable(GTK_LABEL(codename_label), TRUE);
	gtk_label_set_use_markup(GTK_LABEL(codename_label), TRUE);
	gtk_label_set_markup(GTK_LABEL(codename_label), CODENAME);
	gtk_misc_set_padding(GTK_MISC(codename_label), 2, 8);
	gtk_widget_show(codename_label);
	gtk_box_pack_start(GTK_BOX(info_box), codename_label, FALSE, FALSE, 0);

	/* build date label */
	builddate_label = gtk_label_new(NULL);
	gtk_label_set_justify(GTK_LABEL(builddate_label), GTK_JUSTIFY_CENTER);
	gtk_label_set_selectable(GTK_LABEL(builddate_label), TRUE);
	gtk_label_set_use_markup(GTK_LABEL(builddate_label), TRUE);
	build_date = utils_parse_and_format_build_date(__DATE__);
	g_snprintf(buffer2, sizeof(buffer2), _("(built on or after %s)"), build_date);
	g_free(build_date);
	g_snprintf(buffer, sizeof(buffer), BUILDDATE, buffer2);
	gtk_label_set_markup(GTK_LABEL(builddate_label), buffer);
	gtk_misc_set_padding(GTK_MISC(builddate_label), 2, 2);
	gtk_widget_show(builddate_label);
	gtk_box_pack_start(GTK_BOX(info_box), builddate_label, FALSE, FALSE, 0);

	box = gtk_hbutton_box_new();
	url_button = gtk_button_new();
	gtk_button_set_relief(GTK_BUTTON(url_button), GTK_RELIEF_NONE);
	g_signal_connect(url_button, "clicked", G_CALLBACK(homepage_clicked), (gpointer)GEANY_HOMEPAGE);
	label = gtk_label_new(NULL);
	gtk_label_set_text(GTK_LABEL(label), GEANY_HOMEPAGE);
	gtk_widget_show(label);
	gtk_container_add(GTK_CONTAINER(url_button), label);
	gtk_widget_show(url_button);
	gtk_box_pack_start(GTK_BOX(box), url_button, FALSE, FALSE, 0);
	gtk_widget_show(box);
	gtk_box_pack_start(GTK_BOX(info_box), box, FALSE, FALSE, 10);

	/* copyright label */
	cop_label = gtk_label_new(NULL);
	gtk_label_set_justify(GTK_LABEL(cop_label), GTK_JUSTIFY_CENTER);
	gtk_label_set_selectable(GTK_LABEL(cop_label), FALSE);
	gtk_label_set_use_markup(GTK_LABEL(cop_label), TRUE);
	gtk_label_set_markup(GTK_LABEL(cop_label), COPYRIGHT);
	gtk_misc_set_padding(GTK_MISC(cop_label), 2, 10);
	gtk_widget_show(cop_label);
	gtk_box_pack_start(GTK_BOX(info_box), cop_label, FALSE, FALSE, 0);
	/*gtk_container_add(GTK_CONTAINER(info_box), cop_label); */

	label = gtk_label_new(_("Info"));
	gtk_widget_show(label);
	gtk_widget_show_all(info_box);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_box, label);

	/* create "Credits" tab */
	credits_scrollwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_container_set_border_width(GTK_CONTAINER(credits_scrollwin), 6);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(credits_scrollwin),
		GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

	table = gtk_table_new(23 + translators_len + prev_translators_len, 3, FALSE);
	gtk_table_set_col_spacings(GTK_TABLE(table), 10);

	row = 0;
	g_snprintf(buffer, sizeof(buffer),
		"<span size=\"larger\" weight=\"bold\">%s</span>", _("Developers"));
	label = gtk_label_new(buffer);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, GTK_FILL, 0, 0, 5);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer), "Colomban Wendling - %s", _("maintainer"));
	ROW(buffer, row, 0, 0, 0, 1);
	row++;
	ROW("&lt;[email protected]&gt;", row, 0, 0, 0, 1);
	row++;
	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer), "Nick Treleaven - %s", _("developer"));
	ROW(buffer, row, 0, 0, 0, 1);
	row++;
	ROW("&lt;[email protected]&gt;", row, 0, 0, 0, 1);
	row++;
	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer), "Enrico Tröger - %s", _("developer"));
	ROW(buffer, row, 0, 0, 0, 1);
	row++;
	ROW("&lt;[email protected]&gt;", row, 0, 0, 0, 1);
	row++;
	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer), "Matthew Brush - %s", _("developer"));
	ROW(buffer, row, 0, 0, 0, 1);
	row++;
	ROW("&lt;[email protected]&gt;", row, 0, 0, 0, 1);
	row++;
	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer), "Frank Lanitz - %s", _("translation maintainer"));
	ROW(buffer, row, 0, 0, 0, 1);
	row++;
	ROW("&lt;[email protected]&gt;", row, 0, 0, 0, 1);
	row++;
	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer),
		"<span size=\"larger\" weight=\"bold\">%s</span>", _("Translators"));
	label = gtk_label_new(buffer);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1,
					(GtkAttachOptions) (GTK_FILL),
					(GtkAttachOptions) (0), 0, 5);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	row++;

	for (i = 0; i < translators_len; i++)
	{
		ROW(translators[i][0], row, 0, 1, 4, 0);
		ROW(translators[i][1], row, 1, 0, 4, 0);
		row++;
	}

	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer),
		"<span size=\"larger\" weight=\"bold\">%s</span>", _("Previous Translators"));
	label = gtk_label_new(buffer);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1,
					(GtkAttachOptions) (GTK_FILL),
					(GtkAttachOptions) (0), 0, 5);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	row++;

	for (i = 0; i < prev_translators_len; i++)
	{
		ROW(prev_translators[i][0], row, 0, 1, 4, 0);
		ROW(prev_translators[i][1], row, 1, 0, 4, 0);
		row++;
	}


	ROW("", row, 0, 0, 0, 0);
	row++;

	g_snprintf(buffer, sizeof(buffer),
		"<span size=\"larger\" weight=\"bold\">%s</span>", _("Contributors"));
	label = gtk_label_new(buffer);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1,
					(GtkAttachOptions) (GTK_FILL),
					(GtkAttachOptions) (0), 0, 5);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	row++;

	g_snprintf(buffer, sizeof(buffer),
		_("Some of the many contributors (for a more detailed list, see the file %s):"),
#ifdef G_OS_WIN32
			"Thanks.txt"
#else
			"THANKS"
#endif
		);
	label = geany_wrap_label_new(buffer);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1,
					(GtkAttachOptions) (GTK_FILL),
					(GtkAttachOptions) (0), 0, 5);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	row++;

	label = geany_wrap_label_new(contributors);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1,
					(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
					(GtkAttachOptions) (0), 0, 5);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	row++;

	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(credits_scrollwin), table);
	gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_widget_get_parent(table)), GTK_SHADOW_NONE);
	gtk_widget_show_all(table);
	label = gtk_label_new(_("Credits"));
	gtk_widget_show(label);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), credits_scrollwin, label);

	/* create "License" tab */
	license_scrollwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_container_set_border_width(GTK_CONTAINER(license_scrollwin), 6);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(license_scrollwin),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(license_scrollwin), GTK_SHADOW_IN);
	license_textview = gtk_text_view_new();
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(license_textview), 2);
	gtk_text_view_set_right_margin(GTK_TEXT_VIEW(license_textview), 2);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(license_textview), FALSE);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(license_textview), FALSE);
	gtk_widget_show(license_textview);
	gtk_container_add(GTK_CONTAINER(license_scrollwin), license_textview);
	label = gtk_label_new(_("License"));
	gtk_widget_show(label);

	g_snprintf(buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S "GPL-2", app->datadir);

	g_file_get_contents(buffer, &license_text, NULL, NULL);
	if (license_text == NULL)
	{
		license_text = g_strdup(
			_("License text could not be found, please visit http://www.gnu.org/licenses/gpl-2.0.txt to view it online."));
	}
	tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(license_textview));
	gtk_text_buffer_set_text(tb, license_text, -1);

	g_free(license_text);

	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), license_scrollwin, label);

	gtk_widget_show_all(dialog);
	return dialog;
}
예제 #24
0
GtkWindow* create_notification(UrlClickedCb url_clicked)
{
	GtkWidget* win;
	GtkWidget* main_vbox;
	GtkWidget* vbox;
	GtkWidget* close_button;
	GtkWidget* image;
	GtkWidget* alignment;
	AtkObject* atkobj;
	GtkRcStyle* rcstyle;
	WindowData* windata;
	#ifdef USE_COMPOSITE
		GdkColormap* colormap;
		GdkScreen* screen;
	#endif

	windata = g_new0(WindowData, 1);
	windata->urgency = URGENCY_NORMAL;
	windata->url_clicked = url_clicked;

	win = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
	gtk_widget_set_app_paintable(win, TRUE);
	g_signal_connect(G_OBJECT(win), "style-set", G_CALLBACK(on_style_set), windata);
	g_signal_connect(G_OBJECT(win), "map-event", G_CALLBACK(on_window_map), windata);
	g_signal_connect(G_OBJECT(win), "expose-event", G_CALLBACK(on_window_expose), windata);
	g_signal_connect(G_OBJECT(win), "realize", G_CALLBACK(on_window_realize), windata);

	windata->win = win;

	windata->composited = FALSE;

	#ifdef USE_COMPOSITE
		screen = gtk_window_get_screen(GTK_WINDOW(win));
		colormap = gdk_screen_get_rgba_colormap(screen);

		if (colormap != NULL)
		{
			gtk_widget_set_colormap(win, colormap);

			if (gdk_screen_is_composited(screen))
			{
				windata->composited = TRUE;
			}
		}

		g_signal_connect(win, "composited-changed", G_CALLBACK(on_composited_changed), windata);
	#endif

	gtk_window_set_title(GTK_WINDOW(win), "Notification");
	gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_NOTIFICATION);
	gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);

	g_object_set_data_full(G_OBJECT(win), "windata", windata, (GDestroyNotify) destroy_windata);
	atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT);

	g_signal_connect(G_OBJECT(win), "configure-event", G_CALLBACK(on_configure_event), windata);

	main_vbox = gtk_vbox_new(FALSE, 0);
	g_signal_connect(G_OBJECT(main_vbox), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(main_vbox);
	gtk_container_add(GTK_CONTAINER(win), main_vbox);
	gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 12);

	windata->main_hbox = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(windata->main_hbox);
	gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox, FALSE, FALSE, 0);

	/* First row (icon, vbox, close) */
	windata->iconbox = gtk_alignment_new(0.5, 0, 0, 0);
	gtk_widget_show(windata->iconbox);
	gtk_alignment_set_padding(GTK_ALIGNMENT(windata->iconbox), 5, 0, 0, 0);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), windata->iconbox, FALSE, FALSE, 0);
	gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);

	windata->icon = gtk_image_new();
	gtk_widget_show(windata->icon);
	gtk_container_add(GTK_CONTAINER(windata->iconbox), windata->icon);

	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);

	/* Add the close button */
	alignment = gtk_alignment_new(0.5, 0, 0, 0);
	gtk_widget_show(alignment);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), alignment, FALSE, FALSE, 0);

	close_button = gtk_button_new();
	g_signal_connect(G_OBJECT(close_button), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(close_button);
	windata->close_button = close_button;
	gtk_container_add(GTK_CONTAINER(alignment), close_button);
	gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
	gtk_container_set_border_width(GTK_CONTAINER(close_button), 0);
	g_signal_connect_swapped(G_OBJECT(close_button), "clicked", G_CALLBACK(gtk_widget_destroy), win);

	rcstyle = gtk_rc_style_new();
	rcstyle->xthickness = rcstyle->ythickness = 0;
	gtk_widget_modify_style(close_button, rcstyle);
	g_object_unref(rcstyle);

	atkobj = gtk_widget_get_accessible(close_button);
	atk_action_set_description(ATK_ACTION(atkobj), 0, "Closes the notification.");
	atk_object_set_name(atkobj, "");
	atk_object_set_description(atkobj, "Closes the notification.");

	image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	gtk_container_add(GTK_CONTAINER(close_button), image);

	/* center vbox */
	windata->summary_label = gtk_label_new(NULL);
	g_signal_connect(G_OBJECT(windata->summary_label), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(windata->summary_label);
	gtk_box_pack_start(GTK_BOX(vbox), windata->summary_label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0);
	gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);

	atkobj = gtk_widget_get_accessible(windata->summary_label);
	atk_object_set_description(atkobj, "Notification summary text.");

	windata->content_hbox = gtk_hbox_new(FALSE, 6);
	gtk_widget_show(windata->content_hbox);
	gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);


	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0);

	windata->body_label = gtk_label_new(NULL);
	g_signal_connect(G_OBJECT(windata->body_label), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(windata->body_label);
	gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0);
	gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
	g_signal_connect_swapped(G_OBJECT(windata->body_label), "activate-link", G_CALLBACK(windata->url_clicked), win);

	atkobj = gtk_widget_get_accessible(windata->body_label);
	atk_object_set_description(atkobj, "Notification body text.");

	alignment = gtk_alignment_new(1, 0.5, 0, 0);
	gtk_widget_show(alignment);
	gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);

	windata->actions_box = gtk_hbox_new(FALSE, 6);
	gtk_widget_show(windata->actions_box);
	gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);

	return GTK_WINDOW(win);
}
예제 #25
0
static void
add_address_row (CEPageIP6   *page,
                 const gchar *address,
                 const gchar *network,
                 const gchar *gateway)
{
        GtkWidget *row;
        GtkWidget *row_grid;
        GtkWidget *label;
        GtkWidget *widget;
        GtkWidget *delete_button;
        GtkWidget *image;

        row = gtk_list_box_row_new ();

        row_grid = gtk_grid_new ();
        label = gtk_label_new (_("Address"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "address", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), address);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);

        label = gtk_label_new (_("Prefix"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "prefix", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), network);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);

        label = gtk_label_new (_("Gateway"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "gateway", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), gateway);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);

        delete_button = gtk_button_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
        g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page);
        image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
        atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Address"));
        gtk_button_set_image (GTK_BUTTON (delete_button), image);
        gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 2, 1, 1);
        g_object_set_data (G_OBJECT (row), "delete-button", delete_button);

        gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
        gtk_widget_set_margin_left (row_grid, 10);
        gtk_widget_set_margin_right (row_grid, 10);
        gtk_widget_set_margin_top (row_grid, 10);
        gtk_widget_set_margin_bottom (row_grid, 10);
        gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);

        gtk_container_add (GTK_CONTAINER (row), row_grid);
        gtk_widget_show_all (row);
        gtk_container_add (GTK_CONTAINER (page->address_list), row);

        update_row_sensitivity (page, page->address_list);
}
예제 #26
0
DialogSimulator *
dialog_simulator_new ()
{
  register int i;
  register DialogSimulator *dlg;
  char *str_item_bar[N_DIALOG_SIMULATOR_ITEM_BAR] = { gettext ("_Channel"),
    gettext ("_Simulate"), gettext ("_Graphical"), gettext ("_Help")
  }, *str_item_system[N_DIALOG_SIMULATOR_ITEM_SYSTEM] =
  {
  gettext ("_New"),
      gettext ("_Open"), gettext ("_Edit"), gettext ("_Save"),
      gettext ("S_ave as"), NULL, gettext ("E_xit")},
    *str_item_simulate[N_DIALOG_SIMULATOR_ITEM_SIMULATE] =
  {
  gettext ("_Start"), gettext ("Sto_p"), NULL,
      gettext ("Conse_rvation error"), NULL,
      gettext ("Sa_ve solution"), gettext ("Save _graphical")},
    *str_item_graphic[N_DIALOG_SIMULATOR_ITEM_GRAPHIC] =
  {
  gettext ("_Options"),
      NULL, gettext ("_View animation"), gettext ("_Stop animation")},
    *str_item_help[N_DIALOG_SIMULATOR_ITEM_HELP] =
  {
  gettext ("_Help"), gettext ("_About")},
    *str_buttons[N_DIALOG_SIMULATOR_BUTTONS] =
  {
  gettext ("Exit"), NULL,
      gettext ("New system"), gettext ("Open system"),
      gettext ("Edit system"), gettext ("Save system"),
      gettext ("Save system as"), NULL, gettext ("Start simulation"),
      gettext ("Stop simulation"), gettext ("Conservation error"),
      gettext ("Save solution"), gettext ("Save graphical"), NULL,
      gettext ("Graphical options"), gettext ("View animation"),
      gettext ("Stop animation"), NULL, gettext ("Help"), gettext ("About")},
    *image_buttons[N_DIALOG_SIMULATOR_BUTTONS] =
  {
  "application-exit", NULL,
      "document-new", "document-open", "document-properties",
      "document-save", "document-save-as", NULL,
      "system-run", "process-stop",
      "dialog-information", "document-revert",
      "document-print", NULL,
      "preferences-system", "call-start",
      "call-stop", NULL, "help-browser", "help-about"};

  dlg = (DialogSimulator *) g_try_malloc (sizeof (DialogSimulator));
  if (!dlg)
    return 0;

  dlg->menu = (GtkMenuBar *) gtk_menu_bar_new ();
  for (i = 0; i < N_DIALOG_SIMULATOR_ITEM_BAR; ++i)
    {
      if (str_item_bar[i])
        dlg->item_bar[i] = (GtkMenuItem *) gtk_menu_item_new_with_mnemonic
          (str_item_bar[i]);
      else
        dlg->item_bar[i] = (GtkMenuItem *) gtk_separator_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (dlg->menu),
                             GTK_WIDGET (dlg->item_bar[i]));
    }

  dlg->menu_system = (GtkMenu *) gtk_menu_new ();
  for (i = 0; i < N_DIALOG_SIMULATOR_ITEM_SYSTEM; ++i)
    {
      if (str_item_system[i])
        dlg->item_system[i] = (GtkMenuItem *) gtk_menu_item_new_with_mnemonic
          (str_item_system[i]);
      else
        dlg->item_system[i] = (GtkMenuItem *) gtk_separator_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (dlg->menu_system),
                             GTK_WIDGET (dlg->item_system[i]));
    }
  gtk_menu_item_set_submenu (dlg->item_bar[0], GTK_WIDGET (dlg->menu_system));

  dlg->menu_simulate = (GtkMenu *) gtk_menu_new ();
  for (i = 0; i < N_DIALOG_SIMULATOR_ITEM_SIMULATE; ++i)
    {
      if (str_item_simulate[i])
        dlg->item_simulate[i] = (GtkMenuItem *)
          gtk_menu_item_new_with_mnemonic (str_item_simulate[i]);
      else
        dlg->item_simulate[i] = (GtkMenuItem *) gtk_separator_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (dlg->menu_simulate),
                             GTK_WIDGET (dlg->item_simulate[i]));
    }
  gtk_menu_item_set_submenu (dlg->item_bar[1], GTK_WIDGET (dlg->menu_simulate));

  dlg->menu_graphic = (GtkMenu *) gtk_menu_new ();
  for (i = 0; i < N_DIALOG_SIMULATOR_ITEM_GRAPHIC; ++i)
    {
      if (str_item_graphic[i])
        dlg->item_graphic[i] = (GtkMenuItem *)
          gtk_menu_item_new_with_mnemonic (str_item_graphic[i]);
      else
        dlg->item_graphic[i] = (GtkMenuItem *) gtk_separator_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (dlg->menu_graphic),
                             GTK_WIDGET (dlg->item_graphic[i]));
    }
  gtk_menu_item_set_submenu (dlg->item_bar[2], GTK_WIDGET (dlg->menu_graphic));

  dlg->menu_help = (GtkMenu *) gtk_menu_new ();
  for (i = 0; i < N_DIALOG_SIMULATOR_ITEM_HELP; ++i)
    {
      if (str_item_help[i])
        dlg->item_help[i] = (GtkMenuItem *) gtk_menu_item_new_with_mnemonic
          (str_item_help[i]);
      else
        dlg->item_help[i] = (GtkMenuItem *) gtk_separator_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (dlg->menu_help),
                             GTK_WIDGET (dlg->item_help[i]));
    }
  gtk_menu_item_set_submenu (dlg->item_bar[3], GTK_WIDGET (dlg->menu_help));

  dlg->toolbar = (GtkToolbar *) gtk_toolbar_new ();
  for (i = 0; i < N_DIALOG_SIMULATOR_BUTTONS; ++i)
    {
      if (str_buttons[i])
        {
          dlg->button[i] = (GtkToolItem *) gtk_tool_button_new
            (gtk_image_new_from_icon_name
             (image_buttons[i], GTK_ICON_SIZE_SMALL_TOOLBAR), str_buttons[i]);
          gtk_widget_set_tooltip_text
            (GTK_WIDGET (dlg->button[i]), str_buttons[i]);
        }
      else
        dlg->button[i] = (GtkToolItem *) gtk_separator_tool_item_new ();
      gtk_toolbar_insert (dlg->toolbar, dlg->button[i], -1);
    }

  dlg->graphic = jbw_graphic_new (0, 6, 6, 6, draw_graphic);
  jbw_graphic_set_logo (dlg->graphic, "swigs.png");
  dlg->label_simulation
    = (GtkLabel *) gtk_label_new (gettext ("Simulation time"));
  dlg->progress_simulation = (GtkProgressBar *) gtk_progress_bar_new ();

  dlg->label_cpu = (GtkLabel *) gtk_label_new (gettext ("Computational time"));
  gtk_widget_set_sensitive (GTK_WIDGET (dlg->label_cpu), 0);
  dlg->entry_cpu = (JBWFloatEntry *) jbw_float_entry_new ();

  dlg->label_error =
    (GtkLabel *) gtk_label_new (gettext ("Conservation error"));
  dlg->entry_error = (JBWFloatEntry *) jbw_float_entry_new ();

  dlg->box_bar = (GtkGrid *) gtk_grid_new ();
  gtk_grid_attach (dlg->box_bar, GTK_WIDGET (dlg->label_simulation),
                   0, 0, 1, 1);
  gtk_grid_attach (dlg->box_bar, GTK_WIDGET (dlg->progress_simulation),
                   1, 0, 1, 1);
  gtk_grid_attach (dlg->box_bar, GTK_WIDGET (dlg->label_cpu), 2, 0, 1, 1);
  gtk_grid_attach (dlg->box_bar, GTK_WIDGET (dlg->entry_cpu), 3, 0, 1, 1);
  gtk_grid_attach (dlg->box_bar, GTK_WIDGET (dlg->label_error), 4, 0, 1, 1);
  gtk_grid_attach (dlg->box_bar, GTK_WIDGET (dlg->entry_error), 5, 0, 1, 1);

  dlg->button_bar = (GtkButton *) gtk_button_new ();
  gtk_container_add (GTK_CONTAINER (dlg->button_bar),
                     GTK_WIDGET (dlg->box_bar));
  gtk_widget_set_sensitive (GTK_WIDGET (dlg->button_bar), 0);

  dlg->box = (GtkGrid *) gtk_grid_new ();
  gtk_grid_attach (dlg->box, GTK_WIDGET (dlg->menu), 0, 0, 1, 1);
  gtk_grid_attach (dlg->box, GTK_WIDGET (dlg->toolbar), 0, 1, 1, 1);
  gtk_grid_attach (dlg->box, GTK_WIDGET (dlg->button_bar), 0, 2, 1, 1);

  dlg->pixbuf = gtk_image_get_pixbuf
    (GTK_IMAGE (gtk_image_new_from_file ("logo.png")));

  dlg->window = (GtkWindow *) gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (dlg->window, "SWIGS");
  gtk_window_set_icon (dlg->window, dlg->pixbuf);
  gtk_container_add (GTK_CONTAINER (dlg->window), GTK_WIDGET (dlg->box));
  gtk_widget_show_all (GTK_WIDGET (dlg->window));
#if JBW_GRAPHIC==JBW_GRAPHIC_GLUT
  g_signal_connect (dlg->window, "destroy", glutLeaveMainLoop, NULL);
#else
  g_signal_connect (dlg->window, "destroy", gtk_main_quit, NULL);
#endif

  g_signal_connect
    (dlg->item_system[0], "activate", dialog_simulator_new_system, 0);
  g_signal_connect_swapped (dlg->item_system[1], "activate",
                            (void (*)) dialog_open_system_new,
                            dialog_open_system);
  g_signal_connect (dlg->item_system[2], "activate", dialog_simulator_edit, 0);
  g_signal_connect_swapped
    (dlg->item_system[3], "activate", (void (*)) system_save_xml, sys);
  g_signal_connect
    (dlg->item_system[4], "activate", dialog_simulator_save_as, 0);
  g_signal_connect (dlg->item_system[6], "activate", (void (*)) exit, 0);
  g_signal_connect_swapped (dlg->item_simulate[0], "activate",
                            (void (*)) dialog_simulator_start, dlg);
  g_signal_connect
    (dlg->item_simulate[1], "activate", dialog_simulator_stop, 0);
  g_signal_connect
    (dlg->item_simulate[3], "activate", dialog_simulator_mass, 0);
  g_signal_connect
    (dlg->item_simulate[5], "activate", dialog_save_solution_new, 0);
  g_signal_connect
    (dlg->item_simulate[6], "activate", dialog_save_graphical_new, 0);
  g_signal_connect_swapped (dlg->item_graphic[0], "activate",
                            (void (*)) dialog_graphical_options_new,
                            dlg->window);
  g_signal_connect_swapped (dlg->item_graphic[2], "activate",
                            (void *) dialog_simulator_animate, dlg);
  g_signal_connect (dlg->item_graphic[3], "activate", dialog_simulator_stop, 0);
  g_signal_connect_swapped
    (dlg->item_help[0], "activate", dialog_simulator_help, dlg);
  g_signal_connect_swapped
    (dlg->item_help[1], "activate", dialog_simulator_about, dlg);

  g_signal_connect (dlg->button[0], "clicked", (void (*)) exit, 0);
  g_signal_connect (dlg->button[2], "clicked", dialog_simulator_new_system, 0);
  g_signal_connect_swapped (dlg->button[3], "clicked",
                            (void (*)) dialog_open_system_new,
                            dialog_open_system);
  g_signal_connect (dlg->button[4], "clicked", dialog_simulator_edit, 0);
  g_signal_connect_swapped
    (dlg->button[5], "clicked", (void (*)) system_save_xml, sys);
  g_signal_connect (dlg->button[6], "clicked", dialog_simulator_save_as, 0);
  g_signal_connect_swapped
    (dlg->button[8], "clicked", (void (*)) dialog_simulator_start, dlg);
  g_signal_connect (dlg->button[9], "clicked", dialog_simulator_stop, 0);
  g_signal_connect (dlg->button[10], "clicked", dialog_simulator_mass, 0);
  g_signal_connect (dlg->button[11], "clicked", dialog_save_solution_new, 0);
  g_signal_connect (dlg->button[12], "clicked", dialog_save_graphical_new, 0);
  g_signal_connect_swapped (dlg->button[14], "clicked",
                            (void (*)) dialog_graphical_options_new,
                            dlg->window);
  g_signal_connect_swapped (dlg->button[15], "clicked",
                            (void *) dialog_simulator_animate, dlg);
  g_signal_connect (dlg->button[16], "clicked", dialog_simulator_stop, 0);
  g_signal_connect_swapped
    (dlg->button[18], "clicked", (void (*)) dialog_simulator_help, dlg);
  g_signal_connect_swapped
    (dlg->button[19], "clicked", (void (*)) dialog_simulator_about, dlg);

  dialog_simulator_actualize (dlg);

  window_parent = dlg->window;

  return dlg;
}
/* Create new notification */
GtkWindow *
create_notification(UrlClickedCb url_clicked)
{
	GtkWidget *spacer;
	GtkWidget *win;
	GtkWidget *drawbox;
	GtkWidget *main_vbox;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *close_button;
	GtkWidget *image;
	GtkWidget *alignment;
	AtkObject *atkobj;
	WindowData *windata;
	GdkColormap *colormap;
	GdkScreen *screen;

	windata = g_new0(WindowData, 1);
	windata->urgency = URGENCY_NORMAL;
	windata->url_clicked = url_clicked;

	win = gtk_window_new(GTK_WINDOW_POPUP);
	windata->win = win;

	windata->enable_transparency = FALSE;
	screen = gtk_window_get_screen(GTK_WINDOW(win));
	colormap = gdk_screen_get_rgba_colormap(screen);

	if (colormap != NULL)
	{
		gtk_widget_set_colormap(win, colormap);
		if (gdk_screen_is_composited(screen))
			windata->enable_transparency = TRUE;
	}

	gtk_window_set_title(GTK_WINDOW(win), "Notification");
	gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
	gtk_widget_realize(win);
	gtk_widget_set_size_request(win, WIDTH, -1);

	g_object_set_data_full(G_OBJECT(win), "windata", windata,
						   (GDestroyNotify)destroy_windata);
	atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT);

	g_signal_connect(G_OBJECT(win), "configure_event",
					 G_CALLBACK(configure_event_cb), windata);

	/*
	 * For some reason, there are occasionally graphics glitches when
	 * repainting the window. Despite filling the window with a background
	 * color, parts of the other windows on the screen or the shadows around
	 * notifications will appear on the notification. Somehow, adding this
	 * eventbox makes that problem just go away. Whatever works for now.
	 */
	drawbox = gtk_event_box_new();
	gtk_widget_show(drawbox);
	gtk_container_add(GTK_CONTAINER(win), drawbox);

	main_vbox = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(main_vbox);
	gtk_container_add(GTK_CONTAINER(drawbox), main_vbox);
	gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);

	g_signal_connect(G_OBJECT(main_vbox), "expose_event",
					 G_CALLBACK(paint_window), windata);

	windata->top_spacer = gtk_image_new();
	gtk_box_pack_start(GTK_BOX(main_vbox), windata->top_spacer,
					   FALSE, FALSE, 0);
	gtk_widget_set_size_request(windata->top_spacer, -1, DEFAULT_ARROW_HEIGHT);

	windata->main_hbox = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(windata->main_hbox);
	gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox,
					   FALSE, FALSE, 0);

	windata->bottom_spacer = gtk_image_new();
	gtk_box_pack_start(GTK_BOX(main_vbox), windata->bottom_spacer,
					   FALSE, FALSE, 0);
	gtk_widget_set_size_request(windata->bottom_spacer, -1,
								DEFAULT_ARROW_HEIGHT);

	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);

	hbox = gtk_hbox_new(FALSE, 6);
	gtk_widget_show(hbox);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	spacer = gtk_image_new();
	gtk_widget_show(spacer);
	gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0);
	gtk_widget_set_size_request(spacer, SPACER_LEFT, -1);

	windata->summary_label = gtk_label_new(NULL);
	gtk_widget_show(windata->summary_label);
	gtk_box_pack_start(GTK_BOX(hbox), windata->summary_label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0);
	gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);

	atkobj = gtk_widget_get_accessible(windata->summary_label);
	atk_object_set_description(atkobj, "Notification summary text.");

	/* Add the close button */
	close_button = gtk_button_new();
	gtk_widget_show(close_button);
	gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
	gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
	gtk_container_set_border_width(GTK_CONTAINER(close_button), 0);
	gtk_widget_set_size_request(close_button, 24, 24);
	g_signal_connect_swapped(G_OBJECT(close_button), "clicked",
							 G_CALLBACK(gtk_widget_destroy), win);

	atkobj = gtk_widget_get_accessible(close_button);
	atk_action_set_description(ATK_ACTION(atkobj), 0,
							   "Closes the notification.");
	atk_object_set_name(atkobj, "");
	atk_object_set_description(atkobj, "Closes the notification.");

	image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	gtk_container_add(GTK_CONTAINER(close_button), image);

	windata->content_hbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);

	windata->iconbox = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(windata->iconbox);
	gtk_box_pack_start(GTK_BOX(windata->content_hbox), windata->iconbox,
					   FALSE, FALSE, 0);
	gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);

	windata->icon = gtk_image_new();
	gtk_box_pack_start(GTK_BOX(windata->iconbox), windata->icon,
					   TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->icon), 0.5, 0.0);

	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0);

	windata->body_label = gtk_label_new(NULL);
	gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0);
	gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
	g_signal_connect(G_OBJECT(windata->body_label), "activate-link",
                         G_CALLBACK(activate_link), windata);

	atkobj = gtk_widget_get_accessible(windata->body_label);
	atk_object_set_description(atkobj, "Notification body text.");

	alignment = gtk_alignment_new(1, 0.5, 0, 0);
	gtk_widget_show(alignment);
	gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);

	windata->actions_box = gtk_hbox_new(FALSE, 6);
	gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);

	return GTK_WINDOW(win);
}
GtkWidget * AP_UnixDialog_SplitCells::_constructWindowContents(void)
{
	GtkWidget *wContents;

	wContents = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_widget_show (wContents);
	GtkWidget *frame1;
	GtkWidget *table1;
	GtkWidget *wlSplitLeft;
	GtkWidget *wlSplitHoriMid;
	GtkWidget *wlSplitRight;
	GtkWidget *wlSplitAbove;
	GtkWidget *wlSplitVertMid;
	GtkWidget *wlSplitBelow;
	GtkWidget *wSplitLeft;
	GtkWidget *wSplitHoriMid;
	GtkWidget *wSplitRight;
	GtkWidget *wSplitAbove;
	GtkWidget *wSplitVertMid;
	GtkWidget *wSplitBelow;
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	std::string s;
	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_Frame,s);
	frame1 = gtk_frame_new (NULL);
	gtk_widget_show (frame1);
	gtk_container_add (GTK_CONTAINER (wContents), frame1);
	gtk_container_set_border_width (GTK_CONTAINER (frame1), 3);
	gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_NONE);

	table1 = gtk_table_new (6, 2, FALSE);
	gtk_widget_show (table1);
	gtk_container_add (GTK_CONTAINER (frame1), table1);
	gtk_table_set_col_spacings (GTK_TABLE (table1), 2);

	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_Left,s);
	wlSplitLeft = gtk_label_new (s.c_str());
	gtk_widget_show (wlSplitLeft);
	gtk_table_attach (GTK_TABLE (table1), wlSplitLeft, 0, 1, 0, 1,
					  (GtkAttachOptions) (GTK_FILL),
					  (GtkAttachOptions) (0), 0, 0);
	gtk_misc_set_alignment (GTK_MISC (wlSplitLeft), 0, 0.5);

	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_HoriMid,s);
	wlSplitHoriMid = gtk_label_new (s.c_str());
	gtk_widget_show (wlSplitHoriMid);
	gtk_table_attach (GTK_TABLE (table1), wlSplitHoriMid, 0, 1, 1, 2,
					  (GtkAttachOptions) (GTK_FILL),
					  (GtkAttachOptions) (0), 0, 0);
	gtk_misc_set_alignment (GTK_MISC (wlSplitHoriMid), 0, 0.5);

	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_Right,s);
	wlSplitRight = gtk_label_new (s.c_str());
	gtk_widget_show (wlSplitRight);
	gtk_table_attach (GTK_TABLE (table1), wlSplitRight, 0, 1, 2, 3,
					  (GtkAttachOptions) (GTK_FILL),
					  (GtkAttachOptions) (0), 0, 0);
	gtk_misc_set_alignment (GTK_MISC (wlSplitRight), 0, 0.5);

	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_Above,s);
	wlSplitAbove = gtk_label_new (s.c_str());
	gtk_widget_show (wlSplitAbove);
	gtk_table_attach (GTK_TABLE (table1), wlSplitAbove, 0, 1, 3, 4,
					  (GtkAttachOptions) (GTK_FILL),
					  (GtkAttachOptions) (0), 0, 0);
	gtk_misc_set_alignment (GTK_MISC (wlSplitAbove), 0, 0.5);

	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_VertMid,s);
	wlSplitVertMid = gtk_label_new (s.c_str());
	gtk_widget_show (wlSplitVertMid);
	gtk_table_attach (GTK_TABLE (table1), wlSplitVertMid, 0, 1, 4, 5,
					  (GtkAttachOptions) (GTK_FILL),
					  (GtkAttachOptions) (0), 0, 0);
	gtk_misc_set_alignment (GTK_MISC (wlSplitVertMid), 0, 0.5);

	pSS->getValueUTF8(AP_STRING_ID_DLG_SplitCells_Below,s);
	wlSplitBelow = gtk_label_new (s.c_str());
	gtk_widget_show (wlSplitBelow);
	gtk_table_attach (GTK_TABLE (table1), wlSplitBelow, 0, 1, 5, 6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
	gtk_misc_set_alignment (GTK_MISC (wlSplitBelow), 0, 0.5);

	wSplitLeft = gtk_button_new();
	gtk_widget_show (wSplitLeft);
	label_button_with_abi_pixmap(wSplitLeft, "tb_SplitLeft_xpm");

	gtk_table_attach (GTK_TABLE (table1), wSplitLeft, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 3, 0);

	wSplitHoriMid = gtk_button_new();
	gtk_widget_show (wSplitHoriMid);
	label_button_with_abi_pixmap(wSplitHoriMid, "tb_SplitHoriMid_xpm");

	gtk_table_attach (GTK_TABLE (table1), wSplitHoriMid, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 3, 0);


	wSplitRight = gtk_button_new();
	gtk_widget_show (wSplitRight);
	label_button_with_abi_pixmap(wSplitRight, "tb_SplitRight_xpm");
	gtk_table_attach (GTK_TABLE (table1), wSplitRight, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 3, 0);

	wSplitAbove = gtk_button_new();
	gtk_widget_show (wSplitAbove);
	label_button_with_abi_pixmap(wSplitAbove, "tb_SplitAbove_xpm");

	gtk_table_attach (GTK_TABLE (table1), wSplitAbove, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 3, 0);


	wSplitVertMid = gtk_button_new();
	gtk_widget_show (wSplitVertMid);
	label_button_with_abi_pixmap(wSplitVertMid, "tb_SplitVertMid_xpm");

	gtk_table_attach (GTK_TABLE (table1), wSplitVertMid, 1, 2, 4, 5,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 3, 0);


	wSplitBelow = gtk_button_new();
	gtk_widget_show (wSplitBelow);
	label_button_with_abi_pixmap(wSplitBelow, "tb_SplitBelow_xpm");

	gtk_table_attach (GTK_TABLE (table1), wSplitBelow, 1, 2, 5, 6,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 3, 0);

	m_wSplitLeft = wSplitLeft;
	m_wSplitHoriMid = wSplitHoriMid;
	m_wSplitRight = wSplitRight;
	m_wSplitAbove = wSplitAbove;
	m_wSplitVertMid = wSplitVertMid;
	m_wSplitBelow = wSplitBelow;
	m_lwSplitLeft = wlSplitLeft;
	m_lwSplitRight = wlSplitRight;
	m_lwSplitAbove = wlSplitAbove;
	m_lwSplitVertMid = wlSplitVertMid;
	m_lwSplitHoriMid = wlSplitHoriMid;
	m_lwSplitBelow = wlSplitBelow;

	m_wContents = wContents;
	
	return m_wContents;
}
예제 #29
0
Preview_t *
make_preview (GimpDrawable *drawable)
{
   Preview_t *data = g_new(Preview_t, 1);
   GtkAdjustment *hadj;
   GtkAdjustment *vadj;
   GtkWidget *preview;
   GtkWidget *window;
   GtkWidget *button, *arrow;
   GtkWidget *ruler;
   GtkWidget *table;
   GtkWidget *scrollbar;
   gint width, height;

   data->drawable = drawable;
   data->preview = preview = gimp_preview_area_new ();

   g_object_set_data (G_OBJECT (preview), "preview", data);
   gtk_widget_set_events(GTK_WIDGET(preview), PREVIEW_MASK);
   g_signal_connect_after(preview, "expose-event",
                          G_CALLBACK(preview_expose), data);
   g_signal_connect (preview, "size-allocate",
                     G_CALLBACK (preview_size_allocate), (gpointer)data);

   /* Handle drop of links in preview widget */
   gtk_drag_dest_set(preview, GTK_DEST_DEFAULT_ALL, target_table,
                     2, GDK_ACTION_COPY);
   g_signal_connect(preview, "drag-data-received",
                    G_CALLBACK(handle_drop), NULL);

   data->widget_width = data->width =
       gimp_drawable_width(drawable->drawable_id);
   data->widget_height = data->height =
       gimp_drawable_height(drawable->drawable_id);
   gtk_widget_set_size_request (preview, data->widget_width,
                                data->widget_height);

   /* The main table */
   data->window = table = gtk_table_new(3, 3, FALSE);
   gtk_table_set_col_spacings (GTK_TABLE (table), 1);
   gtk_table_set_row_spacings (GTK_TABLE (table), 1);

   /* Create button with arrow */
   button = gtk_button_new();
   gtk_widget_set_can_focus (button, FALSE);
   gtk_table_attach(GTK_TABLE(table), button, 0, 1, 0, 1, GTK_FILL, GTK_FILL,
                    0, 0);
   gtk_widget_set_events(button,
                         GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
   g_signal_connect(button, "button-press-event",
                    G_CALLBACK(arrow_cb), NULL);
   gtk_widget_show(button);

   arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
   gtk_container_add(GTK_CONTAINER(button), arrow);
   gtk_widget_show(arrow);

   /* Create horizontal ruler */
   data->hruler = ruler = gimp_ruler_new (GTK_ORIENTATION_HORIZONTAL);
   g_signal_connect_swapped(preview, "motion-notify-event",
                            G_CALLBACK(GTK_WIDGET_GET_CLASS(ruler)->motion_notify_event),
                            ruler);

   gtk_table_attach(GTK_TABLE(table), ruler, 1, 2, 0, 1,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show(ruler);

   /* Create vertical ruler */
   data->vruler = ruler = gimp_ruler_new (GTK_ORIENTATION_VERTICAL);
   g_signal_connect_swapped(preview, "motion-notify-event",
                            G_CALLBACK(GTK_WIDGET_GET_CLASS(ruler)->motion_notify_event),
                            ruler);
   gtk_table_attach(GTK_TABLE(table), ruler, 0, 1, 1, 2,
                    GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
   gtk_widget_show(ruler);

   window = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
                                  GTK_POLICY_NEVER, GTK_POLICY_NEVER);
   width = (data->width > 600) ? 600 : data->width;
   height = (data->height > 400) ? 400 : data->height;
   gtk_widget_set_size_request(window, width, height);
   gtk_table_attach(GTK_TABLE(table), window, 1, 2, 1, 2, GTK_FILL, GTK_FILL,
                    0, 0);
   gtk_widget_show(window);

   hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (window));

   g_signal_connect (hadj, "changed",
                     G_CALLBACK (scroll_adj_changed),
                     data->hruler);
   g_signal_connect (hadj, "value-changed",
                     G_CALLBACK (scroll_adj_changed),
                     data->hruler);

   vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window));

   g_signal_connect (vadj, "changed",
                     G_CALLBACK (scroll_adj_changed),
                     data->vruler);
   g_signal_connect (vadj, "value-changed",
                     G_CALLBACK (scroll_adj_changed),
                     data->vruler);

   gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(window), preview);

   scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, hadj);
   gtk_table_attach(GTK_TABLE(table), scrollbar, 1, 2, 2, 3,
                    GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0);
   gtk_widget_show (scrollbar);

   scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, vadj);
   gtk_table_attach(GTK_TABLE(table), scrollbar,  2, 3, 1, 2,
                    GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0);
   gtk_widget_show (scrollbar);

   gtk_widget_show (preview);

   gimp_pixel_rgn_init(&data->src_rgn, drawable, 0, 0, data->width,
                       data->height, FALSE, FALSE);
   render_preview(data, &data->src_rgn);

   gtk_widget_show(table);

   return data;
}
예제 #30
0
BackupAssistant::BackupAssistant(int dummy) :
  AssistantBase(_("Backup"), _("backup"))
// Backup assistant.
{
  gtk_assistant_set_forward_page_func (GTK_ASSISTANT (assistant), GtkAssistantPageFunc (assistant_forward_function), gpointer(this), NULL);
  
  g_signal_connect (G_OBJECT (assistant), "apply", G_CALLBACK (on_assistant_apply_signal), gpointer(this));
  g_signal_connect (G_OBJECT (assistant), "prepare", G_CALLBACK (on_assistant_prepare_signal), gpointer(this));

  introduction (_("A backup helps keep your data safe"));

  // Configuration and initialization.
  extern Settings *settings;
  ustring project = settings->genconfig.project_get();

  // Build the GUI for the task selector.
  vbox_select_type = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox_select_type);
  page_number_select_type = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_select_type);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_select_type), 10);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_select_type, _("What would you like to backup?"));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_select_type, GTK_ASSISTANT_PAGE_CONTENT);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_select_type, true);

  GSList *radiobutton_select_type_group = NULL;

  radiobutton_select_type_bible = gtk_radio_button_new_with_mnemonic (NULL, _("Bible"));
  gtk_widget_show (radiobutton_select_type_bible);
  gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_bible, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible), radiobutton_select_type_group);
  radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible));

  radiobutton_select_type_notes = gtk_radio_button_new_with_mnemonic (NULL, _("Notes"));
  gtk_widget_show (radiobutton_select_type_notes);
  gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_notes, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes), radiobutton_select_type_group);
  radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes));

  radiobutton_select_type_resource = gtk_radio_button_new_with_mnemonic (NULL, _("Resource"));
  gtk_widget_show (radiobutton_select_type_resource);
  gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_resource, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_resource), radiobutton_select_type_group);
  radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_resource));

  radiobutton_select_type_everything = gtk_radio_button_new_with_mnemonic (NULL, _("Everything"));
  gtk_widget_show (radiobutton_select_type_everything);
  gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_everything, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_everything), radiobutton_select_type_group);
  radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_everything));

  Shortcuts shortcuts_select_type (0);
  shortcuts_select_type.button (radiobutton_select_type_bible);
  shortcuts_select_type.button (radiobutton_select_type_notes);
  shortcuts_select_type.button (radiobutton_select_type_resource);
  shortcuts_select_type.button (radiobutton_select_type_everything);
  shortcuts_select_type.consider_assistant();
  shortcuts_select_type.process();

  // Confirm or change Bible.
  vbox_bible_name = gtk_vbox_new (FALSE, 5);
  gtk_widget_show (vbox_bible_name);
  page_number_bible_name = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_bible_name);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_bible_name), 10);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_bible_name, _("Is this the right Bible?"));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_bible_name, GTK_ASSISTANT_PAGE_CONTENT);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_bible_name, true);

  label_bible_name = gtk_label_new (_("Bible name"));
  gtk_widget_show (label_bible_name);
  gtk_box_pack_start (GTK_BOX (vbox_bible_name), label_bible_name, FALSE, FALSE, 0);

  button_bible_name = gtk_button_new ();
  gtk_widget_show (button_bible_name);
  gtk_box_pack_start (GTK_BOX (vbox_bible_name), button_bible_name, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) button_bible_name, "clicked", G_CALLBACK (on_button_bible_name_clicked), gpointer (this));

  GtkWidget *alignment1;
  GtkWidget *hbox1;
  GtkWidget *image1;
  GtkWidget *label1;

  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (button_bible_name), alignment1);

  hbox1 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox1);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox1);

  image1 = gtk_image_new_from_stock (_("gtk-open"), GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image1);
  gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0);

  label1 = gtk_label_new_with_mnemonic (_("Choose another one"));
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0);

  Shortcuts shortcuts_bible_name (0);
  shortcuts_bible_name.label (label1);
  shortcuts_bible_name.consider_assistant();
  shortcuts_bible_name.process();

  // Confirm or change Resource.
  vbox_resource_name = gtk_vbox_new (FALSE, 5);
  gtk_widget_show (vbox_resource_name);
  page_number_resource_name = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_resource_name);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_resource_name), 10);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_resource_name, _("Is this the right Resource?"));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_resource_name, GTK_ASSISTANT_PAGE_CONTENT);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_resource_name, true);

  label_resource_name = gtk_label_new (_("Resource name"));
  gtk_widget_show (label_resource_name);
  gtk_box_pack_start (GTK_BOX (vbox_resource_name), label_resource_name, FALSE, FALSE, 0);

  button_resource_name = gtk_button_new ();
  gtk_widget_show (button_resource_name);
  gtk_box_pack_start (GTK_BOX (vbox_resource_name), button_resource_name, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) button_resource_name, "clicked", G_CALLBACK (on_button_resource_name_clicked), gpointer (this));

  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (button_resource_name), alignment1);

  hbox1 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox1);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox1);

  image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image1);
  gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0);

  label1 = gtk_label_new_with_mnemonic (_("Choose another one"));
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0);

  Shortcuts shortcuts_resource_name (0);
  shortcuts_resource_name.label (label1);
  shortcuts_resource_name.consider_assistant();
  shortcuts_resource_name.process();

  // Select file where to save to.
  vbox_file = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox_file);
  page_number_file = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_file);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_file), 10);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_file, _("Where would you like to save it?"));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_file, GTK_ASSISTANT_PAGE_CONTENT);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_file, false);

  button_file = gtk_button_new ();
  gtk_widget_show (button_file);
  gtk_box_pack_start (GTK_BOX (vbox_file), button_file, FALSE, FALSE, 0);

  GtkWidget *alignment2;
  GtkWidget *hbox2;
  GtkWidget *image2;

  alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment2);
  gtk_container_add (GTK_CONTAINER (button_file), alignment2);

  hbox2 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox2);
  gtk_container_add (GTK_CONTAINER (alignment2), hbox2);

  image2 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image2);
  gtk_box_pack_start (GTK_BOX (hbox2), image2, FALSE, FALSE, 0);

  label_file = gtk_label_new_with_mnemonic ("");
  gtk_widget_show (label_file);
  gtk_box_pack_start (GTK_BOX (hbox2), label_file, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) button_file, "clicked", G_CALLBACK (on_button_file_clicked), gpointer(this));

  // Build the confirmation stuff.
  label_confirm = gtk_label_new (_("Backup is about to be made"));
  gtk_widget_show (label_confirm);
  page_number_confirm = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_confirm);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_confirm, _("Backup is about to be made"));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_confirm, GTK_ASSISTANT_PAGE_CONFIRM);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_confirm, true);
  
  label_progress = gtk_label_new ("");
  gtk_widget_show (label_progress);
  gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_progress);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_progress, "");
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_progress, GTK_ASSISTANT_PAGE_PROGRESS);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_progress, true);
  
  label_summary = gtk_label_new (_("Backup is done"));
  gtk_widget_show (label_summary);
  summary_page_number = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_summary);

  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_summary, _("The backup was completed successfully."));
  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_summary, GTK_ASSISTANT_PAGE_SUMMARY);
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_summary, true);
  
  // Finish building assistant.
  gtk_widget_show_all (assistant);
  gtk_assistant_set_current_page (GTK_ASSISTANT (assistant), 0);
}