static void
xviewer_properties_dialog_set_property (GObject      *object,
				    guint         prop_id,
				    const GValue *value,
				    GParamSpec   *pspec)
{
	XviewerPropertiesDialog *prop_dlg = XVIEWER_PROPERTIES_DIALOG (object);

	switch (prop_id) {
		case PROP_THUMBVIEW:
			prop_dlg->priv->thumbview = g_value_get_object (value);
			break;
		case PROP_NETBOOK_MODE:
			xviewer_properties_dialog_set_netbook_mode (prop_dlg,
						   g_value_get_boolean (value));
			break;
		case PROP_NEXT_ACTION:
			gtk_activatable_set_related_action (GTK_ACTIVATABLE (prop_dlg->priv->next_button),
							    g_value_get_object(value));
			gtk_button_set_always_show_image(GTK_BUTTON(prop_dlg->priv->next_button), TRUE);
			break;
		case PROP_PREV_ACTION:
			gtk_activatable_set_related_action (GTK_ACTIVATABLE (prop_dlg->priv->previous_button),
							    g_value_get_object(value));
			gtk_button_set_always_show_image(GTK_BUTTON(prop_dlg->priv->previous_button), TRUE);
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id,
							   pspec);
			break;
	}
}
Esempio n. 2
0
static void gtkhash_properties_init_objects(struct page_s *page,
	GtkBuilder *builder)
{
	// Main container
	page->box = GTK_WIDGET(gtkhash_properties_get_object(builder,
		"vbox"));
	g_object_ref(page->box);

	// Progress bar
	page->progressbar = GTK_PROGRESS_BAR(gtkhash_properties_get_object(builder,
		"progressbar"));

	// Treeview
	page->treeview = GTK_TREE_VIEW(gtkhash_properties_get_object(builder,
		"treeview"));
	page->treeselection = GTK_TREE_SELECTION(gtkhash_properties_get_object(builder,
		"treeselection"));
	page->cellrendtoggle = GTK_CELL_RENDERER_TOGGLE(gtkhash_properties_get_object(builder,
		"cellrenderertoggle"));

	// Popup menu
	page->menu = GTK_MENU(gtkhash_properties_get_object(builder,
		"menu"));
	g_object_ref(page->menu);
	page->menuitem_copy = GTK_MENU_ITEM(gtkhash_properties_get_object(builder,
		"imagemenuitem_copy"));
	page->menuitem_show_funcs = GTK_CHECK_MENU_ITEM(gtkhash_properties_get_object(builder,
		"checkmenuitem_show_funcs"));

	// Check/MAC inputs
	page->hbox_inputs = GTK_WIDGET(gtkhash_properties_get_object(builder,
		"hbox_inputs"));
	page->entry_check = GTK_ENTRY(gtkhash_properties_get_object(builder,
		"entry_check"));
	page->togglebutton_hmac = GTK_TOGGLE_BUTTON(gtkhash_properties_get_object(builder,
		"togglebutton_hmac"));
	page->entry_hmac = GTK_ENTRY(gtkhash_properties_get_object(builder,
		"entry_hmac"));

	// Buttons
	page->button_hash = GTK_BUTTON(gtkhash_properties_get_object(builder,
		"button_hash"));
	page->button_stop = GTK_BUTTON(gtkhash_properties_get_object(builder,
		"button_stop"));
#if (GTK_MAJOR_VERSION > 2)
	gtk_button_set_always_show_image(page->button_hash, true);
	gtk_button_set_always_show_image(page->button_stop, true);
#endif
}
Esempio n. 3
0
GtkWidget*sc_image_toggle_button_new_by_size(const guint8* data,int siz)
{


    GtkWidget*image;
    GtkWidget*button=gtk_toggle_button_new();

    GdkPixbuf*pxf=gdk_pixbuf_new_from_inline(-1,data,FALSE,NULL);
    GdkPixbuf*real_pxf;


    if(!pxf) {
        image=gtk_image_new_from_icon_name("image-x-generic",GTK_ICON_SIZE_BUTTON);

    } else {
        real_pxf=gdk_pixbuf_scale_simple(pxf,siz,siz,GDK_INTERP_HYPER);
        g_object_unref(pxf);
        image=gtk_image_new_from_pixbuf(real_pxf);
        g_object_set(image,"pixel-size",GTK_IMAGE_PIXBUF,NULL);
    }
    g_object_unref(real_pxf);

    gtk_button_set_image(GTK_BUTTON(button),image);
    gtk_button_set_always_show_image(GTK_BUTTON(button),TRUE);

    sc_button_set_style(GTK_BUTTON(button));


    return button;


}
Esempio n. 4
0
GtkWidget*sc_image_button_new(const guint8* data)
{

    GtkWidget*image;
    GtkWidget*button=gtk_button_new();

    GdkPixbuf*pxf=gdk_pixbuf_new_from_inline(-1,data,FALSE,NULL);


    if(!pxf) {
        image=gtk_image_new_from_icon_name("image-x-generic",GTK_ICON_SIZE_BUTTON);

    } else {
        image=gtk_image_new_from_pixbuf(pxf);
        g_object_unref(pxf);
    }

    gtk_button_set_image(GTK_BUTTON(button),image);
    gtk_button_set_always_show_image(GTK_BUTTON(button),TRUE);

    sc_button_set_style(GTK_BUTTON(button));


    return button;

}
Esempio n. 5
0
static void agreement_app_window_init(AgreementAppWindow *win)
{
    gtk_window_set_title(GTK_WINDOW(win), "Agreement");
    gtk_window_set_default_size(GTK_WINDOW(win), 800, 500);

    GtkWidget* grid;
    grid = gtk_grid_new();
    gtk_container_add(GTK_CONTAINER(win), grid);

    GtkWidget *view;
    view = gtk_text_view_new();
    gtk_widget_set_hexpand(view, true);
    gtk_widget_set_vexpand(view, true);
    gtk_grid_attach(GTK_GRID(grid), view, 0, 0, 1, 1);

    agreement_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
    gtk_text_buffer_set_text(agreement_text_buffer, "No file loaded", -1);

    GtkWidget *flow_box;
    flow_box = gtk_flow_box_new();
    gtk_flow_box_set_min_children_per_line(GTK_FLOW_BOX(flow_box), 2);
    gtk_widget_set_halign(flow_box, GTK_ALIGN_CENTER);
    gtk_grid_attach(GTK_GRID(grid), flow_box, 0, 1, 1, 1);

    GtkWidget *no_button;
    no_button = gtk_button_new_from_icon_name("window-close", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_always_show_image(GTK_BUTTON(no_button), true);
    gtk_button_set_label(GTK_BUTTON(no_button), "No, I do not agree");
    gtk_container_add(GTK_CONTAINER(flow_box), no_button);

    GtkWidget *yes_button;
    yes_button = gtk_button_new_from_icon_name("go-next", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_always_show_image(GTK_BUTTON(yes_button), true);
    gtk_button_set_label(GTK_BUTTON(yes_button), "Yes, I agree");
    gtk_container_add(GTK_CONTAINER(flow_box), yes_button);

    gtk_widget_show_all(GTK_WIDGET(win));
}
Esempio n. 6
0
static void on_button_press(widget, event)
{
	GtkWidget *exit_dialog = gtk_dialog_new();
	GtkWidget *vbox = gtk_dialog_get_content_area(GTK_DIALOG(exit_dialog));
	gtk_window_set_default_size(GTK_WINDOW(exit_dialog), 300, 300);
	GtkWidget *exit_button = gtk_button_new();
	gtk_button_set_always_show_image(GTK_BUTTON(exit_button), TRUE);
	gtk_button_set_image(GTK_BUTTON(exit_button), gtk_image_new_from_icon_name("application-exit", GTK_ICON_SIZE_DIALOG));
	g_signal_connect(exit_button, "clicked", G_CALLBACK(on_exit_button), exit_dialog);
	gtk_box_pack_start(GTK_BOX(vbox), exit_button, TRUE, TRUE, 5);
	gtk_widget_show_all(vbox);
	if (gtk_dialog_run(GTK_DIALOG(exit_dialog)) == GTK_RESPONSE_CLOSE)
	{
		// system("sudo poweroff");
		system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop");
		gtk_main_quit();
	}
	gtk_widget_destroy(GTK_WIDGET(exit_dialog));
}
static void
photos_tool_filter_button_constructed (GObject *object)
{
  PhotosToolFilterButton *self = PHOTOS_TOOL_FILTER_BUTTON (object);
  GApplication *app;
  g_autoptr (GdkPixbuf) preview_icon = NULL;
  GtkWidget *image;
  PhotosWidgetShader *shader;
  cairo_surface_t *preview_icon_surface = NULL; /* TODO: use g_autoptr */
  gint scale;

  G_OBJECT_CLASS (photos_tool_filter_button_parent_class)->constructed (object);

  app = g_application_get_default ();
  scale = photos_application_get_scale_factor (PHOTOS_APPLICATION (app));
  preview_icon = photos_utils_create_placeholder_icon_for_scale ("content-loading-symbolic", 96, scale);
  if (preview_icon != NULL)
    preview_icon_surface = gdk_cairo_surface_create_from_pixbuf (preview_icon, scale, NULL);

  image = gtk_image_new_from_surface (preview_icon_surface);
  gtk_container_add (GTK_CONTAINER (self->overlay), image);
  shader = photos_widget_shader_new (image);
  gtk_widget_show (image);

  self->button = gtk_radio_button_new_with_label_from_widget (self->group, self->label);
  gtk_button_set_always_show_image (GTK_BUTTON (self->button), TRUE);
  gtk_button_set_image (GTK_BUTTON (self->button), self->overlay);
  gtk_button_set_image_position (GTK_BUTTON (self->button), GTK_POS_TOP);
  gtk_button_set_relief (GTK_BUTTON (self->button), GTK_RELIEF_NONE);
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (self->button), FALSE);
  gtk_container_add (GTK_CONTAINER (self), self->button);
  g_object_bind_property (self->button, "active", shader, "active", G_BINDING_SYNC_CREATE);
  g_signal_connect_swapped (self->button, "toggled", G_CALLBACK (photos_tool_filter_button_toggled), self);
  photos_tool_filter_button_toggled (self);

  g_clear_pointer (&preview_icon_surface, (GDestroyNotify) cairo_surface_destroy);
  self->group = NULL; /* We will not need it any more */
}
Esempio n. 8
0
/*
 * GUI initialization
 * args:
 *   width - window width
 *   height - window height
 *
 * asserts:
 *   none
 *
 * returns: error code (0 -OK)
 */
int gui_attach_gtk3(int width, int height)
{
	if(!gtk_init_called)
	{
		if(!gtk_init_check(NULL, NULL))
		{
			fprintf(stderr, "GUVCVIEW: (GUI) Gtk3 can't open display\n");
			return -1;
		}

		gtk_init_called = 1;
	}


	/*check for device errors*/
	//if(!device)
	//{
	//	gui_error("Guvcview error", "no video device found", 1);
	//	return -1;
	//}

	g_set_application_name(_("Guvcview Video Capture"));

#if !GTK_VER_AT_LEAST(3,12)
	/* make sure the type is realized so that we can change the properties*/
	g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
	/* make sure gtk-button-images property is set to true (defaults to false in karmic)*/
	g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
#endif

	/* Create a main window */
	main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (main_window), _("Guvcview"));
	gtk_widget_show (main_window);

	/* get screen resolution */
	GdkScreen* screen = NULL;
	screen = gtk_window_get_screen(GTK_WINDOW(main_window));
	int desktop_width = gdk_screen_get_width(screen);
	int desktop_height = gdk_screen_get_height(screen);

	if(debug_level > 0)
		printf("GUVCVIEW: (GUI) Screen resolution is (%d x %d)\n", desktop_width, desktop_height);

	if((width > desktop_width) && (desktop_width > 0))
		width = desktop_width;
	if((height > desktop_height) && (desktop_height > 0))
		height = desktop_height;

	gtk_window_resize(GTK_WINDOW(main_window), width, height);

	/* Add delete event handler */
	g_signal_connect(GTK_WINDOW(main_window), "delete_event", G_CALLBACK(delete_event), NULL);

	/*window icon*/
	char* icon1path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/guvcview.png", NULL);
	if (g_file_test(icon1path, G_FILE_TEST_EXISTS))
		gtk_window_set_icon_from_file(GTK_WINDOW (main_window), icon1path, NULL);
	g_free(icon1path);

	/*---------------------------- Main table ---------------------------------*/
	GtkWidget *maintable = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
	gtk_widget_show (maintable);

	/*----------------------------- Top Menu ----------------------------------*/
	gui_attach_gtk3_menu(maintable);

	/*----------------------------- Buttons -----------------------------------*/
	GtkWidget *HButtonBox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_halign (HButtonBox, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (HButtonBox, TRUE);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(HButtonBox),GTK_BUTTONBOX_SPREAD);
	gtk_box_set_homogeneous(GTK_BOX(HButtonBox),TRUE);
	gtk_widget_show(HButtonBox);

	/*photo button*/
	if(check_photo_timer())
	{
		CapImageButt = gtk_button_new_with_mnemonic (_("Stop Cap. (I)"));
		g_object_set_data (G_OBJECT (CapImageButt), "control_info",
							GINT_TO_POINTER(1));
	}
	else
	{
		CapImageButt = gtk_button_new_with_mnemonic (_("Cap. Image (I)"));
		g_object_set_data (G_OBJECT (CapImageButt), "control_info",
							GINT_TO_POINTER(0));
	}

	char *pix2path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/camera.png",NULL);
	if (g_file_test(pix2path, G_FILE_TEST_EXISTS))
	{
		GtkWidget *ImgButton_Img = gtk_image_new_from_file (pix2path);
#if GTK_VER_AT_LEAST(3,12)		
		gtk_button_set_always_show_image(GTK_BUTTON(CapImageButt), TRUE);
#endif
		gtk_button_set_image(GTK_BUTTON(CapImageButt), ImgButton_Img);
		gtk_button_set_image_position(GTK_BUTTON(CapImageButt), GTK_POS_TOP);
	}
	g_free(pix2path);
	
	gtk_box_pack_start(GTK_BOX(HButtonBox), CapImageButt, TRUE, TRUE, 2);
	gtk_widget_show (CapImageButt);

	g_signal_connect (GTK_BUTTON(CapImageButt), "clicked",
		G_CALLBACK (capture_image_clicked), NULL);

	/*video button*/
	CapVideoButt = gtk_toggle_button_new_with_mnemonic (_("Cap. Video (V)"));
	gui_set_video_capture_button_status_gtk3(get_encoder_status());

	char *pix3path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/movie.png",NULL);
	if (g_file_test(pix3path, G_FILE_TEST_EXISTS))
	{
		GtkWidget *VideoButton_Img = gtk_image_new_from_file (pix3path);
#if GTK_VER_AT_LEAST(3,12)
		gtk_button_set_always_show_image(GTK_BUTTON(CapVideoButt), TRUE);
#endif
		gtk_button_set_image(GTK_BUTTON(CapVideoButt), VideoButton_Img);
		gtk_button_set_image_position(GTK_BUTTON(CapVideoButt), GTK_POS_TOP);
	}
	g_free(pix3path);

	gtk_box_pack_start(GTK_BOX(HButtonBox), CapVideoButt, TRUE, TRUE, 2);
	gtk_widget_show (CapVideoButt);

	g_signal_connect (GTK_BUTTON(CapVideoButt), "clicked",
		G_CALLBACK (capture_video_clicked), NULL);

	/*quit button*/
	//GtkWidget *quitButton = gtk_button_new_from_stock(GTK_STOCK_QUIT);
	GtkWidget *quitButton = gtk_button_new_with_mnemonic (_("Quit"));

	char* pix4path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/close.png", NULL);
	if (g_file_test(pix4path,G_FILE_TEST_EXISTS))
	{
		GtkWidget *QButton_Img = gtk_image_new_from_file (pix4path);
#if GTK_VER_AT_LEAST(3,12)		
		gtk_button_set_always_show_image(GTK_BUTTON(quitButton), TRUE);
#endif
		gtk_button_set_image(GTK_BUTTON(quitButton), QButton_Img);
		gtk_button_set_image_position(GTK_BUTTON(quitButton), GTK_POS_TOP);

	}
	/*must free path strings*/
	g_free(pix4path);
	gtk_box_pack_start(GTK_BOX(HButtonBox), quitButton, TRUE, TRUE, 2);
	gtk_widget_show_all (quitButton);

	g_signal_connect (GTK_BUTTON(quitButton), "clicked",
		G_CALLBACK (quit_button_clicked), NULL);

	gtk_box_pack_start(GTK_BOX(maintable), HButtonBox, FALSE, TRUE, 2);

	/*--------------------------- Tab container -------------------------------*/
	GtkWidget *tab_box = gtk_notebook_new();
	gtk_widget_show (tab_box);

	/*------------------------ Image controls Tab -----------------------------*/

	GtkWidget *scroll_1 = gtk_scrolled_window_new(NULL,NULL);
	gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_1), GTK_CORNER_TOP_LEFT);
	gtk_widget_show(scroll_1);

	/*
	 * viewport is only needed for gtk < 3.8
	 * for 3.8 and above controls tab can be directly added to scroll1
	 */
	GtkWidget* viewport = gtk_viewport_new(NULL,NULL);
	gtk_widget_show(viewport);

	gtk_container_add(GTK_CONTAINER(scroll_1), viewport);

	gui_attach_gtk3_v4l2ctrls(viewport);

	GtkWidget *tab_1 = gtk_grid_new();
	gtk_widget_show (tab_1);

    GtkWidget *tab_1_label = gtk_label_new(_("Image Controls"));
	gtk_widget_show (tab_1_label);
	/** check for files */
	gchar *tab_1_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/image_controls.png",NULL);
	/** don't test for file - use default empty image if load fails */
	/** get icon image*/
	GtkWidget *tab_1_icon = gtk_image_new_from_file(tab_1_icon_path);
	gtk_widget_show (tab_1_icon);

	g_free(tab_1_icon_path);
	gtk_grid_attach (GTK_GRID(tab_1), tab_1_icon, 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID(tab_1), tab_1_label, 1, 0, 1, 1);

	gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_1, tab_1);

	/*----------------------------H264 Controls Tab --------------------------*/
	if(v4l2core_get_h264_unit_id(get_v4l2_device_handler()) > 0)
	{
		GtkWidget *scroll_2 = gtk_scrolled_window_new(NULL,NULL);
		gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_2), GTK_CORNER_TOP_LEFT);
		gtk_widget_show(scroll_2);

		/*
		 * viewport is only needed for gtk < 3.8
		 * for 3.8 and above controls tab can be directly added to scroll1
		 */
		GtkWidget* viewport2 = gtk_viewport_new(NULL,NULL);
		gtk_widget_show(viewport2);

		gtk_container_add(GTK_CONTAINER(scroll_2), viewport2);

		gui_attach_gtk3_h264ctrls(viewport2);

		GtkWidget *tab_2 = gtk_grid_new();
		gtk_widget_show (tab_2);

		GtkWidget *tab_2_label = gtk_label_new(_("H264 Controls"));
		gtk_widget_show (tab_2_label);
		/** check for files */
		gchar *tab_2_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/image_controls.png",NULL);
		/** don't test for file - use default empty image if load fails */
		/** get icon image*/
		GtkWidget *tab_2_icon = gtk_image_new_from_file(tab_2_icon_path);
		gtk_widget_show (tab_2_icon);

		g_free(tab_2_icon_path);
		gtk_grid_attach (GTK_GRID(tab_2), tab_2_icon, 0, 0, 1, 1);
		gtk_grid_attach (GTK_GRID(tab_2), tab_2_label, 1, 0, 1, 1);

		gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_2, tab_2);
	}

	/*exclude video and audio tabs if we are in control panel mode*/
	if(!is_control_panel)
	{
		/*----------------------- Video controls Tab ------------------------------*/

		GtkWidget *scroll_3 = gtk_scrolled_window_new(NULL,NULL);
		gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_3), GTK_CORNER_TOP_LEFT);
		gtk_widget_show(scroll_3);

		/*
		 * viewport is only needed for gtk < 3.8
		 * for 3.8 and above controls tab can be directly added to scroll1
		 */
		GtkWidget* viewport3 = gtk_viewport_new(NULL,NULL);
		gtk_widget_show(viewport3);

		gtk_container_add(GTK_CONTAINER(scroll_3), viewport3);

		gui_attach_gtk3_videoctrls(viewport3);

		GtkWidget *tab_3 = gtk_grid_new();
		gtk_widget_show (tab_3);

		GtkWidget *tab_3_label = gtk_label_new(_("Video Controls"));
		gtk_widget_show (tab_3_label);
		/** check for files */
		gchar *tab_3_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/video_controls.png",NULL);
		/** don't test for file - use default empty image if load fails */
		/** get icon image*/
		GtkWidget *tab_3_icon = gtk_image_new_from_file(tab_3_icon_path);
		gtk_widget_show (tab_3_icon);

		g_free(tab_3_icon_path);
		gtk_grid_attach (GTK_GRID(tab_3), tab_3_icon, 0, 0, 1, 1);
		gtk_grid_attach (GTK_GRID(tab_3), tab_3_label, 1, 0, 1, 1);

		gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_3, tab_3);

		/*----------------------- Audio controls Tab ------------------------------*/

		GtkWidget *scroll_4 = gtk_scrolled_window_new(NULL,NULL);
		gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_4), GTK_CORNER_TOP_LEFT);
		gtk_widget_show(scroll_4);

		/*
		 * viewport is only needed for gtk < 3.8
		 * for 3.8 and above controls tab can be directly added to scroll1
		 */
		GtkWidget* viewport4 = gtk_viewport_new(NULL,NULL);
		gtk_widget_show(viewport4);

		gtk_container_add(GTK_CONTAINER(scroll_4), viewport4);

		gui_attach_gtk3_audioctrls(viewport4);

		GtkWidget *tab_4 = gtk_grid_new();
		gtk_widget_show (tab_4);

		GtkWidget *tab_4_label = gtk_label_new(_("Audio Controls"));
		gtk_widget_show (tab_4_label);
		/** check for files */
		gchar *tab_4_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/audio_controls.png",NULL);
		/** don't test for file - use default empty image if load fails */
		/** get icon image*/
		GtkWidget *tab_4_icon = gtk_image_new_from_file(tab_4_icon_path);
		gtk_widget_show (tab_4_icon);

		g_free(tab_4_icon_path);
		gtk_grid_attach (GTK_GRID(tab_4), tab_4_icon, 0, 0, 1, 1);
		gtk_grid_attach (GTK_GRID(tab_4), tab_4_label, 1, 0, 1, 1);

		gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_4, tab_4);
	}

	/* Attach the notebook (tabs) */
	gtk_box_pack_start(GTK_BOX(maintable), tab_box, TRUE, TRUE, 2);

	/*-------------------------- Status bar ------------------------------------*/
	status_bar = gtk_statusbar_new();
	status_warning_id = gtk_statusbar_get_context_id (GTK_STATUSBAR(status_bar), "warning");

    gtk_widget_show(status_bar);
	/* add the status bar*/
	gtk_box_pack_start(GTK_BOX(maintable), status_bar, FALSE, FALSE, 2);


	/* attach to main window container */
	gtk_container_add (GTK_CONTAINER (main_window), maintable);

	/* add key events*/
	gtk_widget_add_events (GTK_WIDGET (main_window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
	g_signal_connect (GTK_WINDOW(main_window), "key_press_event", G_CALLBACK(window_key_pressed), NULL);

	/* add update timers:
	 *  devices
	 */
	gtk_devices_timer_id = g_timeout_add( 1000, check_device_events, NULL);
	/*controls*/
	gtk_control_events_timer_id = g_timeout_add(1000, check_control_events, NULL);

	return 0;
}
Esempio n. 9
0
int main (int argc, char *argv[])
{
    //const std::string creatureDB[]={"pidgeot","gardevoir"}; - For creature catalog~~
    //std::cout<<creatureDB[0];

    /* Initialize GTK+ */
    g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
    gtk_init (&argc, &argv);
    g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);

    /* Main window configuration */
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (GTK_WINDOW (win), false);
    gtk_widget_set_size_request(win,windowWidth,windowHeight);
    gtk_container_set_border_width (GTK_CONTAINER (win), 0);
    gtk_window_set_title (GTK_WINDOW (win), "Pokemon");
    gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
    gtk_widget_realize (win);
    g_signal_connect (win, "destroy", gtk_main_quit, NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(win),"images/winIcon.png",NULL);
    //gtk_window_set_decorated (GTK_WINDOW(win),FALSE); //Óáèðàåò ñòàíäàðòíîå îôîðìëåíèå îêíà windows

    /* Initializing objects */
    zeBigContainer = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    zeBigContainerOverlay = gtk_overlay_new();
    topPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    topPartCenter = gtk_alignment_new (0.5,0.5,1,1);
    topPartLeft = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    topPartCenter = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    topPartRight = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    bottomPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    buttons = gtk_grid_new ();
    dialogScrollFrame = gtk_scrolled_window_new(NULL,NULL);
    dialogText = gtk_text_view_new ();
    dialogBuffer = gtk_text_buffer_new (NULL);
    button1 = gtk_button_new ();
    button2 = gtk_button_new ();
    button3 = gtk_button_new ();
    button4 = gtk_button_new_with_label ("Restart");
    button5 = gtk_button_new_with_label ("Back to choosing screen");
    topMidPart = gtk_image_new_from_file ("images/topPic.jpg");
    IMGBackground = gtk_image_new_from_file ("images/pokeBackground.jpg");
    leftImage = gtk_image_new_from_file ("images/filler.PNG");
    rightImage = gtk_image_new_from_file ("images/filler.PNG");
    leftBar = gtk_progress_bar_new ();
    rightBar = gtk_progress_bar_new ();

    /* Setting dialogText */
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_LEFT, 5);
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_BOTTOM, 20);
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_TOP, 5);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(dialogText), FALSE);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(dialogText), FALSE);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dialogText),GTK_WRAP_WORD);

    /* Setting progress bars */
    gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(rightBar),TRUE);
    gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(leftBar),TRUE);
    gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(rightBar),TRUE);

    /* Various initializations */
    gtk_box_set_homogeneous((GtkBox*)topPartCenter,TRUE);
    gtk_box_set_homogeneous((GtkBox*)topPart,TRUE);
    gtk_box_set_homogeneous((GtkBox*)bottomPart,TRUE);
    gtk_box_set_homogeneous((GtkBox*)zeBigContainer,TRUE);
    gtk_grid_set_row_homogeneous((GtkGrid*)buttons,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)buttons,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)buttons,12);
    gtk_grid_set_column_spacing((GtkGrid*)buttons,12);
    g_object_set (buttons,"margin",12,NULL);
    g_object_set (topPart,"margin",12,NULL);
    gtk_container_set_border_width(GTK_CONTAINER(dialogScrollFrame),5);
    //gtk_box_set_child_packing((GtkBox*)zeBigContainer,bottomPart,gTRUE,gTRUE,100,GTK_PACK_START);
    gtk_text_view_set_buffer (GTK_TEXT_VIEW(dialogText), dialogBuffer);
    gtk_text_buffer_set_text(dialogBuffer, "", -1);
    //gtk_text_buffer_get_iter_at_offset (dialogBuffer, &lastCharIter, -1);
    gtk_text_buffer_get_end_iter(dialogBuffer, &endIter);
    fontDesc = pango_font_description_from_string("Consolas");
    gtk_widget_override_font(dialogText,fontDesc);
    endMark = gtk_text_mark_new ("endMark",FALSE);
    endMark = gtk_text_buffer_get_mark(dialogBuffer,"insert");
    gtk_button_set_always_show_image(GTK_BUTTON(button1),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(button2),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(button3),TRUE);

    /* Building objects */
    gtk_container_add (GTK_CONTAINER(win),zeBigContainerOverlay);
    gtk_overlay_add_overlay(GTK_OVERLAY(zeBigContainerOverlay),zeBigContainer);
    gtk_container_add (GTK_CONTAINER(zeBigContainerOverlay),IMGBackground);
    gtk_container_add (GTK_CONTAINER(zeBigContainer),topPart);
    gtk_container_add (GTK_CONTAINER(zeBigContainer),bottomPart);
    gtk_container_add (GTK_CONTAINER(topPart),topPartLeft); // Â topPartLeft âñòàâëÿòü ëåâûé áàð
    gtk_container_add (GTK_CONTAINER(topPartLeft),leftBar);
    gtk_container_add (GTK_CONTAINER(topPartLeft),leftImage);
    gtk_container_add (GTK_CONTAINER(topPart),topPartCenter);
    gtk_container_add (GTK_CONTAINER(topPart),topPartRight); // â topPartRight - ïðàâûé...
    gtk_container_add (GTK_CONTAINER(topPartRight),rightBar);
    gtk_container_add (GTK_CONTAINER(topPartRight),rightImage);
    gtk_container_add (GTK_CONTAINER(topPartCenter),topMidPart);
    gtk_container_add (GTK_CONTAINER(bottomPart),dialogScrollFrame);
    gtk_container_add (GTK_CONTAINER(dialogScrollFrame),dialogText);
    gtk_container_add (GTK_CONTAINER(bottomPart),buttons);
    gtk_grid_attach (GTK_GRID(buttons),button1, 1,1,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button2, 1,2,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button3, 1,3,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button4, 1,4,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button5, 1,5,1,1);

    /* Signal connects and some shiatd */
    g_signal_connect(G_OBJECT(button1), "clicked", Cast1, NULL);
    g_signal_connect(G_OBJECT(button2), "clicked", Cast2, NULL);
    g_signal_connect(G_OBJECT(button3), "clicked", Cast3, NULL);
    g_signal_connect(G_OBJECT(button4), "clicked", combatStart, NULL);
    g_signal_connect(G_OBJECT(button5), "clicked", backToChoosingScreen,NULL);

    /* Creature chooser window configuration */ // TO BE CONTINUED..........................................................................
    /* Window creation/configuration (win2) */
    win2win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (GTK_WINDOW (win2win), false);
    gtk_widget_set_size_request(win2win,windowWidth,windowHeight);
    gtk_window_set_title (GTK_WINDOW (win2win), "Pokemon creature chooser");
    gtk_window_set_position (GTK_WINDOW (win2win), GTK_WIN_POS_CENTER);
    gtk_widget_realize (win2win);
    g_signal_connect (win2win, "destroy", gtk_main_quit, NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(win2win),"images/winIcon.png",NULL);


    /* Initializing objects (win2) */
    win2topLabel = gtk_image_new_from_file("images/logo.png");
    //win2topLabel = gtk_label_new("");
    //gtk_label_set_markup(GTK_LABEL(win2topLabel),"<small>Small</small><big>Bold</big>");
    win2BigContainer = gtk_grid_new();
    win2BigContainerOverlay = gtk_overlay_new ();
    win2TopPart = gtk_grid_new ();
    win2MiddlePart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    win2BottomPart = gtk_grid_new();
    win2BackgroundIMG = gtk_image_new_from_file ("images/pokeBackground.jpg");
    win2button1 = gtk_button_new_with_label(">>Switch Screens<<");
    win2button2 = gtk_button_new_with_label("Exit");
    win2buttonReset = gtk_button_new_with_label("Reset");
    win2creatureIcon1 = gtk_button_new();
    win2creatureIcon2 = gtk_button_new();
    win2creatureIcon3 = gtk_button_new();
    win2creatureIcon4 = gtk_button_new();
    win2creatureIcon5 = gtk_button_new();
    win2creatureIcon1IMG = gtk_image_new_from_file("images/ImagePidgeotSmall.png");
    win2creatureIcon2IMG = gtk_image_new_from_file("images/ImageGardevoirSmall.png");
    win2creatureIcon3IMG = gtk_image_new_from_file("images/ImageArcanineSmall.png");
    win2creatureIcon4IMG = gtk_image_new_from_file("images/ImagePikachuSmall.png");
    win2creatureIcon5IMG = gtk_image_new_from_file("images/ImageFishSmall.png");
    win2ImageVersus = gtk_image_new_from_file ("images/versus.png");
    win2MiddleFirst = gtk_image_new_from_file ("images/facelessVoid.png");
    win2MiddleSecond = gtk_image_new_from_file ("images/facelessVoid.png");

    /* Various initializations (win2) */
    gtk_grid_set_row_homogeneous((GtkGrid*)win2BigContainer,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2BigContainer,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2BigContainer,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2BigContainer,12);
    //g_object_set (win2BigContainer,"margin",12,NULL);

    gtk_grid_set_row_homogeneous((GtkGrid*)win2BottomPart,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2BottomPart,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2BottomPart,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2BottomPart,12);
    g_object_set (win2BottomPart,"margin",12,NULL);

    gtk_grid_set_row_homogeneous((GtkGrid*)win2TopPart,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2TopPart,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2TopPart,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2TopPart,12);
    g_object_set (win2TopPart,"margin",12,NULL);

    gtk_box_set_homogeneous(GTK_BOX(win2MiddlePart),TRUE);

    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon1),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon2),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon3),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon4),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon5),TRUE);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon1),win2creatureIcon1IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon2),win2creatureIcon2IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon3),win2creatureIcon3IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon4),win2creatureIcon4IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon5),win2creatureIcon5IMG);

    /* Building objects (win2) */
    gtk_container_add (GTK_CONTAINER(win2win),win2BigContainerOverlay);
    gtk_overlay_add_overlay(GTK_OVERLAY(win2BigContainerOverlay),win2BigContainer);
    gtk_container_add (GTK_CONTAINER(win2BigContainerOverlay),win2BackgroundIMG);
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2topLabel,1,1,1,2);//1
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2TopPart,1,2,1,3);//3
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon1,1,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon2,2,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon3,3,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon4,4,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon5,5,1,1,1);
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2MiddlePart,1,5,1,3);//3
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2BottomPart,1,8,1,3);//3
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleFirst);
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2ImageVersus);
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleSecond);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2button1, 1,1,3,1);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2buttonReset,4,1,1,1);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2button2, 5,1,1,1);

    /* Signal connects (win2) */
    g_signal_connect (G_OBJECT(win2button1),"clicked",win2StartGame,NULL);
    g_signal_connect (G_OBJECT(win2button2),"clicked",gtk_main_quit,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon1),"clicked",win2pidgeotSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon2),"clicked",win2gardevoirSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon3),"clicked",win2arcanineSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon4),"clicked",win2pikachuSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon5),"clicked",win2mightyfishSelect,NULL);
    g_signal_connect (G_OBJECT(win2buttonReset),"clicked",win2CharReset,NULL);

    /* Other stuff */
    srand(time(NULL));
    write ("___________________________________________________\n");

    /* Enter the main loop */
    gtk_widget_show_all (win2win);
    gtk_main ();

    return 0;
};
Esempio n. 10
0
void configure_program_dialog(GtkWidget *widget, gpointer user_data) {

  /** Program configuration dailog window. **/

  #ifdef DEBUG
  DEBUG_FUNC_MARK
  #endif

  GtkWidget *configure_dialog = gtk_dialog_new() ;



  gtk_window_set_icon_from_file(GTK_WINDOW(configure_dialog), PATH_TO_PRG_WIN_ICON, NULL) ;
  gtk_window_set_title(GTK_WINDOW(configure_dialog), "Configure program") ;
  gtk_window_set_position(GTK_WINDOW(configure_dialog), GTK_WIN_POS_CENTER_ALWAYS) ;
  gtk_window_set_resizable(GTK_WINDOW(configure_dialog), FALSE);
  gtk_widget_set_size_request(configure_dialog,-1,-1) ;
  gtk_window_set_modal(GTK_WINDOW(configure_dialog), FALSE) ;
  gtk_window_set_destroy_with_parent(GTK_WINDOW(configure_dialog), TRUE) ;
  gtk_window_set_decorated(GTK_WINDOW(configure_dialog), TRUE) ;

  gtk_window_set_type_hint(GTK_WINDOW(configure_dialog), GDK_WINDOW_TYPE_HINT_NORMAL) ;
  gtk_window_set_transient_for(GTK_WINDOW(configure_dialog), GTK_WINDOW(gui->window)) ;

  gtk_container_set_border_width(GTK_CONTAINER(configure_dialog), 12) ;


  #define DIALOG_DEFAULT_SPACE 12


  /** ***** [START] Icon set choice [START] ***** **/

  GtkWidget *icon_set_choice_frame = gtk_frame_new(" Icon set ") ;


  GtkWidget *icon_set_choice_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(icon_set_choice_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_box_set_spacing(GTK_BOX(icon_set_choice_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_box_set_homogeneous(GTK_BOX(icon_set_choice_hbox), TRUE) ;


  GtkWidget *radiobutton_icons_high_contrast = gtk_radio_button_new_with_label(NULL, " HighContrast") ;

  GtkWidget *image_icons_high_contrast       ;

  GtkWidget *radiobutton_icons_oxygen        = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radiobutton_icons_high_contrast)), " Oxygen") ;

  GtkWidget *image_icons_oxygen              ;


  gtk_widget_set_tooltip_markup(radiobutton_icons_high_contrast, "Set the <b>HighContrast</b> theme icon set.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(radiobutton_icons_oxygen,        "Set the <b>Oxygen</b> theme icon set.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radiobutton_icons_high_contrast), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radiobutton_icons_oxygen),        FALSE) ;


  if (settings.icon_set_oxygen) {

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_icons_oxygen), TRUE) ;

    image_icons_high_contrast = gtk_image_new_from_file( PATH_TO_HIGH_CONTRAST_BUTTON_ICONS  "face-angry.png")     ;

    image_icons_oxygen        = gtk_image_new_from_file( PATH_TO_OXYGEN_BUTTON_ICONS         "face-smile-big.png") ;

  }
  else {

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_icons_high_contrast), TRUE) ;

    image_icons_high_contrast = gtk_image_new_from_file( PATH_TO_HIGH_CONTRAST_BUTTON_ICONS  "face-smile-big.png") ;

    image_icons_oxygen        = gtk_image_new_from_file( PATH_TO_OXYGEN_BUTTON_ICONS         "face-angry.png")     ;

  }


  gtk_button_set_image(GTK_BUTTON(radiobutton_icons_high_contrast), image_icons_high_contrast) ;

  gtk_button_set_always_show_image(GTK_BUTTON(radiobutton_icons_high_contrast), TRUE) ;

  gtk_button_set_image(GTK_BUTTON(radiobutton_icons_oxygen), image_icons_oxygen) ;

  gtk_button_set_always_show_image(GTK_BUTTON(radiobutton_icons_oxygen), TRUE)   ;





  gtk_box_pack_start(GTK_BOX(icon_set_choice_hbox), radiobutton_icons_high_contrast, TRUE,  TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(icon_set_choice_hbox), radiobutton_icons_oxygen,        TRUE,  TRUE, 0) ;

  gtk_container_add(GTK_CONTAINER(icon_set_choice_frame), icon_set_choice_hbox) ;

  /** ***** [END] Icon set choice [END] ***** **/



  /** ***** [START] Playing settings [START] ***** **/

  GtkWidget *playing_settings_frame = gtk_frame_new(" Player settings ") ;


  GtkWidget *playing_settings_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(playing_settings_vbox), DIALOG_DEFAULT_SPACE) ;



  GtkWidget *playing_settings_repeat_all = gtk_check_button_new_with_label(" Repeat all mode. ") ;

  gtk_widget_set_tooltip_markup(playing_settings_repeat_all, "Enable the <b>repeat all</b> feature.\nThis will update the player settings.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playing_settings_repeat_all), is_repeat_all) ;



  GtkWidget *playing_settings_shuffle = gtk_check_button_new_with_label(" Shuffle mode. ") ;

  gtk_widget_set_tooltip_markup(playing_settings_shuffle, "Enable the <b>shuffle</b> feature.\nThis will update the player settings.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playing_settings_shuffle), is_shuffle ) ;

  GtkWidget *playing_settings_volume_hbox  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;



  GtkWidget *playing_settings_volume_label_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  GtkWidget *playing_settings_volume_image      = gtk_image_new_from_file( (settings.path_to_button_icons + "audio-volume-medium.png").c_str() ) ;

  GtkWidget *playing_settings_volume_label      = gtk_label_new(" Default Volume:") ;

  gtk_box_pack_start(GTK_BOX(playing_settings_volume_label_hbox), playing_settings_volume_image, FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(playing_settings_volume_label_hbox), playing_settings_volume_label, FALSE, FALSE, 0) ;


  GtkWidget *playing_settings_volume_scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0) ;



  gtk_widget_set_tooltip_markup(playing_settings_volume_scale, "Set the <b>default player volume</b> at start.\nThis will <b>not</b> update the player settings.\nYou must press the <b>Apply</b> button to store your configuration.") ;

  gtk_range_set_value(GTK_RANGE(playing_settings_volume_scale), settings.volume) ;

  gtk_scale_set_draw_value(GTK_SCALE(playing_settings_volume_scale), TRUE) ;
  gtk_scale_set_has_origin(GTK_SCALE(playing_settings_volume_scale), TRUE) ;

  gtk_scale_set_value_pos(GTK_SCALE(playing_settings_volume_scale), GTK_POS_TOP) ;

  gtk_scale_add_mark(GTK_SCALE(playing_settings_volume_scale), 50.0, GTK_POS_TOP, NULL) ;



  gtk_box_pack_start(GTK_BOX(playing_settings_volume_hbox), playing_settings_volume_label_hbox, FALSE,  FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(playing_settings_volume_hbox), playing_settings_volume_scale,      TRUE,   TRUE,  0) ;



  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_repeat_all,               FALSE, FALSE, 0)   ;
  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_shuffle,                  FALSE, FALSE, 0)   ;
  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_volume_hbox,              FALSE, FALSE, 0)   ;

  gtk_container_add(GTK_CONTAINER(playing_settings_frame), playing_settings_vbox) ;

  /** ***** [END] Playing settings [END] ***** **/



  /** ***** [START] Interface size setting [START] ***** **/

  GtkWidget *interface_size_frame = gtk_frame_new(" Interface size ") ;

  GtkWidget *interface_size_hbox  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(interface_size_hbox), DIALOG_DEFAULT_SPACE) ;

  GtkWidget *interface_size_radiobutton_little = gtk_radio_button_new_with_label(NULL, " Little") ;
  GtkWidget *interface_size_radiobutton_middle = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(interface_size_radiobutton_little)), " Medium") ;
  GtkWidget *interface_size_radiobutton_big    = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(interface_size_radiobutton_little)), "  Big  ") ;

  GtkWidget *interface_size_little_image       = gtk_image_new_from_file((settings.path_to_button_icons + "interface-little.png").c_str() ) ;
  GtkWidget *interface_size_middle_image       = gtk_image_new_from_file((settings.path_to_button_icons + "interface-middle.png").c_str() ) ;
  GtkWidget *interface_size_big_image          = gtk_image_new_from_file((settings.path_to_button_icons + "interface-big.png").c_str()    ) ;

  gtk_widget_set_tooltip_markup(interface_size_radiobutton_little, "Set the <b>interface size</b> on <b>little</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(interface_size_radiobutton_middle, "Set the <b>interface size</b> on <b>middle</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(interface_size_radiobutton_big,    "Set the <b>interface size</b> on <b>big</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.")    ;

  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_little), interface_size_little_image) ;
  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_middle), interface_size_middle_image) ;
  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_big),    interface_size_big_image   ) ;

  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_little), TRUE) ;
  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_middle), TRUE) ;
  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_big),    TRUE) ;

  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_little), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_middle), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_big),    FALSE) ;


  switch (settings.image_resized_size) {

    case IMAGE_RESIZED_SIZE_LITTLE :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_little), TRUE) ;
      break ;

    case IMAGE_RESIZED_SIZE_MIDDLE :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_middle), TRUE) ;
      break ;

    case IMAGE_RESIZED_SIZE_BIG :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_big),    TRUE) ;
      break ;

    default :
      break ;
  }


  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_little, TRUE, TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_middle, TRUE, TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_big,    TRUE, TRUE, 0) ;

  gtk_box_set_homogeneous(GTK_BOX(interface_size_hbox), TRUE) ;

  gtk_box_set_spacing(GTK_BOX(interface_size_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_container_add(GTK_CONTAINER(interface_size_frame), interface_size_hbox) ;

  /** ***** [END] Interface size setting [END] ***** **/



  /** ***** [START] Music folder setting [START] ***** **/

  GtkWidget *folder_selecting_frame = gtk_frame_new(" Music folder ") ;

  GtkWidget *folder_selecting_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(folder_selecting_box), DIALOG_DEFAULT_SPACE) ;


  GtkWidget *folder_selecting_button = gtk_file_chooser_button_new("Set the Music folder to open per default.", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ;

  gtk_widget_set_tooltip_markup(folder_selecting_button, "Set the folder to open per default: your <b>default music folder</b>.\n<i>The default folder from the folder selector</i>.\nSet it simply to your <b>Music folder</b>.\nChanges are immediatly applied.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_file_chooser_button_set_title(GTK_FILE_CHOOSER_BUTTON(folder_selecting_button), "Set the Music folder to open per default.") ;

  const char *user_music_folder = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC) ;

  gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(folder_selecting_button), (g_file_test(settings.path_to_music_folder.c_str(), G_FILE_TEST_IS_DIR)) ? settings.path_to_music_folder.c_str() : (user_music_folder != NULL) ? user_music_folder : g_get_home_dir()  ) ;


  gtk_box_pack_start(GTK_BOX(folder_selecting_box), folder_selecting_button,  TRUE, TRUE, 0)   ;

  gtk_container_add(GTK_CONTAINER(folder_selecting_frame), folder_selecting_box) ;

  /** ***** [END] Music folder setting [END] ***** **/



  /** ***** [START] Dialog main content box [START] ***** **/

  GtkWidget *content_area = gtk_dialog_get_content_area( GTK_DIALOG(configure_dialog) ) ;

  gtk_box_pack_start(GTK_BOX(content_area), icon_set_choice_frame,  FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), playing_settings_frame, FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), interface_size_frame,   FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), folder_selecting_frame, FALSE, FALSE, 0) ;

  gtk_box_set_spacing(GTK_BOX(content_area), DIALOG_DEFAULT_SPACE) ;

  /** ***** [END] Dialog main content box [END] ***** **/



  /** ***** [START] Dialog action buttons [START] ***** **/

  GtkWidget *button_close = gtk_button_new_with_label("Close") ; // gtk_dialog_add_button(GTK_DIALOG(configure_dialog), "Cancel", GTK_RESPONSE_CANCEL) ;

  GtkWidget *image_close  = gtk_image_new_from_file((settings.path_to_button_icons + "dialog-close.png").c_str()) ;

  gtk_widget_set_tooltip_markup(button_close, "<b>Close</b> the configuration window and don't store any setting.") ;

  gtk_button_set_image(GTK_BUTTON(button_close), image_close) ;

  gtk_button_set_always_show_image(GTK_BUTTON(button_close), TRUE) ;


  GtkWidget *button_ok = gtk_button_new_with_label("Apply") ; // gtk_dialog_add_button(GTK_DIALOG(configure_dialog), "Apply", GTK_RESPONSE_APPLY) ;

  GtkWidget *image_ok  = gtk_image_new_from_file((settings.path_to_button_icons + "dialog-ok.png").c_str()) ;

  gtk_widget_set_tooltip_markup(button_ok, "<b>Register</b> all the settings as <i>your default configuration</i> at start.") ;

  gtk_button_set_image(GTK_BUTTON(button_ok), image_ok) ;

  gtk_button_set_always_show_image(GTK_BUTTON(button_ok), TRUE) ;


  gtk_dialog_add_action_widget(GTK_DIALOG(configure_dialog), button_close, GTK_RESPONSE_CLOSE) ;

  gtk_dialog_add_action_widget(GTK_DIALOG(configure_dialog), button_ok,     GTK_RESPONSE_APPLY)  ;

  GtkWidget *action_area = gtk_dialog_get_action_area(GTK_DIALOG(configure_dialog)) ;

  gtk_container_set_border_width(GTK_CONTAINER(action_area), 0) ;

  gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area), GTK_BUTTONBOX_EDGE) ;

  /** ***** [END] Dialog action buttons [END] ***** **/



  Radio_Config high_contrast_radiobutton ;

  high_contrast_radiobutton.button  = radiobutton_icons_high_contrast ;
  high_contrast_radiobutton.image   = image_icons_high_contrast       ;

  high_contrast_radiobutton.volume  = playing_settings_volume_image       ;
  high_contrast_radiobutton.cancel  = image_close    ;
  high_contrast_radiobutton.apply   = image_ok       ;

  high_contrast_radiobutton.little  = interface_size_little_image ;
  high_contrast_radiobutton.middle  = interface_size_middle_image ;
  high_contrast_radiobutton.big     = interface_size_big_image    ;


  Radio_Config oxygen_radiobutton ;

  oxygen_radiobutton.button  = radiobutton_icons_oxygen ;
  oxygen_radiobutton.image   = image_icons_oxygen       ;

  oxygen_radiobutton.volume  = playing_settings_volume_image       ;
  oxygen_radiobutton.cancel  = image_close    ;
  oxygen_radiobutton.apply   = image_ok       ;

  oxygen_radiobutton.little  = interface_size_little_image ;
  oxygen_radiobutton.middle  = interface_size_middle_image ;
  oxygen_radiobutton.big     = interface_size_big_image    ;

  g_signal_connect(G_OBJECT(radiobutton_icons_high_contrast), "clicked", G_CALLBACK(configure_high_contrast_radiobutton), &high_contrast_radiobutton) ;
  g_signal_connect(G_OBJECT(radiobutton_icons_oxygen),        "clicked", G_CALLBACK(configure_oxygen_radiobutton),        &oxygen_radiobutton       ) ;


  int little = -1 ;
  int middle =  0 ;
  int big    =  1 ;

  g_signal_connect(G_OBJECT(interface_size_radiobutton_little), "clicked",       G_CALLBACK(reconfigure_interface_size), &little) ;
  g_signal_connect(G_OBJECT(interface_size_radiobutton_middle), "clicked",       G_CALLBACK(reconfigure_interface_size), &middle) ;
  g_signal_connect(G_OBJECT(interface_size_radiobutton_big),    "clicked",       G_CALLBACK(reconfigure_interface_size), &big)    ;


  g_signal_connect(G_OBJECT(playing_settings_repeat_all),       "toggled",       G_CALLBACK(repeat_all_feature_set),     NULL)    ;
  g_signal_connect(G_OBJECT(playing_settings_shuffle),          "toggled",       G_CALLBACK(shuffle_feature_set),        NULL)    ;
  g_signal_connect(G_OBJECT(playing_settings_volume_scale),     "value-changed", G_CALLBACK(get_volume),                 NULL)    ;
  g_signal_connect(G_OBJECT(folder_selecting_button),           "file-set",      G_CALLBACK(set_default_folder),         NULL)    ;


  gtk_widget_show_all(configure_dialog) ;



  int response = gtk_dialog_run(GTK_DIALOG(configure_dialog))  ;

  switch (response) {

    case GTK_RESPONSE_APPLY :

      {

        GKeyFile *conf_file = g_key_file_new() ;

        GError *error = NULL ;

        settings.is_repeat_all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(playing_settings_repeat_all)) ;

        settings.is_shuffle       = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(playing_settings_shuffle))    ;



        // Set configuration settings to configuration file buffer.
        g_key_file_set_string(conf_file,   "Config",  "Buttons_Icons_Path",   settings.path_to_button_icons.c_str()) ;

        g_key_file_set_string(conf_file,   "Config",  "Menu_Icons_Path",      settings.path_to_menu_icons.c_str())   ;

        g_key_file_set_string(conf_file,   "Config",  "Music_Folder",         settings.path_to_music_folder.c_str())   ;

        g_key_file_set_boolean(conf_file,  "Config",  "Is_Oxygen",            settings.icon_set_oxygen) ;
        g_key_file_set_boolean(conf_file,  "Config",  "Repeat_all",           settings.is_repeat_all)  ;
        g_key_file_set_boolean(conf_file,  "Config",  "Shuffle",              settings.is_shuffle) ;

        g_key_file_set_double(conf_file,   "Config",  "Volume",               settings.volume) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Buttons_space",        settings.space_buttons) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Display_Size",         settings.display_size) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Image_Resizing",       settings.image_resized_size) ;

        g_key_file_set_string(conf_file,   "Config",  "Sized_Default_Image",  settings.path_to_default_image.c_str())   ;

        // Write to configuration file
        g_key_file_save_to_file(conf_file, PATH_TO_CONF_FILE, &error);

        // Setting global variables.
        cover_image    = settings.path_to_default_image ;
        current_folder = settings.path_to_music_folder ;

        if ( error != NULL ) {

          display_message_dialog("Error store configuration !", "Cannot store the configuration.") ;

          #ifdef DEBUG
          fprintf(stdout,"\n%s: Error store configuratiom settings.\n", prgname.c_str() )    ; fflush(stdout) ;
          #endif
        }
        else { // Success
          #ifdef DEBUG
          fprintf(stdout,"\n%s: Success store configuratiom settings.\n", prgname.c_str() )  ;
          #endif
        }

      }

      break ;

    case GTK_RESPONSE_CLOSE :
      // Do nothing.
      break ;
  }

  gtk_widget_destroy(configure_dialog) ;

  return ;

}
Esempio n. 11
0
/*!
    \return Pure instance from IjadiGui
*/
IjadiGui * 		Ijadi_gui_new()
{
	IjadiGui *object = g_object_new(IJADI_TYPE_GUI,
					   "type", GTK_WINDOW_TOPLEVEL,NULL);

	//Style Provider
	GtkStyleProvider *provider;
	provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
	gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),provider,GTK_STYLE_PROVIDER_PRIORITY_FORCE);
	//Private creator
	IjadiGuiPrivate *priv = IJADI_GUI_PRIVATE(object);
	//Prepare Window
	gtk_window_set_position (GTK_WINDOW(object),GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW(object), "Ijadi");
	//gtk_window_set_icon (GTK_WINDOW(object),create_pixbuf("/home/bijan/Source/Ijadi/PURE/Resourses/e.png"));

	//Style for window
	//gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(object)), "ijadi-window");
	//gtk_css_provider_load_from_path (GTK_CSS_PROVIDER(provider),LOCAL_RESOURCES"/style.css",NULL);
	//gtk_style_context_reset_widgets (gdk_screen_get_default ());
	//------------Create Widget----------------
	//Add welcome image
	priv->img_welcome = gtk_image_new_from_file ("/home/bijan/Project/Ijadi/PURE/Resources/mainwindow-welcome.png");
	//Add Button
	priv->btn_new_project = gtk_button_new_with_label("New Project");
	priv->img_new_project = gtk_image_new_from_file ("/home/bijan/Pictures/Icons/Files-Edit-file-icon.png");
	gtk_button_set_always_show_image(GTK_BUTTON(priv->btn_new_project),TRUE);
	gtk_button_set_image (GTK_BUTTON(priv->btn_new_project),priv->img_new_project);
	//
	priv->btn_open_project = gtk_button_new_with_label("Open Project");
	priv->img_open_project = gtk_image_new_from_file ("/home/bijan/Pictures/Icons/folder-open-icon.png");
	gtk_button_set_always_show_image(GTK_BUTTON(priv->btn_open_project),TRUE);
	gtk_button_set_image (GTK_BUTTON(priv->btn_open_project),priv->img_open_project);
	//
	priv->btn_import_project = gtk_button_new_with_label("Import Project");
	priv->img_import_project = gtk_image_new_from_file ("/home/bijan/Pictures/Icons/import-icon.png");
	gtk_button_set_always_show_image(GTK_BUTTON(priv->btn_import_project),TRUE);
	gtk_button_set_image (GTK_BUTTON(priv->btn_import_project),priv->img_import_project);
	//
	priv->btn_import_url = gtk_button_new_with_label ("Import URL");
	priv->img_import_url = gtk_image_new_from_file ("/home/bijan/Pictures/Icons/1372885853_folder_apollon.png");
	gtk_button_set_always_show_image(GTK_BUTTON(priv->btn_import_url),TRUE);
	gtk_button_set_image (GTK_BUTTON(priv->btn_import_url),priv->img_import_url);
	//--------------Create Menu--------------
	priv->menu_bar = ijadi_gui_create_menubar ();
	//------------Create ToolBar-------------
	priv->toolbar = ijadi_gui_create_toolbar();
	//------------Create Layout--------------
	//Create Button Box row 1
	priv->box_button = gtk_grid_new ();
	gtk_grid_attach (GTK_GRID(box_button),priv->btn_new_project,0,0,1,1);
	gtk_grid_attach (GTK_GRID(box_button),priv->btn_open_project,1,0,1,1);
	gtk_box_pack_start (GTK_BOX(priv->box_button_1),priv->btn_new_project,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(priv->box_button_1),priv->btn_open_project,TRUE,TRUE,0);
	gtk_widget_set_margin_right(priv->box_button_1,5);
	gtk_widget_set_margin_left(priv->box_button_1,5);
	gtk_widget_set_margin_bottom(priv->box_button_1,5);
	gtk_widget_set_margin_top(priv->box_button_1,5);
	//Create Button Box row 2
	priv->box_button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_box_pack_start (GTK_BOX(priv->box_button_2),priv->btn_import_project,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(priv->box_button_2),priv->btn_import_url,TRUE,TRUE,0);
	gtk_widget_set_margin_right(priv->box_button_2,5);
	gtk_widget_set_margin_left(priv->box_button_2,5);
	gtk_widget_set_margin_bottom(priv->box_button_2,5);
	gtk_widget_set_margin_top(priv->box_button_2,5);
	//
	
	priv->box_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start (GTK_BOX(priv->box_main),priv->menu_bar,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(priv->box_main),priv->toolbar,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(priv->box_main),priv->img_welcome,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(priv->box_main),priv->box_button_1,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(priv->box_main),priv->box_button_2,TRUE,TRUE,0);
	
	//Add layout to window
	gtk_container_add (GTK_CONTAINER (object), priv->box_main);
	//-----------Connect Signal-------------
	g_signal_connect (GTK_WIDGET(object), "destroy", G_CALLBACK (gtk_main_quit), NULL);
	g_signal_connect (priv->btn_new_project, "clicked", G_CALLBACK (ijadi_gui_btn_new_project_clicked), object);
	//------------------Finalize-----------------
	gtk_window_set_application (GTK_WINDOW(object),GTK_APPLICATION(IJADI_APP));
	return object;
}
Esempio n. 12
0
int
main (int    argc,
      char **argv)
{
  GtkWidget *window, *label, *entry, *button, *grid, *notebook;
  GtkWidget *vbox, *hbox, *grid_hbox, *spin, *spin2, *toggle, *combo, *image, *ebox;
  PangoFontDescription *font;
  GtkAdjustment *adjustment;
  int i, j;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);

  notebook = gtk_notebook_new ();
  gtk_container_add (GTK_CONTAINER (window), notebook);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
			    vbox, gtk_label_new ("hboxes"));

  for (j = 0; j < 2; j++)
    {
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 5);

      char *aligns_names[] = { "FILL", "BASELINE" };
      GtkAlign aligns[] = { GTK_ALIGN_FILL, GTK_ALIGN_BASELINE};

      label = gtk_label_new (aligns_names[j]);
      gtk_container_add (GTK_CONTAINER (hbox), label);

      for (i = 0; i < 3; i++) {
	label = gtk_label_new ("│XYyj,Ö...");

	font = pango_font_description_new ();
	pango_font_description_set_size (font, 5*(i+1)* 1024);
	gtk_widget_override_font (label, font);

	gtk_widget_set_valign (label, aligns[j]);

	gtk_container_add (GTK_CONTAINER (hbox), label);
      }

      for (i = 0; i < 3; i++) {
	entry = gtk_entry_new ();
	gtk_entry_set_text (GTK_ENTRY (entry), "│XYyj,Ö...");

	font = pango_font_description_new ();
	pango_font_description_set_size (font, 5*(i+1)* 1024);
	gtk_widget_override_font (entry, font);

	gtk_widget_set_valign (entry, aligns[j]);

	gtk_container_add (GTK_CONTAINER (hbox), entry);
      }

      spin = gtk_spin_button_new (NULL, 0, 1);
      gtk_orientable_set_orientation (GTK_ORIENTABLE (spin), GTK_ORIENTATION_VERTICAL);
      gtk_widget_set_valign (spin, aligns[j]);
      gtk_container_add (GTK_CONTAINER (hbox), spin);
    }

  grid_hbox = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);

  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[0]);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[1]);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[2]);
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1);
  gtk_container_add (GTK_CONTAINER (hbox), combo);

  for (j = 0; j < 2; j++)
    {
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);

      g_signal_connect (G_OBJECT (combo), "changed",
			G_CALLBACK (baseline_position_changed), hbox);

      if (j == 0)
	label = gtk_label_new ("Baseline:");
      else
	label = gtk_label_new ("Normal:");
      gtk_container_add (GTK_CONTAINER (hbox), label);

      for (i = 0; i < 3; i++)
	{
	  button = gtk_button_new_with_label ("│Xyj,Ö");

	  font = pango_font_description_new ();
	  pango_font_description_set_size (font, 5*(i+1)* 1024);
	  gtk_widget_override_font (button, font);

	  if (j == 0)
	    gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);

	  gtk_container_add (GTK_CONTAINER (hbox), button);
	}

      for (i = 0; i < 3; i++)
	{
	  button = gtk_button_new_with_label ("│Xyj,Ö");

	  gtk_button_set_image (GTK_BUTTON (button),
				gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
	  gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);

	  font = pango_font_description_new ();
	  pango_font_description_set_size (font, 5*(i+1)* 1024);
	  gtk_widget_override_font (button, font);

	  if (j == 0)
	    gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);

	  gtk_container_add (GTK_CONTAINER (hbox), button);
	}

      ebox = gtk_event_box_new ();
      if (j == 0)
	gtk_widget_set_valign (ebox, GTK_ALIGN_BASELINE);
      gtk_container_add (GTK_CONTAINER (hbox), ebox);

      image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON);
      gtk_image_set_pixel_size (GTK_IMAGE (image), 34);
      if (j == 0)
	gtk_widget_set_valign (image, GTK_ALIGN_BASELINE);
      gtk_container_add (GTK_CONTAINER (ebox), image);

      button = gtk_toggle_button_new_with_label ("│Xyj,Ö");
      if (j == 0)
	gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
      gtk_container_add (GTK_CONTAINER (hbox), button);

      button = gtk_toggle_button_new_with_label ("│Xyj,Ö");
      gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), TRUE);
      if (j == 0)
	gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
      gtk_container_add (GTK_CONTAINER (hbox), button);

      button = gtk_check_button_new_with_label ("│Xyj,Ö");
      if (j == 0)
	gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
      gtk_container_add (GTK_CONTAINER (hbox), button);

      button = gtk_radio_button_new_with_label (NULL, "│Xyj,Ö");
      if (j == 0)
	gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
      gtk_container_add (GTK_CONTAINER (hbox), button);
    }


  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
			    vbox, gtk_label_new ("grid"));

  grid_hbox = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);

  label = gtk_label_new ("Align me:");
  gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);

  gtk_container_add (GTK_CONTAINER (hbox), label);

  grid = gtk_grid_new ();
  gtk_widget_set_valign (grid, GTK_ALIGN_BASELINE);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 8);
  gtk_grid_set_row_spacing (GTK_GRID (grid), 8);

  for (j = 0; j < 4; j++)
    {
      char *labels[] = { "Normal:", "Baseline (top):", "Baseline (center):", "Baseline (bottom):"};
      label = gtk_label_new (labels[j]);

      gtk_grid_attach (GTK_GRID (grid),
		       label,
		       0, j,
		       1, 1);
      gtk_widget_set_vexpand (label, TRUE);

      if (j != 0)
	gtk_grid_set_row_baseline_position (GTK_GRID (grid),
					    j, (GtkBaselinePosition)(j-1));

      for (i = 0; i < 3; i++)
	{
	  label = gtk_label_new ("Xyjg,Ö.");

	  font = pango_font_description_new ();
	  pango_font_description_set_size (font, 5*(i+1)* 1024);
	  gtk_widget_override_font (label, font);

	  if (j != 0)
	    gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);

	  gtk_grid_attach (GTK_GRID (grid),
			   label,
			   i+1, j,
			   1, 1);
	}

      for (i = 0; i < 3; i++)
	{
	  button = gtk_button_new_with_label ("│Xyj,Ö");

	  gtk_button_set_image (GTK_BUTTON (button),
				gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
	  gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);

	  font = pango_font_description_new ();
	  pango_font_description_set_size (font, 5*(i+1)* 1024);
	  gtk_widget_override_font (button, font);

	  if (j != 0)
	    gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);

	  gtk_grid_attach (GTK_GRID (grid),
			   button,
			   i+4, j,
			   1, 1);
	}

    }

  gtk_container_add (GTK_CONTAINER (hbox), grid);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 5);

  adjustment = gtk_adjustment_new (0.0, -1.0, 5.0, 1.0, 1.0, 0.0);
  spin = gtk_spin_button_new (adjustment, 1.0, 0);
  g_signal_connect (spin, "value-changed", (GCallback)baseline_row_value_changed, grid);
  gtk_container_add (GTK_CONTAINER (hbox), spin);

  toggle = gtk_toggle_button_new_with_label ("Homogeneous");
  g_signal_connect (toggle, "toggled", (GCallback)homogeneous_changed, grid);
  gtk_container_add (GTK_CONTAINER (hbox), toggle);

  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[0]);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[1]);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[2]);
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1);
  g_signal_connect (G_OBJECT (combo), "changed",
		    G_CALLBACK (baseline_position_changed), grid_hbox);
  gtk_container_add (GTK_CONTAINER (hbox), combo);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
			    vbox, gtk_label_new ("button box"));

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 5);

  adjustment = gtk_adjustment_new (34.0, 1.0, 64.0, 1.0, 1.0, 0.0);
  spin = gtk_spin_button_new (adjustment, 1.0, 0);
  gtk_container_add (GTK_CONTAINER (hbox), spin);

  adjustment = gtk_adjustment_new (16.0, 1.0, 64.0, 1.0, 1.0, 0.0);
  spin2 = gtk_spin_button_new (adjustment, 1.0, 0);
  gtk_container_add (GTK_CONTAINER (hbox), spin2);

  for (j = 0; j < 3; j++)
    {
      hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);

      gtk_box_set_baseline_position (GTK_BOX (hbox), j);

      label = gtk_label_new (baseline_pos_str[j]);
      gtk_container_add (GTK_CONTAINER (hbox), label);
      gtk_widget_set_vexpand (label, TRUE);

      image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON);
      gtk_image_set_pixel_size (GTK_IMAGE (image), 34);
      gtk_container_add (GTK_CONTAINER (hbox), image);

      g_signal_connect (spin, "value-changed", (GCallback)image_size_value_changed, image);

      for (i = 0; i < 3; i++)
	{
	  button = gtk_button_new_with_label ("│Xyj,Ö");

	  font = pango_font_description_new ();
	  pango_font_description_set_size (font, 5*(i+1)* 1024);
	  gtk_widget_override_font (button, font);

	  if (i != 0)
	    gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);

	  gtk_container_add (GTK_CONTAINER (hbox), button);
	}

      for (i = 0; i < 3; i++)
	{
	  button = gtk_button_new_with_label ("│Xyj,Ö");

	  image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON);
	  gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
	  gtk_button_set_image (GTK_BUTTON (button), image);
	  if (i == 0)
	    g_signal_connect (spin2, "value-changed", (GCallback)image_size_value_changed, image);
	  gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);

	  font = pango_font_description_new ();
	  pango_font_description_set_size (font, 5*(i+1)* 1024);
	  gtk_widget_override_font (button, font);

	  gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);

	  gtk_container_add (GTK_CONTAINER (hbox), button);
	}
    }

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}