示例#1
0
void
go_color_palette_set_title (GOColorPalette *pal, char const *title)
{
	g_object_set_data_full (G_OBJECT (pal), "title",
		g_strdup (title), g_free);
}
GtkWidget *
e_plugin_lib_get_configure_widget (EPlugin *plugin)
{
	GtkCellRenderer *renderer;
	GtkTreeSelection *selection;
	GtkTreeIter iter;
	GtkWidget *hbox;
	gchar **clue_list;
	gint i;

	GtkWidget *reminder_configuration_box;
	GtkWidget *clue_container;
	GtkWidget *scrolledwindow1;
	GtkWidget *clue_treeview;
	GtkWidget *vbuttonbox2;
	GtkWidget *clue_add;
	GtkWidget *clue_edit;
	GtkWidget *clue_remove;

	UIData *ui = g_new0 (UIData, 1);

	reminder_configuration_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_widget_show (reminder_configuration_box);
	gtk_widget_set_size_request (reminder_configuration_box, 385, 189);

	clue_container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	gtk_widget_show (clue_container);
	gtk_box_pack_start (
		GTK_BOX (reminder_configuration_box),
		clue_container, TRUE, TRUE, 0);

	scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_show (scrolledwindow1);
	gtk_box_pack_start (GTK_BOX (clue_container), scrolledwindow1, TRUE, TRUE, 0);
	gtk_scrolled_window_set_policy (
		GTK_SCROLLED_WINDOW (scrolledwindow1),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	clue_treeview = gtk_tree_view_new ();
	gtk_widget_show (clue_treeview);
	gtk_container_add (GTK_CONTAINER (scrolledwindow1), clue_treeview);
	gtk_container_set_border_width (GTK_CONTAINER (clue_treeview), 1);

	vbuttonbox2 = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
	gtk_widget_show (vbuttonbox2);
	gtk_box_pack_start (GTK_BOX (clue_container), vbuttonbox2, FALSE, TRUE, 0);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (vbuttonbox2), GTK_BUTTONBOX_START);
	gtk_box_set_spacing (GTK_BOX (vbuttonbox2), 6);

	clue_add = e_dialog_button_new_with_icon ("list-add", _("_Add"));
	gtk_widget_show (clue_add);
	gtk_container_add (GTK_CONTAINER (vbuttonbox2), clue_add);
	gtk_widget_set_can_default (clue_add, TRUE);

	clue_edit = gtk_button_new_with_mnemonic (_("_Edit"));
	gtk_widget_show (clue_edit);
	gtk_container_add (GTK_CONTAINER (vbuttonbox2), clue_edit);
	gtk_widget_set_can_default (clue_edit, TRUE);

	clue_remove = e_dialog_button_new_with_icon ("list-remove", _("_Remove"));
	gtk_widget_show (clue_remove);
	gtk_container_add (GTK_CONTAINER (vbuttonbox2), clue_remove);
	gtk_widget_set_can_default (clue_remove, TRUE);

	ui->settings = e_util_ref_settings ("org.gnome.evolution.plugin.attachment-reminder");

	ui->treeview = clue_treeview;

	ui->store = gtk_list_store_new (CLUE_N_COLUMNS, G_TYPE_STRING);

	gtk_tree_view_set_model (
		GTK_TREE_VIEW (ui->treeview),
		GTK_TREE_MODEL (ui->store));

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (
		GTK_TREE_VIEW (ui->treeview), -1, _("Keywords"),
		renderer, "text", CLUE_KEYWORD_COLUMN, NULL);
	g_object_set (renderer, "editable", TRUE, NULL);
	g_signal_connect (
		renderer, "edited",
		G_CALLBACK (cell_edited_cb), ui);
	g_signal_connect (
		renderer, "editing-canceled",
		G_CALLBACK (cell_editing_canceled_cb), ui);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ui->treeview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	g_signal_connect (
		selection, "changed",
		G_CALLBACK (selection_changed), ui);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ui->treeview), TRUE);

	ui->clue_add = clue_add;
	g_signal_connect (
		ui->clue_add, "clicked",
		G_CALLBACK (clue_add_clicked), ui);

	ui->clue_remove = clue_remove;
	g_signal_connect (
		ui->clue_remove, "clicked",
		G_CALLBACK (clue_remove_clicked), ui);
	gtk_widget_set_sensitive (ui->clue_remove, FALSE);

	ui->clue_edit = clue_edit;
	g_signal_connect (
		ui->clue_edit, "clicked",
		G_CALLBACK (clue_edit_clicked), ui);
	gtk_widget_set_sensitive (ui->clue_edit, FALSE);

	/* Populate tree view with values from GSettings */
	clue_list = g_settings_get_strv (ui->settings, CONF_KEY_ATTACH_REMINDER_CLUES);

	for (i = 0; clue_list[i] != NULL; i++) {
		gtk_list_store_append (ui->store, &iter);
		gtk_list_store_set (ui->store, &iter, CLUE_KEYWORD_COLUMN, clue_list[i], -1);
	}

	g_strfreev (clue_list);

	/* Add the list here */

	hbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

	gtk_box_pack_start (GTK_BOX (hbox), reminder_configuration_box, TRUE, TRUE, 0);

	/* to let free data properly on destroy of configuration widget */
	g_object_set_data_full (G_OBJECT (hbox), "myui-data", ui, destroy_ui_data);

	return hbox;
}
示例#3
0
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_get_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), "draw", G_CALLBACK(on_countdown_draw), windata);
	}

	button = gtk_button_new();
	gtk_widget_show(button);
	gtk_box_pack_start(GTK_BOX(windata->actions_box), button, FALSE, FALSE, 0);
	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
	gtk_container_set_border_width(GTK_CONTAINER(button), 0);

	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 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_window_get_screen(gtk_widget_get_window(GTK_WIDGET(nw)))),
									  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_widget_set_halign (image, GTK_ALIGN_CENTER);
		gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
	}

	label = gtk_label_new(NULL);
	gtk_widget_show(label);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION (3, 16, 0)
	gtk_label_set_xalign (GTK_LABEL (label), 0.0);
	gtk_label_set_yalign (GTK_LABEL (label), 0.5);
#else
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
#endif
	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(on_action_clicked), cb);
}
示例#4
0
/**
 * e_webdav_discover_content_new:
 * @credentials_prompter: an #ECredentialsPrompter to use to ask for credentials
 * @source: (allow-none): optional #ESource to use for authentication, or %NULL
 * @base_url: (allow-none): optional base URL to use for discovery, or %NULL
 * @supports_filter: a bit-or of #EWebDAVDiscoverSupports, a filter to limit what source
 *    types will be shown in the dialog content; use %E_WEBDAV_DISCOVER_SUPPORTS_NONE
 *    to show all
 *
 * Creates a new WebDAV discovery content, which is a #GtkGrid containing necessary
 * widgets to provide a UI interface for a user to search and select for available
 * WebDAV (CalDAV or CardDAV) sources provided by the given server. Do not pack
 * anything into this content, its content can be changed dynamically.
 *
 * Returns: (transfer full): a new WebDAV discovery content widget.
 *
 * Since: 3.18
 **/
GtkWidget *
e_webdav_discover_content_new (ECredentialsPrompter *credentials_prompter,
			       ESource *source,
			       const gchar *base_url,
			       guint supports_filter)
{
	EWebDAVDiscoverContentData *data;
	GtkWidget *content, *scrolled_window, *tree_view;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	GtkListStore *list_store;
	GtkGrid *grid;

	g_return_val_if_fail (E_IS_CREDENTIALS_PROMPTER (credentials_prompter), NULL);
	g_return_val_if_fail (base_url != NULL, NULL);

	data = g_new0 (EWebDAVDiscoverContentData, 1);
	data->credentials_prompter = g_object_ref (credentials_prompter);
	data->source = source ? g_object_ref (source) : NULL;
	data->base_url = g_strdup (base_url);
	data->supports_filter = supports_filter;

	content = gtk_grid_new ();
	grid = GTK_GRID (content);
	gtk_container_set_border_width (GTK_CONTAINER (grid), 4);
	gtk_grid_set_row_spacing (grid, 4);
	gtk_grid_set_column_spacing (grid, 4);

	g_object_set_data_full (G_OBJECT (content), WEBDAV_DISCOVER_CONTENT_DATA_KEY, data, e_webdav_discover_content_data_free);

	list_store = gtk_list_store_new (N_COLUMNS,
					 G_TYPE_STRING, /* COL_HREF_STRING */
					 G_TYPE_UINT, /* COL_SUPPORTS_UINT */
					 G_TYPE_STRING, /* COL_DISPLAY_NAME_STRING */
					 G_TYPE_STRING, /* COL_COLOR_STRING */
					 G_TYPE_STRING, /* COL_DESCRIPTION_STRING */
					 G_TYPE_STRING, /* COL_SUPPORTS_STRING */
					 GDK_TYPE_RGBA, /* COL_COLOR_GDKRGBA */
					 G_TYPE_BOOLEAN); /* COL_SHOW_COLOR_BOOLEAN */

	tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
	g_object_unref (list_store);

	g_object_set (G_OBJECT (tree_view),
		"hexpand", TRUE,
		"vexpand", TRUE,
		"halign", GTK_ALIGN_FILL,
		"valign", GTK_ALIGN_FILL,
		NULL);

	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
	gtk_grid_attach (grid, scrolled_window, 0, 0, 1, 1);

	data->sources_tree_view = GTK_TREE_VIEW (tree_view);

	renderer = e_cell_renderer_color_new ();
	g_object_set (G_OBJECT (renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);

	column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "rgba", COL_COLOR_GDKRGBA, "visible", COL_SHOW_COLOR_BOOLEAN, NULL);
	gtk_tree_view_append_column (data->sources_tree_view, column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_add_attribute (column, renderer, "markup", COL_DESCRIPTION_STRING);
	g_object_set (G_OBJECT (renderer),
		"max-width-chars", 60,
		"wrap-mode", PANGO_WRAP_WORD_CHAR,
		"wrap-width", 640,
		NULL);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Supports"), renderer, "text", COL_SUPPORTS_STRING, NULL);
	gtk_tree_view_append_column (data->sources_tree_view, column);

	if (!supports_filter || (supports_filter & (E_WEBDAV_DISCOVER_SUPPORTS_EVENTS |
	    E_WEBDAV_DISCOVER_SUPPORTS_MEMOS | E_WEBDAV_DISCOVER_SUPPORTS_TASKS)) != 0) {
		GtkWidget *widget, *box;

		widget = gtk_combo_box_text_new ();
		data->email_addresses_combo = GTK_COMBO_BOX (widget);

		box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
		widget = gtk_label_new_with_mnemonic (_("_User mail:"));
		gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (data->email_addresses_combo));

		gtk_container_add (GTK_CONTAINER (box), widget);
		gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (data->email_addresses_combo));

		g_object_set (G_OBJECT (widget),
			"hexpand", FALSE,
			"vexpand", FALSE,
			"halign", GTK_ALIGN_START,
			"valign", GTK_ALIGN_CENTER,
			NULL);

		g_object_set (G_OBJECT (data->email_addresses_combo),
			"hexpand", TRUE,
			"vexpand", FALSE,
			"halign", GTK_ALIGN_FILL,
			"valign", GTK_ALIGN_START,
			NULL);

		g_object_set (G_OBJECT (box),
			"hexpand", TRUE,
			"vexpand", FALSE,
			"halign", GTK_ALIGN_FILL,
			"valign", GTK_ALIGN_START,
			NULL);

		gtk_grid_attach (grid, box, 0, 1, 1, 1);
	}

	gtk_widget_show_all (content);

	return content;
}
示例#5
0
GtkWidget *
do_form_model_change (GtkWidget *do_widget)
{  
	if (!window) {
                GdaStatement *stmt;
		GtkWidget *vbox;
		GtkWidget *label;
		GdaDataModel *models [3];
		
		window = gtk_dialog_new_with_buttons ("Changing data in a GdauiForm",
						      GTK_WINDOW (do_widget),
						      0,
						      "Close", GTK_RESPONSE_NONE,
						      NULL);
		
		g_signal_connect (window, "response",
				  G_CALLBACK (gtk_widget_destroy), NULL);
		g_signal_connect (window, "destroy",
				  G_CALLBACK (gtk_widget_destroyed), &window);
		
		vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
		gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))),
				    vbox, TRUE, TRUE, 0);
		gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
		
		label = gtk_label_new ("The data in the same GdauiForm widget can be change don the fly.");
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

		/* creating data models */
		stmt = gda_sql_parser_parse_string (demo_parser, "SELECT * FROM products ORDER BY ref, category LIMIT 15", NULL, NULL);
		models[0] = gda_connection_statement_execute_select (demo_cnc, stmt, NULL, NULL);
		gda_data_select_compute_modification_statements (GDA_DATA_SELECT (models[0]), NULL);
		g_object_unref (stmt);

		stmt = gda_sql_parser_parse_string (demo_parser, "SELECT * FROM products WHERE price > 20.2 ORDER BY ref, category LIMIT 10", NULL, NULL);
		models[1] = gda_connection_statement_execute_select (demo_cnc, stmt, NULL, NULL);
		gda_data_select_compute_modification_statements (GDA_DATA_SELECT (models[1]), NULL);
		g_object_unref (stmt);

		stmt = gda_sql_parser_parse_string (demo_parser, "SELECT name, price, ref, category FROM products WHERE price > 20.2 ORDER BY name LIMIT 30", NULL, NULL);
		models[2] = gda_connection_statement_execute_select (demo_cnc, stmt, NULL, NULL);
		gda_data_select_compute_modification_statements (GDA_DATA_SELECT (models[2]), NULL);
		g_object_unref (stmt);

		
		/* allow choosing which data model to display */
		label = gtk_label_new ("");
		gtk_widget_set_halign (label, GTK_ALIGN_START);
                gtk_label_set_markup (GTK_LABEL (label), "<b>Choose which data model to display:</b>");
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

		GtkWidget *layout, *rb;
		GSList *group = NULL;
		gint i;
		layout = gtk_grid_new ();
		gtk_box_pack_start (GTK_BOX (vbox), layout, FALSE, FALSE, 0);
		
		for (i = 0; i < 3; i++) {
			gchar *str;
			str = g_strdup_printf ("%d columns x %d rows", gda_data_model_get_n_columns (models[i]),
					       gda_data_model_get_n_rows (models[i]));
			rb = gtk_radio_button_new_with_label (group, str);
			g_free (str);
			gtk_grid_attach (GTK_GRID (layout), rb, i, 0, 1, 1);
			g_signal_connect (rb, "toggled", G_CALLBACK (model_toggled_cb), models[i]);
			g_object_set_data_full (G_OBJECT (rb), "model", models[i], g_object_unref);
			group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (rb));
		}

		/* Create the form widget */
		label = gtk_label_new ("");
		gtk_widget_set_halign (label, GTK_ALIGN_START);
                gtk_label_set_markup (GTK_LABEL (label), "<b>GdauiForm:</b>");
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

		form = gdaui_form_new (models[0]);
		g_object_set (G_OBJECT (form), "info-flags",
                              GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
                              GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS |
                              GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS, NULL);
		gtk_box_pack_start (GTK_BOX (vbox), form, TRUE, TRUE, 0);

		GdaDataProxy *proxy;
		proxy = gdaui_data_proxy_get_proxy (GDAUI_DATA_PROXY (form));
		g_object_set (proxy, "cache-changes", TRUE, NULL);
	}

	gboolean visible;
	g_object_get (G_OBJECT (window), "visible", &visible, NULL);
	if (!visible)
		gtk_widget_show_all (window);
	else {
		gtk_widget_destroy (window);
		window = NULL;
	}

	return window;
}
/* 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);
}
示例#7
0
static void
install_icons (GnmApp *app)
{
	static const char *icons[] = {
		/* Cursors */
		"cursor_cross.xpm",
		"bucket.xpm",
		"font.xpm",
		"sheet_move_marker.xpm",

		/* Patterns */
		"gp_125grey.xpm",
		"gp_25grey.xpm",
		"gp_50grey.xpm",
		"gp_625grey.xpm",
		"gp_75grey.xpm",
		"gp_bricks.xpm",
		"gp_diag.xpm",
		"gp_diag_cross.xpm",
		"gp_foreground_solid.xpm",
		"gp_horiz.xpm",
		"gp_large_circles.xpm",
		"gp_rev_diag.xpm",
		"gp_semi_circle.xpm",
		"gp_small_circle.xpm",
		"gp_solid.xpm",
		"gp_thatch.xpm",
		"gp_thick_diag_cross.xpm",
		"gp_thin_diag.xpm",
		"gp_thin_diag_cross.xpm",
		"gp_thin_horiz.xpm",
		"gp_thin_horiz_cross.xpm",
		"gp_thin_rev_diag.xpm",
		"gp_thin_vert.xpm",
		"gp_vert.xpm",
		"line_pattern_dash_dot.xpm",
		"line_pattern_dash_dot_dot.xpm",
		"line_pattern_dashed.xpm",
		"line_pattern_dotted.xpm",
		"line_pattern_double.xpm",
		"line_pattern_hair.xpm",
		"line_pattern_medium.xpm",
		"line_pattern_medium_dash.xpm",
		"line_pattern_medium_dash_dot.xpm",
		"line_pattern_medium_dash_dot_dot.xpm",
		"line_pattern_slant.xpm",
		"line_pattern_thick.xpm",
		"line_pattern_thin.xpm",

		/* Borders */
		"bottom_border.xpm",
		"diag_border.xpm",
		"inside_border.xpm",
		"inside_horiz_border.xpm",
		"inside_vert_border.xpm",
		"left_border.xpm",
		"no_border.xpm",
		"outline_border.xpm",
		"rev_diag_border.xpm",
		"right_border.xpm",
		"top_border.xpm"
	};
	static struct {
		const char *scalable_filename;
		const char *sized_filename;
		const char *stock_id;
	} const icons2[] = {
		{
			"column_add_24.xpm",
			"column_add_16.xpm",
			"Gnumeric_ColumnAdd"
		},
		{
			"column_delete_24.xpm",
			"column_delete_16.xpm",
			"Gnumeric_ColumnDelete"
		},
		{
			"column_size_24.xpm",
			"column_size_16.xpm",
			"Gnumeric_ColumnSize"
		},
		{
			"column_hide_24.xpm",
			"column_hide_16.xpm",
			"Gnumeric_ColumnHide"
		},
		{
			"column_unhide_24.xpm",
			"column_unhide_16.xpm",
			"Gnumeric_ColumnUnhide"
		},
		{
			"row_add_24.xpm",
			"row_add_16.xpm",
			"Gnumeric_RowAdd"
		},
		{
			"row_delete_24.xpm",
			"row_delete_16.xpm",
			"Gnumeric_RowDelete"
		},
		{
			"row_size_24.xpm",
			"row_size_16.xpm",
			"Gnumeric_RowSize"
		},
		{
			"row_hide_24.xpm",
			"row_hide_16.xpm",
			"Gnumeric_RowHide"
		},
		{
			"row_unhide_24.xpm",
			"row_unhide_16.xpm",
			"Gnumeric_RowUnhide"
		},

		{
			"group_24.xpm",
			"group_16.xpm",
			"Gnumeric_Group"
		},
		{
			"ungroup_24.xpm",
			"ungroup_16.xpm",
			"Gnumeric_Ungroup"
		},
		{
			"show_detail_24.xpm",
			"show_detail_16.xpm",
			"Gnumeric_ShowDetail"
		},
		{
			"hide_detail_24.xpm",
			"hide_detail_16.xpm",
			"Gnumeric_HideDetail"
		},

		{
			"graph_guru_24.xpm",
			"graph_guru_16.xpm",
			"Gnumeric_GraphGuru"
		},
		{
			"insert_component_24.xpm",
			"insert_component_16.xpm",
			"Gnumeric_InsertComponent"
		},
		{
			"insert_shaped_component_24.xpm",
			"insert_shaped_component_16.xpm",
			"Gnumeric_InsertShapedComponent"
		},

		{
			"center_across_selection_24.xpm",
			"center_across_selection_16.xpm",
			"Gnumeric_CenterAcrossSelection"
		},
		{
			"merge_cells_24.xpm",
			"merge_cells_16.xpm",
			"Gnumeric_MergeCells"
		},
		{
			"split_cells_24.xpm",
			"split_cells_16.xpm",
			"Gnumeric_SplitCells"
		},

		{
			"halign-fill_24.png",
			NULL,
			"Gnumeric_HAlignFill"
		},
		{
			"halign-general_24.png",
			NULL,
			"Gnumeric_HAlignGeneral"
		},

		{
			NULL,
			"comment_add_16.xpm",
			"Gnumeric_CommentAdd"
		},
		{
			NULL,
			"comment_delete_16.xpm",
			"Gnumeric_CommentDelete"
		},
		{
			NULL,
			"comment_edit_16.xpm",
			"Gnumeric_CommentEdit"
		},

		{
			"add_decimals.png",
			NULL,
			"Gnumeric_FormatAddPrecision"
		},
		{
			"remove_decimals.png",
			NULL,
			"Gnumeric_FormatRemovePrecision"
		},
		{
			"format_money_24.png",
			NULL,
			"Gnumeric_FormatAsAccounting"
		},
		{
			"format_percent_24.png",
			NULL,
			"Gnumeric_FormatAsPercentage"
		},
		{
			"thousands.xpm",
			NULL,
			"Gnumeric_FormatThousandSeparator"
		},
		{
			"gnm_subscript_24.png",
			"gnm_subscript_16.png",
			"Gnumeric_Subscript"
		},
		{
			"gnm_superscript_24.png",
			"gnm_superscript_16.png",
			"Gnumeric_Superscript"
		},

		{
			"auto-sum.xpm",
			NULL,
			"Gnumeric_AutoSum"
		},
		{
			"equal-sign.xpm",
			NULL,
			"Gnumeric_Equal"
		},
		{
			"formula_guru_24.png",
			"formula_guru_16.png",
			"Gnumeric_FormulaGuru"
		},
		{
			"insert_image_24.png",
			"insert_image_16.png",
			"Gnumeric_InsertImage"
		},
		{
			"bucket.xpm",
			NULL,
			"Gnumeric_Bucket"
		},
		{
			"font.xpm",
			NULL,
			"Gnumeric_Font"
		},
		{
			"expr_entry.png",
			NULL,
			"Gnumeric_ExprEntry"
		},
		{
			"brush-22.png",
			"brush-16.png",
			"Gnumeric_Brush"
		},

		{
			"object_arrow_24.png",
			NULL,
			"Gnumeric_ObjectArrow"
		},
		{
			"object_ellipse_24.png",
			NULL,
			"Gnumeric_ObjectEllipse"
		},
		{
			"object_line_24.png",
			NULL,
			"Gnumeric_ObjectLine"
		},

		{
			"object_rectangle_24.png",
			NULL,
			"Gnumeric_ObjectRectangle"
		},

		{
			"object_frame_24.png",
			NULL,
			"Gnumeric_ObjectFrame"
		},
		{
			"object_label_24.png",
			NULL,
			"Gnumeric_ObjectLabel"
		},
		{
			"object_button_24.png",
			NULL,
			"Gnumeric_ObjectButton"
		},
		{
			"object_checkbox_24.png",
			NULL,
			"Gnumeric_ObjectCheckbox"
		},
		{
			"object_radiobutton_24.png",
			NULL,
			"Gnumeric_ObjectRadioButton"
		},
		{
			"object_scrollbar_24.png",
			NULL,
			"Gnumeric_ObjectScrollbar"
		},
		{
			"object_spinbutton_24.png",
			NULL,
			"Gnumeric_ObjectSpinButton"
		},
		{
			"object_slider_24.png",
			NULL,
			"Gnumeric_ObjectSlider"
		},
		{
			"object_combo_24.png",
			NULL,
			"Gnumeric_ObjectCombo"
		},
		{
			"object_list_24.png",
			NULL,
			"Gnumeric_ObjectList"
		},

		{
			"pivottable_24.png",
			"pivottable_16.png",
			"Gnumeric_PivotTable"
		},
		{
			"protection_yes_24.png",
			NULL,
			"Gnumeric_Protection_Yes"
		},
		{
			"protection_no_24.png",
			NULL,
			"Gnumeric_Protection_No"
		},
		{
			"protection_yes_48.png",
			NULL,
			"Gnumeric_Protection_Yes_Dialog"
		},
		{
			"visible.png",
			NULL,
			"Gnumeric_Visible"
		},

		{
			"link_add_24.png",
			"link_add_16.png",
			"Gnumeric_Link_Add"
		},
		{
			NULL,
			"link_delete_16.png",
			"Gnumeric_Link_Delete"
		},
		{
			NULL,
			"link_edit_16.png",
			"Gnumeric_Link_Edit"
		},
		{
			"link_external_24.png",
			"link_external_16.png",
			"Gnumeric_Link_External"
		},
		{
			"link_internal_24.png",
			"link_internal_16.png",
			"Gnumeric_Link_Internal"
		},
		{
			"link_email_24.png",
			"link_email_16.png",
			"Gnumeric_Link_EMail"
		},
		{
			"link_url_24.png",
			"link_url_16.png",
			"Gnumeric_Link_URL"
		},

		{
			"autofilter_24.png",
			"autofilter_16.png",
			"Gnumeric_AutoFilter"
		},
		{
			"autofilter_delete_24.png",
			"autofilter_delete_16.png",
			"Gnumeric_AutoFilterDelete"
		},

		{
			"border_left.xpm",
			NULL,
			"Gnumeric_BorderLeft"
		},
		{
			"border_none.xpm",
			NULL,
			"Gnumeric_BorderNone"
		},
		{
			"border_right.xpm",
			NULL,
			"Gnumeric_BorderRight"
		},
		{
			"border_all.xpm",
			NULL,
			"Gnumeric_BorderAll"
		},
		{
			"border_outside.xpm",
			NULL,
			"Gnumeric_BorderOutside"
		},
		{
			"border_thick_outside.xpm",
			NULL,
			"Gnumeric_BorderThickOutside"
		},
		{
			"border_bottom.xpm",
			NULL,
			"Gnumeric_BorderBottom"
		},
		{
			"border_double_bottom.xpm",
			NULL,
			"Gnumeric_BorderDoubleBottom"
		},
		{
			"border_thick_bottom.xpm",
			NULL,
			"Gnumeric_BorderThickBottom"
		},
		{
			"border_top_n_bottom.xpm",
			NULL,
			"Gnumeric_BorderTop_n_Bottom"
		},
		{
			"border_top_n_double_bottom.xpm",
			NULL,
			"Gnumeric_BorderTop_n_DoubleBottom"
		},
		{
			"border_top_n_thick_bottom.xpm",
			NULL,
			"Gnumeric_BorderTop_n_ThickBottom"
		},

		{
			"hf_page.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Page"
		},
		{
			"hf_pages.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Pages"
		},
		{
			"hf_time.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Time"
		},
		{
			"hf_date.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Date"
		},
		{
			"hf_sheet.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Sheet"
		},
		{
			"hf_cell.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Cell"
		},
	};

	GtkIconFactory *factory = gtk_icon_factory_new ();
	unsigned int ui;

	for (ui = 0; ui < G_N_ELEMENTS (icons); ui++) {
		const char *filename = icons[ui];
		char *res = g_strconcat ("res:gnm:pixmaps/", filename, NULL);
		char *iconname;
		GdkPixbuf *pixbuf = go_gdk_pixbuf_load_from_file (res);
		int size = gdk_pixbuf_get_width (pixbuf);

		iconname = g_strdup (filename);
		strchr(iconname, '.')[0] = 0;
		gtk_icon_theme_add_builtin_icon (iconname,
						 size,
						 pixbuf);

		g_object_unref (pixbuf);
		g_free (iconname);
		g_free (res);
	}

	for (ui = 0; ui < G_N_ELEMENTS (icons2) ; ui++)
		add_icon (factory,
			  icons2[ui].scalable_filename,
			  icons2[ui].sized_filename,
			  icons2[ui].stock_id);
	gtk_icon_factory_add_default (factory);
	g_object_set_data_full (G_OBJECT (app),
				"icon-factory", factory,
				(GDestroyNotify)gtk_icon_factory_remove_default);
	g_object_unref (factory);
}
示例#8
0
void
greeter_session_init (void)
{
    GtkWidget *w = NULL;
    GtkWidget *hbox = NULL;
    GtkWidget *main_vbox = NULL;
    GtkWidget *vbox = NULL;
    GtkWidget *cat_vbox = NULL;
    GtkWidget *radio;
    GtkWidget *dialog;
    GtkWidget *button;
    GList *tmp;
    static GtkTooltips *tooltips = NULL;
    GtkRequisition req;
    char *s;
    int num = 1;
    char *label;

    greeter_set_session (NULL);

    session_dialog = dialog = gtk_dialog_new ();
    if (tooltips == NULL)
        tooltips = gtk_tooltips_new ();

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

    button = gtk_button_new_with_mnemonic (_("Change _Session"));
    GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
    gtk_widget_show (button);
    gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
                                  GTK_RESPONSE_OK);

    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
    gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
    gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
    gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);

    main_vbox = gtk_vbox_new (FALSE, 18);
    gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 5);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                        main_vbox,
                        FALSE, FALSE, 0);

    cat_vbox = gtk_vbox_new (FALSE, 6);
    gtk_box_pack_start (GTK_BOX (main_vbox),
                        cat_vbox,
                        FALSE, FALSE, 0);

    s = g_strdup_printf ("<b>%s</b>", _("Sessions"));
    w = gtk_label_new (s);
    gtk_label_set_use_markup (GTK_LABEL (w), TRUE);
    g_free (s);
    gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (cat_vbox), w, FALSE, FALSE, 0);

    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (cat_vbox),
                        hbox, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox),
                        gtk_label_new ("    "),
                        FALSE, FALSE, 0);
    vbox = gtk_vbox_new (FALSE, 6);
    /* we will pack this later depending on size */

    if (mdm_config_get_bool (MDM_KEY_SHOW_LAST_SESSION))
    {
        greeter_set_session (LAST_SESSION);

        radio = gtk_radio_button_new_with_mnemonic (session_group, _("_Last session"));
        g_object_set_data (G_OBJECT (radio),
                           SESSION_NAME,
                           LAST_SESSION);
        session_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
        gtk_tooltips_set_tip (tooltips, radio,
                              _("Log in using the session that you have used "
                                "last time you logged in"),
                              NULL);
        gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, FALSE, 0);
        gtk_widget_show (radio);
    }

    mdm_session_list_init ();

    for (tmp = sessions; tmp != NULL; tmp = tmp->next)
    {
        MdmSession *session;
        char *file;

        file = (char *) tmp->data;
        session = g_hash_table_lookup (sessnames, file);

        if (num < 10 &&
                (strcmp (file, MDM_SESSION_FAILSAFE_GNOME) != 0) &&
                (strcmp (file, MDM_SESSION_FAILSAFE_XTERM) != 0))
            label = g_strdup_printf ("_%d. %s", num, session->name);
        else
            label = g_strdup (session->name);
        num++;

        radio = gtk_radio_button_new_with_mnemonic (session_group, label);
        g_free (label);
        g_object_set_data_full (G_OBJECT (radio), SESSION_NAME,
                                file, (GDestroyNotify) g_free);
        session_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
        gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, FALSE, 0);
        gtk_widget_show (radio);

        if (! ve_string_empty (session->comment))
            gtk_tooltips_set_tip
            (tooltips, GTK_WIDGET (radio), session->comment, NULL);
    }

    gtk_widget_show_all (vbox);
    gtk_widget_size_request (vbox, &req);

    /* if too large */
    if (req.height > 0.7 * mdm_wm_screen.height) {
        GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
        gtk_widget_set_size_request (sw,
                                     req.width,
                                     0.7 * mdm_wm_screen.height);
        gtk_scrolled_window_set_shadow_type
        (GTK_SCROLLED_WINDOW (sw),
         GTK_SHADOW_NONE);
        gtk_scrolled_window_set_policy
        (GTK_SCROLLED_WINDOW (sw),
         GTK_POLICY_NEVER,
         GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_add_with_viewport
        (GTK_SCROLLED_WINDOW (sw), vbox);
        gtk_widget_show (sw);
        gtk_box_pack_start (GTK_BOX (hbox),
                            sw,
                            TRUE, TRUE, 0);
    } else {
        gtk_box_pack_start (GTK_BOX (hbox),
                            vbox,
                            TRUE, TRUE, 0);
    }
}
示例#9
0
static void
load_snapshot_loaded_cb (GFile *snapshot_file,
                         GAsyncResult *result,
                         GSimpleAsyncResult *simple)
{
	EShell *shell;
	GObject *object;
	LoadContext *context;
	EMsgComposer *composer;
	CamelMimeMessage *message;
	CamelStream *camel_stream;
	gchar *contents = NULL;
	gsize length;
	GError *local_error = NULL;

	context = g_simple_async_result_get_op_res_gpointer (simple);

	g_file_load_contents_finish (
		snapshot_file, result, &contents, &length, NULL, &local_error);

	if (local_error != NULL) {
		g_warn_if_fail (contents == NULL);
		g_simple_async_result_take_error (simple, local_error);
		g_simple_async_result_complete (simple);
		return;
	}

	/* Create an in-memory buffer for the MIME parser to read from.
	 * We have to do this because CamelStreams are syncrhonous-only,
	 * and feeding the parser a direct file stream would block. */
	message = camel_mime_message_new ();
	camel_stream = camel_stream_mem_new_with_buffer (contents, length);
	camel_data_wrapper_construct_from_stream_sync (
		CAMEL_DATA_WRAPPER (message), camel_stream, NULL, &local_error);
	g_object_unref (camel_stream);
	g_free (contents);

	if (local_error != NULL) {
		g_simple_async_result_take_error (simple, local_error);
		g_simple_async_result_complete (simple);
		g_object_unref (message);
		return;
	}

	/* g_async_result_get_source_object() returns a new reference. */
	object = g_async_result_get_source_object (G_ASYNC_RESULT (simple));

	/* Create a new composer window from the loaded message and
	 * restore its snapshot file so it continues auto-saving to
	 * the same file. */
	shell = E_SHELL (object);
	g_object_ref (snapshot_file);
	composer = e_msg_composer_new_with_message (shell, message, TRUE, NULL);
	g_object_set_data_full (
		G_OBJECT (composer),
		SNAPSHOT_FILE_KEY, snapshot_file,
		(GDestroyNotify) delete_snapshot_file);
	context->composer = g_object_ref_sink (composer);
	g_object_unref (message);

	g_object_unref (object);

	g_simple_async_result_complete (simple);
	g_object_unref (simple);
}
示例#10
0
文件: callbacks.c 项目: linuxmint/pix
void
fm__gth_browser_construct_cb (GthBrowser *browser)
{
	BrowserData *data;
	GError      *error = NULL;
	GtkWidget   *file_view;

	g_return_if_fail (GTH_IS_BROWSER (browser));

	data = g_new0 (BrowserData, 1);

	data->action_group = gtk_action_group_new ("File Manager Actions");
	gtk_action_group_set_translation_domain (data->action_group, NULL);
	gtk_action_group_add_actions (data->action_group,
				      action_entries,
				      G_N_ELEMENTS (action_entries),
				      browser);
	gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0);
	set_action_sensitive (data, "Edit_PasteInFolder", FALSE);

	data->fixed_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error);
	if (data->fixed_merge_id == 0) {
		g_warning ("building ui failed: %s", error->message);
		g_error_free (error);
	}

	file_view = gth_file_list_get_view (GTH_FILE_LIST (gth_browser_get_file_list (browser)));
	g_signal_connect (file_view,
                          "drag_data_received",
                          G_CALLBACK (gth_file_list_drag_data_received),
                          browser);
	g_signal_connect (file_view,
	                  "drag_drop",
	                  G_CALLBACK (gth_file_list_drag_drop),
	                  browser);
	g_signal_connect (file_view,
			  "drag_motion",
			  G_CALLBACK (gth_file_list_drag_motion),
			  browser);
	g_signal_connect (file_view,
	                  "drag_leave",
	                  G_CALLBACK (gth_file_list_drag_leave),
	                  browser);
	g_signal_connect (file_view,
	                  "drag_end",
	                  G_CALLBACK (gth_file_list_drag_end),
	                  browser);

	file_view = gth_file_list_get_empty_view (GTH_FILE_LIST (gth_browser_get_file_list (browser)));
	g_signal_connect (file_view,
                          "drag_data_received",
                          G_CALLBACK (gth_file_list_drag_data_received),
                          browser);
	g_signal_connect (file_view,
	                  "drag_drop",
	                  G_CALLBACK (gth_file_list_drag_drop),
	                  browser);
	g_signal_connect (file_view,
			  "drag_motion",
			  G_CALLBACK (gth_file_list_drag_motion),
			  browser);
	g_signal_connect (file_view,
	                  "drag_leave",
	                  G_CALLBACK (gth_file_list_drag_leave),
	                  browser);
	g_signal_connect (file_view,
	                  "drag_end",
	                  G_CALLBACK (gth_file_list_drag_end),
	                  browser);

	g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
}
static void
tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
				EmpathyContact          *contact)
{
	EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
	TpHandle self_handle;
	TpHandle handle;
	GArray handles = {(gchar *) &handle, 1};
	EmpathyCapabilities caps;

	/* Keep a weak ref to that contact */
	g_object_weak_ref (G_OBJECT (contact),
			   tp_contact_factory_weak_notify,
			   tp_factory);
	priv->contacts = g_list_prepend (priv->contacts, contact);

	/* The contact keeps a ref to its factory */
	g_object_set_data_full (G_OBJECT (contact), "empathy-factory",
				g_object_ref (tp_factory),
				g_object_unref);

	caps = empathy_contact_get_capabilities (contact);

	/* Set the FT capability */
	if (!priv->contact_caps_supported) {
		/* ContactCapabilities is not supported; assume all contacts can do file
		 * transfer if it's implemented in the CM */
		if (priv->can_request_ft) {
			caps |= EMPATHY_CAPABILITIES_FT;
		}

		/* Set the Stream Tube capability */
		if (priv->can_request_st) {
			caps |= EMPATHY_CAPABILITIES_STREAM_TUBE;
		}
	}

	empathy_contact_set_capabilities (contact, caps);

	/* Set is-user property. Note that it could still be the handle is
	 * different from the connection's self handle, in the case the handle
	 * comes from a group interface. */
	self_handle = tp_connection_get_self_handle (priv->connection);
	handle = empathy_contact_get_handle (contact);
	empathy_contact_set_is_user (contact, self_handle == handle);

	/* FIXME: This should be done by TpContact */
	if (tp_proxy_has_interface_by_id (priv->connection,
			TP_IFACE_QUARK_CONNECTION_INTERFACE_AVATARS)) {
		tp_cli_connection_interface_avatars_call_get_known_avatar_tokens (
			priv->connection, -1, &handles,
			tp_contact_factory_got_known_avatar_tokens, NULL, NULL,
			G_OBJECT (tp_factory));
	}

	if (priv->contact_caps_supported) {
		tp_cli_connection_interface_contact_capabilities_call_get_contact_capabilities (
			priv->connection, -1, &handles,
			tp_contact_factory_got_contact_capabilities, NULL, NULL,
			G_OBJECT (tp_factory));
	}
	else if (tp_proxy_has_interface_by_id (priv->connection,
			TP_IFACE_QUARK_CONNECTION_INTERFACE_CAPABILITIES)) {
		tp_cli_connection_interface_capabilities_call_get_capabilities (
			priv->connection, -1, &handles,
			tp_contact_factory_got_capabilities, NULL, NULL,
			G_OBJECT (tp_factory));
	}

	DEBUG ("Contact added: %s (%d)",
		empathy_contact_get_id (contact),
		empathy_contact_get_handle (contact));
}
示例#12
0
文件: callbacks.c 项目: linuxmint/pix
static void
_gth_browser_update_open_menu (GthBrowser *browser,
			       const char *path)
{
	GtkWidget    *openwith_item;
	GtkWidget    *menu;
	GList        *items;
	GList        *file_list;
	GList        *scan;
	GList        *appinfo_list;
	GHashTable   *used_mime_types;
	GthIconCache *icon_cache;
	GHashTable   *used_apps;

	openwith_item = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), path);
	menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (openwith_item));
	_gtk_container_remove_children (GTK_CONTAINER (menu), NULL, NULL);

	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
	file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);

	appinfo_list = NULL;
	used_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
	for (scan = file_list; scan; scan = scan->next) {
		GthFileData *file_data = scan->data;
		const char  *mime_type;

		mime_type = gth_file_data_get_mime_type (file_data);
		if ((mime_type == NULL) || g_content_type_is_unknown (mime_type))
			continue;
		if (g_hash_table_lookup (used_mime_types, mime_type) != NULL)
			continue;

		appinfo_list = g_list_concat (appinfo_list, g_app_info_get_all_for_type (mime_type));

		g_hash_table_insert (used_mime_types, (gpointer) mime_type, GINT_TO_POINTER (1));
	}
	g_hash_table_destroy (used_mime_types);

	icon_cache = gth_browser_get_menu_icon_cache (browser);
	used_apps = g_hash_table_new (g_str_hash, g_str_equal);
	for (scan = appinfo_list; scan; scan = scan->next) {
		GAppInfo  *appinfo = scan->data;
		char      *label;
		GtkWidget *menu_item;
		GIcon     *icon;

		if (strcmp (g_app_info_get_executable (appinfo), "pix") == 0)
			continue;
		if (g_hash_table_lookup (used_apps, g_app_info_get_id (appinfo)) != NULL)
			continue;
		g_hash_table_insert (used_apps, (gpointer) g_app_info_get_id (appinfo), GINT_TO_POINTER (1));

		label = g_strdup_printf ("%s", g_app_info_get_name (appinfo));
		menu_item = gtk_image_menu_item_new_with_label (label);

		icon = g_app_info_get_icon (appinfo);
		if (icon != NULL) {
			GdkPixbuf *pixbuf;

			pixbuf = gth_icon_cache_get_pixbuf (icon_cache, icon);
			gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), gtk_image_new_from_pixbuf (pixbuf));
			gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menu_item), TRUE);

			g_object_unref (pixbuf);
		}

		gtk_widget_show (menu_item);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);

		g_object_set_data_full (G_OBJECT (menu_item),
					"appinfo",
					g_object_ref (appinfo),
					g_object_unref);
		g_signal_connect (menu_item,
				  "activate",
				  G_CALLBACK (activate_open_with_application_item),
			  	  browser);

		g_free (label);
	}

	/*
	if (appinfo_list == NULL) {
		GtkWidget *menu_item;

		menu_item = gtk_image_menu_item_new_with_label (_("No application available"));
		gtk_widget_set_sensitive (menu_item, FALSE);
		gtk_widget_show (menu_item);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
	}*/

	gtk_widget_set_sensitive (openwith_item, appinfo_list != NULL);
	gtk_widget_show (openwith_item);

	g_hash_table_destroy (used_apps);
	_g_object_list_unref (appinfo_list);
	_g_object_list_unref (file_list);
	_gtk_tree_path_list_free (items);
}
示例#13
0
void show_import_request_dialog(FRONTEND * fe) {
    /* import dialog -> dialog (OK, cancel), filename entry & browse */
    GtkWidget *dlg;
    GtkEntry *filename_entry;
    GtkButton *browse_button;
    GtkBox *box;
    int status;
    gint result;

    dlg =
        gtk_dialog_new_with_buttons("Import Request",
                                    GTK_WINDOW(fe->mainWindow),
                                    GTK_DIALOG_MODAL |
                                    GTK_DIALOG_DESTROY_WITH_PARENT,
                                    GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                    GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
    box = GTK_BOX(gtk_hbox_new(0, 5));

    gtk_box_pack_start(box, gtk_label_new("Import from"), FALSE, FALSE, 0);
    filename_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(filename_entry), FALSE, FALSE, 0);
    browse_button = GTK_BUTTON(gtk_button_new_with_mnemonic("_Browse..."));
    gtk_box_pack_start(box, GTK_WIDGET(browse_button), FALSE, FALSE, 0);
    g_signal_connect(G_OBJECT(browse_button), "clicked",
                     G_CALLBACK(on_browse_button_clicked), dlg);
    g_object_set_data_full(G_OBJECT(browse_button), "entry", filename_entry, NULL);     /* don't ref the entry -- same lifetime */
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->vbox), GTK_WIDGET(box), FALSE,
                       FALSE, 0);

    gtk_widget_show_all(GTK_WIDGET(GTK_DIALOG(dlg)->vbox));
    result = gtk_dialog_run(GTK_DIALOG(dlg));
    if (result == GTK_RESPONSE_ACCEPT) {
        CRYPT_CERTIFICATE request;
        gchar *filename;

        filename =
            g_filename_from_utf8(gtk_entry_get_text(filename_entry), -1, NULL,
                                 NULL, NULL);
        if (filename != NULL) {
            void *data;
            int data_len;
            data = lmz_file_read_full(filename, &data_len);
            if (data != NULL) {
                status =
                    cryptImportCert(data, data_len, CRYPT_UNUSED, &request);
                if (cryptStatusOK(status)) {
                    int id;
                    status = lmz_ca_add_request(fe->db, request, &id);
                    if (!cryptStatusOK(status)) {
                        show_error_dialog(NULL,
                                          "error adding request to db (cl err %d)",
                                          status);
                    }
                    else {
                        /* yay, it worked */
                        GtkTreeView *mainwin_req_tv, *mainwin_cert_tv;
                        mainwin_req_tv =
                            GTK_TREE_VIEW(g_object_get_data
                                          (G_OBJECT(fe->mainWindow),
                                           "request-list"));
                        mainwin_cert_tv =
                            GTK_TREE_VIEW(g_object_get_data
                                          (G_OBJECT(fe->mainWindow),
                                           "certificate-list"));
                        refresh_request_tree_view(mainwin_req_tv, fe);
                        refresh_cert_tree_view(mainwin_cert_tv, fe);
                    }
                    cryptDestroyCert(request);
                }
                else {
                    show_error_dialog(NULL,
                                      "error importing request (cl err %d)",
                                      status);
                }
                free(data);
            }
            else {
                show_error_dialog(NULL, "error reading file");
            }
            g_free(filename);
        }
        else {
        }
    }
    gtk_widget_destroy(dlg);
}
示例#14
0
/**
 * go_color_palette_make_menu:
 * @no_color_label: color label
 * @default_color: #GOColor
 * @cg: #GOColorGroup
 * @custom_dialog_title: optional string
 * @current_color: #GOColor
 *
 * Returns: (transfer full): a submenu with a palette of colours.  Caller is responsible for
 * 	creating an item to point to the submenu.
 **/
GtkWidget *
go_color_palette_make_menu (char const *no_color_label,
			    GOColor default_color,
			    GOColorGroup *cg,
			    char const *custom_dialog_title,
			    GOColor current_color)
{
	int cols = 8;
	int rows = 6;
	int col, row, pos, table_row = 0;
	GONamedColor const *color_names = default_color_set;
        GtkWidget *w, *submenu;

	submenu = g_object_new (go_menu_color_get_type (), NULL);

	if (no_color_label != NULL) {
		w = make_colored_menu_item (no_color_label, default_color);
		gtk_menu_attach (GTK_MENU (submenu), w, 0, cols, 0, 1);
		g_signal_connect (G_OBJECT (w),
			"activate",
			G_CALLBACK (cb_menu_default_activate), submenu);
		table_row++;
	}
	for (row = 0; row < rows; row++, table_row++) {
		for (col = 0; col < cols; col++) {
			pos = row * cols + col;
			if (color_names [pos].name == NULL)
				goto custom_colors;
			w = make_colored_menu_item (" ",
				color_names [pos].color);
			gtk_widget_set_tooltip_text (w, _(color_names[pos].name));
			gtk_menu_attach (GTK_MENU (submenu), w,
				col, col+1, table_row, table_row+1);
			g_signal_connect (G_OBJECT (w),
				"activate",
				G_CALLBACK (cb_menu_color_activate), submenu);
		}
	}

custom_colors :
	if (col > 0)
		row++;
	for (col = 0; col < cols && col < GO_COLOR_GROUP_HISTORY_SIZE; col++) {
		w = make_colored_menu_item (" ", cg->history[col]);
		gtk_menu_attach (GTK_MENU (submenu), w,
			col, col+1, table_row, table_row+1);
		g_signal_connect (G_OBJECT (w),
			"activate",
			G_CALLBACK (cb_menu_color_activate), submenu);
	}
	w = gtk_image_menu_item_new_with_label (_("Custom color..."));
	/* Workaround for bug http://bugzilla.gnome.org/show_bug.cgi?id=585421 */
	/* We can't have an image in one of the gtk_menu_item, it would lead to an
	   ugly item spacing. */
	/* gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (w),*/
	/* 	gtk_image_new_from_stock (GTK_STOCK_SELECT_COLOR, GTK_ICON_SIZE_MENU));*/
	gtk_widget_show_all (w);
	gtk_menu_attach (GTK_MENU (submenu), w, 0, cols, row + 2, row + 3);
	g_signal_connect (G_OBJECT (w),
		"activate",
		G_CALLBACK (cb_menu_custom_activate), submenu);

	((GOMenuColor *)submenu)->selection = current_color;
	((GOMenuColor *)submenu)->default_color = default_color;
	g_object_set_data_full (G_OBJECT (submenu), "title",
		g_strdup (custom_dialog_title), g_free);

	gtk_widget_show (submenu);

	return submenu;
}
示例#15
0
static GstFlowReturn
recv_sample (GstAppSink * appsink, gpointer user_data)
{
  KmsRecorderEndpoint *self =
      KMS_RECORDER_ENDPOINT (GST_OBJECT_PARENT (appsink));
  GstAppSrc *appsrc = GST_APP_SRC (user_data);
  KmsUriEndpointState state;
  GstFlowReturn ret;
  GstSample *sample;
  GstSegment *segment;
  GstBuffer *buffer;
  BaseTimeType *base_time;
  GstClockTime offset;

  g_signal_emit_by_name (appsink, "pull-sample", &sample);
  if (sample == NULL)
    return GST_FLOW_OK;

  buffer = gst_sample_get_buffer (sample);
  if (buffer == NULL) {
    ret = GST_FLOW_OK;
    goto end;
  }

  segment = gst_sample_get_segment (sample);

  g_object_get (G_OBJECT (self), "state", &state, NULL);
  if (state != KMS_URI_ENDPOINT_STATE_START) {
    GST_WARNING ("Dropping buffer received in invalid state %" GST_PTR_FORMAT,
        buffer);
    // TODO: Add a flag to discard buffers until keyframe
    ret = GST_FLOW_OK;
    goto end;
  }

  gst_buffer_ref (buffer);
  buffer = gst_buffer_make_writable (buffer);

  if (GST_BUFFER_PTS_IS_VALID (buffer))
    buffer->pts =
        gst_segment_to_running_time (segment, GST_FORMAT_TIME, buffer->pts);
  if (GST_BUFFER_DTS_IS_VALID (buffer))
    buffer->dts =
        gst_segment_to_running_time (segment, GST_FORMAT_TIME, buffer->dts);

  BASE_TIME_LOCK (self);

  base_time = g_object_get_data (G_OBJECT (self), BASE_TIME_DATA);

  if (base_time == NULL) {
    base_time = g_slice_new0 (BaseTimeType);
    base_time->pts = buffer->pts;
    base_time->dts = buffer->dts;
    GST_DEBUG_OBJECT (appsrc, "Setting pts base time to: %" G_GUINT64_FORMAT,
        base_time->pts);
    g_object_set_data_full (G_OBJECT (self), BASE_TIME_DATA, base_time,
        release_base_time_type);
  }

  if (!GST_CLOCK_TIME_IS_VALID (base_time->pts)
      && GST_BUFFER_PTS_IS_VALID (buffer)) {
    base_time->pts = buffer->pts;
    GST_DEBUG_OBJECT (appsrc, "Setting pts base time to: %" G_GUINT64_FORMAT,
        base_time->pts);
    base_time->dts = buffer->dts;
  }

  if (GST_CLOCK_TIME_IS_VALID (base_time->pts)) {
    if (GST_BUFFER_PTS_IS_VALID (buffer)) {
      offset = base_time->pts + self->priv->paused_time;
      if (buffer->pts > offset) {
        buffer->pts -= offset;
      } else {
        buffer->pts = 0;
      }
    }
  }

  if (GST_CLOCK_TIME_IS_VALID (base_time->dts)) {
    if (GST_BUFFER_DTS_IS_VALID (buffer)) {
      offset = base_time->dts + self->priv->paused_time;
      if (buffer->dts > offset) {
        buffer->dts -= offset;
      } else {
        buffer->dts = 0;
      }
    }
  }

  BASE_TIME_UNLOCK (GST_OBJECT_PARENT (appsink));

  GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_LIVE);

  if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER))
    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);

  ret = gst_app_src_push_buffer (appsrc, buffer);

  if (ret != GST_FLOW_OK) {
    /* something wrong */
    GST_ERROR ("Could not send buffer to appsrc %s. Cause: %s",
        GST_ELEMENT_NAME (appsrc), gst_flow_get_name (ret));
  }

end:
  if (sample != NULL) {
    gst_sample_unref (sample);
  }

  return ret;
}
示例#16
0
GtkWindow* create_notification(Settings settings) {
    WindowData *windata;

    GtkWidget   *win;

#ifdef USE_COMPOSITE
    GdkColormap *colormap;
    GdkScreen   *screen;
#endif

    // create WindowData object
    windata = g_new0(WindowData, 1);

    // create GTK window
    win = gtk_window_new(GTK_WINDOW_POPUP);
    gtk_window_set_resizable(GTK_WINDOW (win), FALSE);
    gtk_widget_set_app_paintable(win, TRUE);
    windata->win = win;
    windata->settings = settings;

    // connect signals
    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);

    // prepare composite
    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_window_set_default_size(GTK_WINDOW(win), 400, 400);
    gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);

    g_object_set_data_full (G_OBJECT (win),
                            "windata", windata,
                            (GDestroyNotify)destroy_windata);

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

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

//    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);

    // icon box
    windata->iconbox = gtk_alignment_new (0.5f, 0, 0, 0);
    gtk_widget_show (windata->iconbox);
    gtk_alignment_set_padding (GTK_ALIGNMENT (windata->iconbox),
                               0, IMAGE_PADDING, 0, 0);
    gtk_box_pack_start (GTK_BOX (windata->main_vbox),
                        windata->iconbox,
                        FALSE, FALSE, 0);
    gtk_widget_set_size_request (windata->iconbox, BODY_X_OFFSET, -1);

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

    // progress bar box
    windata->progressbarbox = gtk_alignment_new (0.5f, 0, 0, 0);
    gtk_widget_show (windata->progressbarbox);
//    gtk_alignment_set_padding (GTK_ALIGNMENT (windata->iconbox),
//                               5, 0, 0, 0);
    gtk_box_pack_start (GTK_BOX (windata->main_vbox),
                        windata->progressbarbox,
                        FALSE, FALSE, 0);
    gtk_widget_set_size_request (windata->progressbarbox, BODY_X_OFFSET, -1);

    // progress bar
    windata->progressbar = gtk_image_new ();
    gtk_widget_show (windata->progressbar);
    gtk_container_add (GTK_CONTAINER (windata->progressbarbox), windata->progressbar);

    return GTK_WINDOW(win);
}
示例#17
0
/** Create the preferences dialog.  This function first reads the
 *  dialog-preferences.glade file to obtain the content and then
 *  the dialog is created with a set of common preferences.  It then
 *  runs the list of add-ins, calling a helper function to add each full/partial
 *  page to this dialog, Finally it builds the "interesting widgets"
 *  table that is used for connecting the widgets up to callback functions.
 *
 *  @internal
 *
 *  @return A pointer to the newly created dialog.
 */
static GtkWidget *
gnc_preferences_dialog_create(void)
{
    GtkBuilder *builder;
    GtkWidget *dialog, *notebook, *label, *image;
    GtkWidget *box, *date, *period, *currency;
    GHashTable *prefs_table;
    GDate* gdate = NULL;
    gchar buf[128];
    GtkListStore *store;
    GtkTreePath *path;
    GtkTreeIter iter;
    gnc_commodity *locale_currency;
    const gchar *currency_name;
    QofBook *book;
    KvpFrame *book_frame;
    gint64 month, day;
    GDate fy_end;
    gboolean date_is_valid = FALSE;

    ENTER("");
    DEBUG("Opening dialog-preferences.glade:");
    builder = gtk_builder_new();

    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "auto_decimal_places_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "autosave_interval_minutes_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "save_on_close_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "date_backmonth_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "max_transactions_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "key_length_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "new_search_limit_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "retain_days_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "tab_width_adj");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "date_formats");
    gnc_builder_add_from_file (builder, "dialog-preferences.glade", "GnuCash Preferences");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "GnuCash Preferences"));

#ifndef REGISTER2_ENABLED
    /* Hide preferences that are related to register2 */
    box = GTK_WIDGET (gtk_builder_get_object (builder, "label14"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/key-length"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/show-extra-dates"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/show-calendar-buttons"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/selection-to-blank-on-expand"));
    gtk_widget_hide (box);
    box = GTK_WIDGET (gtk_builder_get_object (builder, "pref/general.register/show-extra-dates-on-selection"));
    gtk_widget_hide (box);
#endif

    label = GTK_WIDGET(gtk_builder_get_object (builder, "sample_account"));
    g_object_set_data(G_OBJECT(dialog), "sample_account", label);

    image = GTK_WIDGET(gtk_builder_get_object (builder, "separator_error"));
    g_object_set_data(G_OBJECT(dialog), "separator_error", image);

    DEBUG("autoconnect");
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, dialog);

    DEBUG("done");

    notebook = GTK_WIDGET(gtk_builder_get_object (builder, "notebook1"));
    prefs_table = g_hash_table_new(g_str_hash, g_str_equal);
    g_object_set_data(G_OBJECT(dialog), NOTEBOOK, notebook);
    g_object_set_data_full(G_OBJECT(dialog), PREFS_WIDGET_HASH,
                           prefs_table, (GDestroyNotify)g_hash_table_destroy);


    book = gnc_get_current_book();
    g_date_clear (&fy_end, 1);
    qof_instance_get (QOF_INSTANCE (book),
		      "fy-end", &fy_end,
		      NULL);
    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_PERIOD));
    period = gnc_period_select_new(TRUE);
    gtk_widget_show (period);
    gtk_box_pack_start (GTK_BOX (box), period, TRUE, TRUE, 0);
    if (date_is_valid)
        gnc_period_select_set_fy_end(GNC_PERIOD_SELECT (period), &fy_end);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_END_PERIOD));
    period = gnc_period_select_new(FALSE);
    gtk_widget_show (period);
    gtk_box_pack_start (GTK_BOX (box), period, TRUE, TRUE, 0);
    if (date_is_valid)
        gnc_period_select_set_fy_end(GNC_PERIOD_SELECT (period), &fy_end);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_DATE));
    date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
    gtk_widget_show (date);
    gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_END_DATE));
    date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
    gtk_widget_show (date);
    gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_GENERAL "/" GNC_PREF_CURRENCY_OTHER));
    currency = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(currency), gnc_default_currency());
    gtk_widget_show (currency);
    gtk_box_pack_start(GTK_BOX (box), currency, TRUE, TRUE, 0);

    box = GTK_WIDGET(gtk_builder_get_object (builder,
                     "pref/" GNC_PREFS_GROUP_GENERAL_REPORT "/" GNC_PREF_CURRENCY_OTHER));
    currency = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(currency), gnc_default_currency());
    gtk_widget_show (currency);
    gtk_box_pack_start(GTK_BOX (box), currency, TRUE, TRUE, 0);


    /* Add to the list of interesting widgets */
    gnc_prefs_build_widget_table(builder, dialog);

    g_slist_foreach(add_ins, gnc_preferences_build_page, dialog);

    /* Sort tabs alphabetically */
    gnc_prefs_sort_pages(GTK_NOTEBOOK(notebook));
    gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);

    DEBUG("We have the following interesting widgets:");
    g_hash_table_foreach(prefs_table, (GHFunc)gnc_prefs_connect_one, dialog);
    DEBUG("Done with interesting widgets.");

    /* Other stuff */
    gdate = g_date_new_dmy(31, G_DATE_JULY, 2013);
    g_date_strftime(buf, sizeof(buf), "%x", gdate);
    store = GTK_LIST_STORE(gtk_builder_get_object (builder, "date_formats"));
    path = gtk_tree_path_new_from_indices (QOF_DATE_FORMAT_LOCALE, -1);
    if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
            gtk_list_store_set (store, &iter, 1, buf, -1);
    g_date_free(gdate);

    locale_currency = gnc_locale_default_currency ();
    currency_name = gnc_commodity_get_printname(locale_currency);
    label = GTK_WIDGET(gtk_builder_get_object (builder, "locale_currency"));
    gtk_label_set_label(GTK_LABEL(label), currency_name);
    label = GTK_WIDGET(gtk_builder_get_object (builder, "locale_currency2"));
    gtk_label_set_label(GTK_LABEL(label), currency_name);

    g_object_unref(G_OBJECT(builder));

    LEAVE("dialog %p", dialog);
    return dialog;
}
GtkWidget *
palette_import_dialog_new (GimpContext *context)
{
  ImportDialog *dialog;
  GimpGradient *gradient;
  GtkWidget    *button;
  GtkWidget    *main_hbox;
  GtkWidget    *frame;
  GtkWidget    *vbox;
  GtkWidget    *table;
  GtkWidget    *abox;
  GtkSizeGroup *size_group;
  GSList       *group = NULL;

  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);

  gradient = gimp_context_get_gradient (context);

  dialog = g_slice_new0 (ImportDialog);

  dialog->import_type = GRADIENT_IMPORT;
  dialog->context     = gimp_context_new (context->gimp, "Palette Import",
                                          context);

  dialog->dialog = gimp_dialog_new (_("Import a New Palette"),
                                    "gimp-palette-import", NULL, 0,
                                    gimp_standard_help_func,
                                    GIMP_HELP_PALETTE_IMPORT,

                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,

                                    NULL);

  button = gtk_dialog_add_button (GTK_DIALOG (dialog->dialog),
                                  _("_Import"), GTK_RESPONSE_OK);
  gtk_button_set_image (GTK_BUTTON (button),
                        gtk_image_new_from_icon_name ("gtk-convert",
                                                      GTK_ICON_SIZE_BUTTON));

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  g_object_set_data_full (G_OBJECT (dialog->dialog), "palette-import-dialog",
                          dialog, (GDestroyNotify) palette_import_free);

  g_signal_connect (dialog->dialog, "response",
                    G_CALLBACK (palette_import_response),
                    dialog);

  gimp_dnd_viewable_dest_add (dialog->dialog,
                              GIMP_TYPE_GRADIENT,
                              import_dialog_drop_callback,
                              dialog);
  gimp_dnd_viewable_dest_add (dialog->dialog,
                              GIMP_TYPE_IMAGE,
                              import_dialog_drop_callback,
                              dialog);

  main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))),
                      main_hbox, TRUE, TRUE, 0);
  gtk_widget_show (main_hbox);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);


  /*  The "Source" frame  */

  frame = gimp_frame_new (_("Select Source"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (5, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  dialog->gradient_radio =
    gtk_radio_button_new_with_mnemonic (group, _("_Gradient"));
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->gradient_radio));
  gtk_table_attach (GTK_TABLE (table), dialog->gradient_radio,
                    0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (dialog->gradient_radio);

  g_signal_connect (dialog->gradient_radio, "toggled",
                    G_CALLBACK (palette_import_grad_callback),
                    dialog);

  dialog->image_radio =
    gtk_radio_button_new_with_mnemonic (group, _("I_mage"));
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio));
  gtk_table_attach (GTK_TABLE (table), dialog->image_radio,
                    0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (dialog->image_radio);

  g_signal_connect (dialog->image_radio, "toggled",
                    G_CALLBACK (palette_import_image_callback),
                    dialog);

  gtk_widget_set_sensitive (dialog->image_radio,
                            ! gimp_container_is_empty (context->gimp->images));

  dialog->sample_merged_toggle =
    gtk_check_button_new_with_mnemonic (_("Sample _Merged"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle),
                                TRUE);
  gtk_table_attach (GTK_TABLE (table), dialog->sample_merged_toggle,
                    1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (dialog->sample_merged_toggle);

  g_signal_connect_swapped (dialog->sample_merged_toggle, "toggled",
                            G_CALLBACK (palette_import_make_palette),
                            dialog);

  dialog->selection_only_toggle =
    gtk_check_button_new_with_mnemonic (_("_Selected Pixels only"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->selection_only_toggle),
                                FALSE);
  gtk_table_attach (GTK_TABLE (table), dialog->selection_only_toggle,
                    1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (dialog->selection_only_toggle);

  g_signal_connect_swapped (dialog->selection_only_toggle, "toggled",
                            G_CALLBACK (palette_import_make_palette),
                            dialog);

  dialog->file_radio =
    gtk_radio_button_new_with_mnemonic (group, _("Palette _file"));
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio));
  gtk_table_attach (GTK_TABLE (table), dialog->file_radio,
                    0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (dialog->file_radio);

  g_signal_connect (dialog->file_radio, "toggled",
                    G_CALLBACK (palette_import_file_callback),
                    dialog);

  size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);

  /*  The gradient menu  */
  dialog->gradient_combo =
    gimp_container_combo_box_new (gimp_data_factory_get_container (context->gimp->gradient_factory),
                                  dialog->context, 24, 1);
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
                             NULL, 0.0, 0.5, dialog->gradient_combo, 1, FALSE);
  gtk_size_group_add_widget (size_group, dialog->gradient_combo);

  /*  The image menu  */
  dialog->image_combo =
    gimp_container_combo_box_new (context->gimp->images, dialog->context,
                                  24, 1);
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
                             NULL, 0.0, 0.5, dialog->image_combo, 1, FALSE);
  gtk_size_group_add_widget (size_group, dialog->image_combo);

  /*  Palette file name entry  */
  dialog->file_chooser = gtk_file_chooser_button_new (_("Select Palette File"),
                                                      GTK_FILE_CHOOSER_ACTION_OPEN);
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
                             NULL, 0.0, 0.5, dialog->file_chooser, 1, FALSE);
  gtk_size_group_add_widget (size_group, dialog->file_chooser);

  g_object_unref (size_group);


  /*  The "Import" frame  */

  frame = gimp_frame_new (_("Import Options"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (4, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  /*  The source's name  */
  dialog->entry = gtk_entry_new ();
  gtk_entry_set_text (GTK_ENTRY (dialog->entry),
                      gradient ?
                      gimp_object_get_name (gradient) : _("New import"));
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
                             _("Palette _name:"), 0.0, 0.5,
                             dialog->entry, 2, FALSE);

  /*  The # of colors  */
  dialog->num_colors =
    GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
                                          _("N_umber of colors:"), -1, 5,
                                          256, 2, 10000, 1, 10, 0,
                                          TRUE, 0.0, 0.0,
                                          NULL, NULL));

  g_signal_connect_swapped (dialog->num_colors,
                            "value-changed",
                            G_CALLBACK (palette_import_make_palette),
                            dialog);

  /*  The columns  */
  dialog->columns =
    GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
                                          _("C_olumns:"), -1, 5,
                                          16, 0, 64, 1, 8, 0,
                                          TRUE, 0.0, 0.0,
                                          NULL, NULL));

  g_signal_connect (dialog->columns, "value-changed",
                    G_CALLBACK (palette_import_columns_changed),
                    dialog);

  /*  The interval  */
  dialog->threshold =
    GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
                                          _("I_nterval:"), -1, 5,
                                          1, 1, 128, 1, 8, 0,
                                          TRUE, 0.0, 0.0,
                                          NULL, NULL));

  g_signal_connect_swapped (dialog->threshold, "value-changed",
                            G_CALLBACK (palette_import_make_palette),
                            dialog);


  /*  The "Preview" frame  */
  frame = gimp_frame_new (_("Preview"));
  gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (frame), vbox);
  gtk_widget_show (vbox);

  abox = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
  gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
  gtk_widget_show (abox);

  dialog->preview = gimp_view_new_full_by_types (dialog->context,
                                                 GIMP_TYPE_VIEW,
                                                 GIMP_TYPE_PALETTE,
                                                 192, 192, 1,
                                                 TRUE, FALSE, FALSE);
  gtk_container_add (GTK_CONTAINER (abox), dialog->preview);
  gtk_widget_show (dialog->preview);

  dialog->no_colors_label =
    gtk_label_new (_("The selected source contains no colors."));
  gtk_widget_set_size_request (dialog->no_colors_label, 194, -1);
  gtk_label_set_line_wrap (GTK_LABEL (dialog->no_colors_label), TRUE);
  gimp_label_set_attributes (GTK_LABEL (dialog->no_colors_label),
                             PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
                             -1);
  gtk_box_pack_start (GTK_BOX (vbox), dialog->no_colors_label, FALSE, FALSE, 0);
  gtk_widget_show (dialog->no_colors_label);


  /*  keep the dialog up-to-date  */

  g_signal_connect (context->gimp->images, "add",
                    G_CALLBACK (palette_import_image_add),
                    dialog);
  g_signal_connect (context->gimp->images, "remove",
                    G_CALLBACK (palette_import_image_remove),
                    dialog);

  g_signal_connect (dialog->context, "gradient-changed",
                    G_CALLBACK (palette_import_gradient_changed),
                    dialog);
  g_signal_connect (dialog->context, "image-changed",
                    G_CALLBACK (palette_import_image_changed),
                    dialog);
  g_signal_connect (dialog->file_chooser, "selection-changed",
                    G_CALLBACK (palette_import_filename_changed),
                    dialog);

  palette_import_grad_callback (dialog->gradient_radio, dialog);

  return dialog->dialog;
}
示例#19
0
/**
 * creates a box for selecting a character sets
 *
 * \param assistant	GsbAssistant
 * \param content of file
 * \param charmap_imported
 *
 * \return		A charmap.
 */
gchar *utils_files_create_sel_charset ( GtkWidget *assistant,
                        const gchar *tmp_str,
                        const gchar *charmap_imported,
                        gchar *filename )
{
    GtkWidget *dialog, *vbox, *sw, *tree_view;
    GtkWidget *hbox, *warn, *label;
    GtkTreeViewColumn *column;
    GtkCellRenderer *renderer;
    GtkTreeModel *model;
    GSList *list;
    GtkTreeIter iter;
    gchar* tmpstr;
    GtkWidget *go_charmap_sel;
    gint result;

    dialog = gtk_dialog_new_with_buttons ( _("Select a charmap"),
                            GTK_WINDOW ( assistant ),
                            GTK_DIALOG_MODAL,
                            GTK_STOCK_CANCEL, 0,
                            GTK_STOCK_OK, GTK_RESPONSE_OK,
                            NULL );
    gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
    gtk_widget_set_size_request ( dialog, 600, -1 );
    gtk_dialog_set_response_sensitive   ( GTK_DIALOG ( dialog ), GTK_RESPONSE_OK, FALSE );

    vbox = gtk_vbox_new ( FALSE, 6 );
    gtk_container_set_border_width ( GTK_CONTAINER(vbox), 12 );
    gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) -> vbox ), vbox );

    /* Warning label */
    hbox = gtk_hbox_new ( FALSE, 6 );
    gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );

    warn = gtk_image_new_from_stock ( GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON );
    gtk_box_pack_start ( GTK_BOX ( hbox ), warn, FALSE, FALSE, 0 );

    label = gtk_label_new ( NULL );
    tmpstr = g_strdup_printf ( _("You are here because your file"
                        " can't be imported directly into grisbi.\n%s"),
                        filename );
    gtk_label_set_markup ( GTK_LABEL ( label ),
                        make_pango_attribut ( "weight=\"bold\"",tmpstr ) );
    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
    gtk_box_pack_start ( GTK_BOX ( hbox ), label, TRUE, TRUE, 0 );
    g_free ( tmpstr );

    /*scrolled windows */
    sw = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_set_size_request ( sw, 480, 150 );
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
                        GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX ( vbox ), sw, TRUE, TRUE, 6 );

    /* Tree view and model. */
    model = GTK_TREE_MODEL ( gtk_list_store_new ( IMPORT_CHARMAP_NB, G_TYPE_BOOLEAN,
                        G_TYPE_STRING, G_TYPE_STRING ) );
    tree_view = gtk_tree_view_new_with_model ( model );
    gtk_container_add ( GTK_CONTAINER ( sw ), tree_view );
    g_object_set_data ( G_OBJECT ( model ), "dialog", dialog );
    g_object_set_data ( G_OBJECT ( dialog ), "charset_model", model );
    g_object_set_data ( G_OBJECT ( dialog ), "charset_tree_view", tree_view );

    /* Toggle column. */
    renderer = gtk_cell_renderer_toggle_new ( );
    g_signal_connect ( renderer,
                        "toggled",
                        G_CALLBACK (utils_files_charmap_active_toggled),
                        model );
    column = gtk_tree_view_column_new_with_attributes ( _("Import"), renderer,
                        "active", IMPORT_CHARMAP_SELECTED,
                        NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), column );

    /* Codage column. */
    renderer = gtk_cell_renderer_text_new ( );
    column = gtk_tree_view_column_new_with_attributes ( _("Encoding"), renderer,
                        "text", IMPORT_CHARMAP_ENCODING,
                        NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), column );

    /* Result column. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ( _("Result"), renderer,
                        "text", IMPORT_CHARMAP_RESULT,
                        NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), column );

    /* select an other encoding */
    label = gtk_label_new ( _("If no proposals above are correct you can choose a "
                        "different charset") );
    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
    gtk_box_pack_start ( GTK_BOX ( vbox ), label, TRUE, TRUE, 0 );

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

    go_charmap_sel = go_charmap_sel_new (GO_CHARMAP_SEL_TO_UTF8);
    g_signal_connect ( go_charmap_sel,
                        "charmap_changed",
                        G_CALLBACK (utils_files_go_charmap_sel_changed),
                        dialog );
    g_object_set_data ( G_OBJECT ( dialog ), "charset_cs", go_charmap_sel );
    gtk_box_pack_start ( GTK_BOX ( hbox ), go_charmap_sel, FALSE, FALSE, 0 );

    label = gtk_label_new ( _("Select a charset") );
    gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
    gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
    gtk_box_pack_start ( GTK_BOX ( hbox ), label, TRUE, TRUE, 0 );
    g_object_set_data ( G_OBJECT ( dialog ), "charset_label", label );

    /* on remplit le model */
    list = utils_files_check_UTF8_validity (tmp_str, charmap_imported );
    if ( list )
    {
        GSList *tmp_list;
        struct struc_check_encoding *result;
            
        tmp_list = list;
        result = tmp_list -> data;
        g_object_set_data_full ( G_OBJECT ( dialog ), "charset_str",
                        g_strdup ( result -> result ), g_free );
        tmp_list = tmp_list -> next;
        while ( tmp_list )
        {
            struct struc_check_encoding *result;
            
            result = tmp_list -> data;
            
            gtk_list_store_append ( GTK_LIST_STORE ( model ), &iter );
            gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
                        IMPORT_CHARMAP_ENCODING, result -> charset,
                        IMPORT_CHARMAP_RESULT, result -> result,
                        -1);
            tmp_list = tmp_list -> next;
        }
    }

    gtk_widget_show_all ( dialog );

    result = gtk_dialog_run ( GTK_DIALOG ( dialog ));

    if ( result == GTK_RESPONSE_OK )
    {
        gchar *charset;

        charset = g_strdup ( g_object_get_data ( G_OBJECT ( dialog ), "charset") );
        gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
        return charset;
    }
    else
    {
        gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
        return g_strdup ( "UTF8" );
    }
}
示例#20
0
G_MODULE_EXPORT gint
test_state_main (gint    argc,
                  gchar **argv)
{
  ClutterColor  black={0,0,0,0xff};
  ClutterActor *stage;
  ClutterState *layout_state;
  gint i;
  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  layout_state = clutter_state_new ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &black);
  clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);

  g_signal_connect (stage, "button-press-event",
                    G_CALLBACK (press_event), layout_state);
  g_signal_connect (stage, "button-release-event",
                    G_CALLBACK (release_event), layout_state);

  for (i=0; i<TOTAL; i++)
    {
      ClutterActor *actor;
      ClutterState *a_state;

      int row = i/COLS;
      int col = i%COLS;

      actor = new_rect (255 * ( 1.0*col/COLS), 50,
                        255 * ( 1.0*row/ROWS), 255);
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
      clutter_actor_set_position (actor, 320.0, 240.0);
      clutter_actor_set_reactive (actor, TRUE);


      clutter_state_set (layout_state, NULL, "active",
            actor, "delayed::x", CLUTTER_LINEAR,
                                         ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS), 
                                        ((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
            actor, "delayed::y", CLUTTER_LINEAR,
                                         ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
                                        ((row*1.0/ROWS))/2, 0.0,
            actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
            actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
            NULL);

      clutter_state_set (layout_state, NULL, "right",
            actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
                                    ((row*1.0/ROWS))/2,
                                    (1.0-(row*1.0/ROWS))/2,
            actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
                                    ((row*1.0/ROWS))/2,
                                    0.0,
            NULL);

      clutter_state_set (layout_state, NULL, "left",
            actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
            actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
            actor, "x", CLUTTER_LINEAR, 0-64.0,
            actor, "y", CLUTTER_LINEAR, 0-64.0,
                         NULL);

      a_state = clutter_state_new ();
      g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
                              a_state, g_object_unref);
      g_signal_connect (actor, "enter-event",
                        G_CALLBACK (enter_event), a_state);
      g_signal_connect (actor, "leave-event",
                        G_CALLBACK (leave_event), a_state);

      clutter_state_set (a_state, NULL, "normal",
                         actor, "opacity", CLUTTER_LINEAR, 0x77,
                         actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
                         NULL);
      clutter_state_set (a_state, NULL, "hover",
                         actor, "opacity", CLUTTER_LINEAR, 0xff,
                         actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
                         NULL);
      clutter_actor_set_opacity (actor, 0x77);

      clutter_state_set_duration (a_state, NULL, NULL, 500);
    }

  clutter_state_set_duration (layout_state, NULL, NULL, 1000);
  clutter_state_set_duration (layout_state, "active", "left", 1400);

  g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);

  clutter_actor_show (stage);

  clutter_state_warp_to_state (layout_state, "left");
  clutter_state_set_state (layout_state, "active");

  clutter_main ();
  g_object_unref (layout_state);

  return EXIT_SUCCESS;
}
示例#21
0
文件: view-commands.c 项目: 1ynx/gimp
void
view_padding_color_cmd_callback (GtkAction *action,
                                 gint       value,
                                 gpointer   data)
{
  GimpDisplay        *display;
  GimpImageWindow    *window;
  GimpDisplayShell   *shell;
  GimpDisplayOptions *options;
  gboolean            fullscreen;
  return_if_no_display (display, data);

  shell  = gimp_display_get_shell (display);
  window = gimp_display_shell_get_window (shell);

  if (window)
    fullscreen = gimp_image_window_get_fullscreen (window);
  else
    fullscreen = FALSE;

  if (fullscreen)
    options = shell->fullscreen_options;
  else
    options = shell->options;

  switch ((GimpCanvasPaddingMode) value)
    {
    case GIMP_CANVAS_PADDING_MODE_DEFAULT:
    case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
    case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);

      options->padding_mode_set = TRUE;

      gimp_display_shell_set_padding (shell, (GimpCanvasPaddingMode) value,
                                      &options->padding_color);
      break;

    case GIMP_CANVAS_PADDING_MODE_CUSTOM:
      {
        GtkWidget *color_dialog;

        color_dialog = g_object_get_data (G_OBJECT (shell),
                                          "padding-color-dialog");

        if (! color_dialog)
          {
            GimpImage        *image = gimp_display_get_image (display);
            GimpDisplayShell *shell = gimp_display_get_shell (display);

            color_dialog =
              gimp_color_dialog_new (GIMP_VIEWABLE (image),
                                     action_data_get_context (data),
                                     _("Set Canvas Padding Color"),
                                     GTK_STOCK_SELECT_COLOR,
                                     _("Set Custom Canvas Padding Color"),
                                     GTK_WIDGET (shell),
                                     NULL, NULL,
                                     &options->padding_color,
                                     FALSE, FALSE);

            g_signal_connect (color_dialog, "update",
                              G_CALLBACK (view_padding_color_dialog_update),
                              shell);

            g_object_set_data_full (G_OBJECT (shell), "padding-color-dialog",
                                    color_dialog,
                                    (GDestroyNotify) gtk_widget_destroy);
          }

        gtk_window_present (GTK_WINDOW (color_dialog));
      }
      break;

    case GIMP_CANVAS_PADDING_MODE_RESET:
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);

      {
        GimpDisplayOptions *default_options;

        options->padding_mode_set = FALSE;

        if (fullscreen)
          default_options = display->config->default_fullscreen_view;
        else
          default_options = display->config->default_view;

        gimp_display_shell_set_padding (shell,
                                        default_options->padding_mode,
                                        &default_options->padding_color);
      }
      break;
    }
}
示例#22
0
char *
gui_get_image_save_info (GtkWindow *toplevel, GSList *supported_formats,
			 GOImageFormat *ret_format, double *resolution)
{
	GOImageFormat format;
	GOImageFormatInfo const *format_info;
	GtkComboBox *format_combo = NULL;
	GtkFileChooser *fsel = gui_image_chooser_new (TRUE);
	GtkWidget *expander = NULL;
	GtkWidget *resolution_spin = NULL;
	GtkWidget *resolution_table;
	GladeXML *gui;
	SaveInfoState *state;
	const char *key = "gui_get_image_save_info";
	char *uri = NULL;

	state = g_object_get_data (G_OBJECT (toplevel), key);
	if (state == NULL) {
		state = g_new (SaveInfoState, 1);
		g_return_val_if_fail (state != NULL, NULL);
		state->uri = NULL;
		state->resolution = 150.0;
		state->is_expanded = FALSE;
		state->format = GO_IMAGE_FORMAT_SVG;
		g_object_set_data_full (G_OBJECT (toplevel), key,
					state, (GDestroyNotify) save_info_state_free);
	}

	g_object_set (G_OBJECT (fsel), "title", _("Save as"), NULL);

	gui = go_libglade_new ("go-image-save-dialog-extra.glade", 
			       "image_save_dialog_extra", 
			       GETTEXT_PACKAGE, NULL);
	if (gui != NULL) {
		GtkWidget *widget;

		/* Format selection UI */
		if (supported_formats != NULL && ret_format != NULL) {
			int i;
			GSList *l;
			format_combo = GTK_COMBO_BOX (glade_xml_get_widget (gui, "format_combo"));
			for (l = supported_formats, i = 0; l != NULL; l = l->next, i++) {
				format = GPOINTER_TO_UINT (l->data);
				format_info = go_image_get_format_info (format);
				gtk_combo_box_append_text (format_combo, _(format_info->desc)); 
				if (format == state->format) 
					gtk_combo_box_set_active (format_combo, i);
			}
			if (gtk_combo_box_get_active (format_combo) < 0)
				gtk_combo_box_set_active (format_combo, 0);
		} else {
			widget = glade_xml_get_widget (gui, "file_type_box");
			gtk_widget_hide (widget);
		}

		/* Export setting expander */
		expander = glade_xml_get_widget (gui, "export_expander");
		if (resolution != NULL) {
			gtk_expander_set_expanded (GTK_EXPANDER (expander), state->is_expanded);
			resolution_spin = glade_xml_get_widget (gui, "resolution_spin");
			gtk_spin_button_set_value (GTK_SPIN_BUTTON (resolution_spin), state->resolution);
		} else 
			gtk_widget_hide (expander);

		if (resolution != NULL && supported_formats != NULL && ret_format != NULL) {
			widget = glade_xml_get_widget (gui, "image_save_dialog_extra");
			gtk_file_chooser_set_extra_widget (fsel, widget);

			resolution_table = glade_xml_get_widget (gui, "resolution_table");
		
			cb_format_combo_changed (format_combo, resolution_table);	
			g_signal_connect (GTK_WIDGET (format_combo), "changed", 
					  G_CALLBACK (cb_format_combo_changed), resolution_table);
		}

		g_object_unref (G_OBJECT (gui));
	}

	if (state->uri != NULL) {
		gtk_file_chooser_set_uri (fsel, state->uri);
		gtk_file_chooser_unselect_all (fsel);
	}
	
	/* Show file selector */
 loop:
	if (!go_gtk_file_sel_dialog (toplevel, GTK_WIDGET (fsel)))
		goto out;
	uri = gtk_file_chooser_get_uri (fsel);
	if (format_combo) {
		char *new_uri = NULL;

		format = GPOINTER_TO_UINT (g_slist_nth_data 
			(supported_formats, 
			 gtk_combo_box_get_active (format_combo)));
		format_info = go_image_get_format_info (format);
		if (!go_url_check_extension (uri, format_info->ext, &new_uri) &&
		    !go_gtk_query_yes_no (GTK_WINDOW (fsel), TRUE,
		     _("The given file extension does not match the"
		       " chosen file type. Do you want to use this name"
		       " anyway?"))) {
			g_free (new_uri);
			g_free (uri);
			uri = NULL;
			goto out;
		} else {
			g_free (uri);
			uri = new_uri;
		}
		*ret_format = format;
	}
	if (!go_gtk_url_is_writeable (GTK_WINDOW (fsel), uri, TRUE)) {
		g_free (uri);
		uri = NULL;
		goto loop;
	}
 out:
	if (uri != NULL) {
		g_free (state->uri);
		state->uri = g_strdup (uri);
		state->format = *ret_format;
		if (resolution != NULL) {
			state->is_expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
			*resolution =  gtk_spin_button_get_value (GTK_SPIN_BUTTON (resolution_spin));
			state->resolution = *resolution;
		}
	}

	gtk_widget_destroy (GTK_WIDGET (fsel));

	return uri;
}
示例#23
0
/**
 * terminal_profile_edit:
 * @profile: a #TerminalProfile
 * @transient_parent: a #GtkWindow, or %NULL
 * @widget_name: a widget name in the profile editor's UI, or %NULL
 *
 * Shows the profile editor with @profile, anchored to @transient_parent.
 * If @widget_name is non-%NULL, focuses the corresponding widget and
 * switches the notebook to its containing page.
 */
void
terminal_profile_edit (TerminalProfile *profile,
                       GtkWindow       *transient_parent,
                       const char      *widget_name)
{
	char *path;
	GtkBuilder *builder;
	GError *error = NULL;
	GtkWidget *editor, *w;
	guint i;

	editor = g_object_get_data (G_OBJECT (profile), "editor-window");
	if (editor)
	{
		terminal_profile_editor_focus_widget (editor, widget_name);

		gtk_window_set_transient_for (GTK_WINDOW (editor),
		                              GTK_WINDOW (transient_parent));
		gtk_window_present (GTK_WINDOW (editor));
		return;
	}

	path = g_build_filename (TERM_PKGDATADIR, "profile-preferences.ui", NULL);
	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (builder, path, &error))
	{
		g_warning ("Failed to load %s: %s\n", path, error->message);
		g_error_free (error);
		g_free (path);
		g_object_unref (builder);
		return;
	}
	g_free (path);

	editor = (GtkWidget *) gtk_builder_get_object  (builder, "profile-editor-dialog");
	g_object_set_data_full (G_OBJECT (editor), "builder",
	                        builder, (GDestroyNotify) g_object_unref);

	/* Store the dialogue on the profile, so we can acccess it above to check if
	 * there's already a profile editor for this profile.
	 */
	g_object_set_data (G_OBJECT (profile), "editor-window", editor);

	g_signal_connect (editor, "destroy",
	                  G_CALLBACK (profile_editor_destroyed),
	                  profile);

	g_signal_connect (editor, "response",
	                  G_CALLBACK (editor_response_cb),
	                  NULL);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "color-scheme-combobox");
	init_color_scheme_menu (w);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "darken-background-scale");
	init_background_darkness_scale (w);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "background-image-filechooser");
	setup_background_filechooser (w, profile);

	/* Hook up the palette colorpickers and combo box */

	for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
	{
		char name[32];
		char *text;

		g_snprintf (name, sizeof (name), "palette-colorpicker-%u", i + 1);
		w = (GtkWidget *) gtk_builder_get_object  (builder, name);

		g_object_set_data (G_OBJECT (w), "palette-entry-index", GUINT_TO_POINTER (i));

		text = g_strdup_printf (_("Choose Palette Color %d"), i + 1);
		gtk_color_button_set_title (GTK_COLOR_BUTTON (w), text);
		g_free (text);

		text = g_strdup_printf (_("Palette entry %d"), i + 1);
		gtk_widget_set_tooltip_text (w, text);
		g_free (text);

		g_signal_connect (w, "notify::color",
		                  G_CALLBACK (palette_color_notify_cb),
		                  profile);
	}

	profile_palette_notify_colorpickers_cb (profile, NULL, editor);
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_PALETTE,
	                  G_CALLBACK (profile_palette_notify_colorpickers_cb),
	                  editor);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "palette-combobox");
	g_signal_connect (w, "notify::active",
	                  G_CALLBACK (palette_scheme_combo_changed_cb),
	                  profile);

	profile_palette_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_PALETTE,
	                  G_CALLBACK (profile_palette_notify_scheme_combo_cb),
	                  w);

	/* Hook up the color scheme pickers and combo box */
	w = (GtkWidget *) gtk_builder_get_object  (builder, "color-scheme-combobox");
	g_signal_connect (w, "notify::active",
	                  G_CALLBACK (color_scheme_combo_changed_cb),
	                  profile);

	profile_colors_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_FOREGROUND_COLOR,
	                  G_CALLBACK (profile_colors_notify_scheme_combo_cb),
	                  w);
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_BACKGROUND_COLOR,
	                  G_CALLBACK (profile_colors_notify_scheme_combo_cb),
	                  w);

#define CONNECT_WITH_FLAGS(name, prop, flags) terminal_util_bind_object_property_to_widget (G_OBJECT (profile), prop, (GtkWidget *) gtk_builder_get_object (builder, name), flags)
#define CONNECT(name, prop) CONNECT_WITH_FLAGS (name, prop, 0)
#define SET_ENUM_VALUE(name, value) g_object_set_data (gtk_builder_get_object (builder, name), "enum-value", GINT_TO_POINTER (value))

	w = GTK_WIDGET (gtk_builder_get_object (builder, "custom-command-entry"));
	custom_command_entry_changed_cb (GTK_ENTRY (w));
	g_signal_connect (w, "changed",
	                  G_CALLBACK (custom_command_entry_changed_cb), NULL);
	w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-name-entry"));
	g_signal_connect (w, "changed",
	                  G_CALLBACK (visible_name_entry_changed_cb), editor);

	g_signal_connect (gtk_builder_get_object  (builder, "reset-compat-defaults-button"),
	                  "clicked",
	                  G_CALLBACK (reset_compat_defaults_cb),
	                  profile);

	SET_ENUM_VALUE ("image-radiobutton", TERMINAL_BACKGROUND_IMAGE);
	SET_ENUM_VALUE ("solid-radiobutton", TERMINAL_BACKGROUND_SOLID);
	SET_ENUM_VALUE ("transparent-radiobutton", TERMINAL_BACKGROUND_TRANSPARENT);
	CONNECT ("allow-bold-checkbutton", TERMINAL_PROFILE_ALLOW_BOLD);
	CONNECT ("background-colorpicker", TERMINAL_PROFILE_BACKGROUND_COLOR);
	CONNECT ("background-image-filechooser", TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE);
	CONNECT ("backspace-binding-combobox", TERMINAL_PROFILE_BACKSPACE_BINDING);
	CONNECT ("bold-color-same-as-fg-checkbox", TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG);
	CONNECT ("bold-colorpicker", TERMINAL_PROFILE_BOLD_COLOR);
	CONNECT ("cursor-shape-combobox", TERMINAL_PROFILE_CURSOR_SHAPE);
	CONNECT ("cursor-blink-combobox", TERMINAL_PROFILE_CURSOR_BLINK_MODE);
	CONNECT ("custom-command-entry", TERMINAL_PROFILE_CUSTOM_COMMAND);
	CONNECT ("darken-background-scale", TERMINAL_PROFILE_BACKGROUND_DARKNESS);
	CONNECT ("default-size-columns-spinbutton", TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS);
	CONNECT ("default-size-rows-spinbutton", TERMINAL_PROFILE_DEFAULT_SIZE_ROWS);
	CONNECT ("delete-binding-combobox", TERMINAL_PROFILE_DELETE_BINDING);
	CONNECT ("exit-action-combobox", TERMINAL_PROFILE_EXIT_ACTION);
	CONNECT ("font-selector", TERMINAL_PROFILE_FONT);
	CONNECT ("foreground-colorpicker", TERMINAL_PROFILE_FOREGROUND_COLOR);
	CONNECT ("image-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
	CONNECT ("login-shell-checkbutton", TERMINAL_PROFILE_LOGIN_SHELL);
	CONNECT ("profile-name-entry", TERMINAL_PROFILE_VISIBLE_NAME);
	CONNECT ("scrollback-lines-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES);
	CONNECT ("scrollback-unlimited-checkbutton", TERMINAL_PROFILE_SCROLLBACK_UNLIMITED);
	CONNECT ("scroll-background-checkbutton", TERMINAL_PROFILE_SCROLL_BACKGROUND);
	CONNECT ("scrollbar-position-combobox", TERMINAL_PROFILE_SCROLLBAR_POSITION);
	CONNECT ("scroll-on-keystroke-checkbutton", TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE);
	CONNECT ("scroll-on-output-checkbutton", TERMINAL_PROFILE_SCROLL_ON_OUTPUT);
	CONNECT ("show-menubar-checkbutton", TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR);
	CONNECT ("solid-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
	CONNECT ("system-font-checkbutton", TERMINAL_PROFILE_USE_SYSTEM_FONT);
	CONNECT ("title-entry", TERMINAL_PROFILE_TITLE);
	CONNECT ("title-mode-combobox", TERMINAL_PROFILE_TITLE_MODE);
	CONNECT ("transparent-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
	CONNECT ("update-records-checkbutton", TERMINAL_PROFILE_UPDATE_RECORDS);
	CONNECT ("use-custom-command-checkbutton", TERMINAL_PROFILE_USE_CUSTOM_COMMAND);
	CONNECT ("use-custom-default-size-checkbutton", TERMINAL_PROFILE_USE_CUSTOM_DEFAULT_SIZE);
	CONNECT ("use-theme-colors-checkbutton", TERMINAL_PROFILE_USE_THEME_COLORS);
	CONNECT ("word-chars-entry", TERMINAL_PROFILE_WORD_CHARS);
	CONNECT_WITH_FLAGS ("bell-checkbutton", TERMINAL_PROFILE_SILENT_BELL, FLAG_INVERT_BOOL);

#undef CONNECT
#undef CONNECT_WITH_FLAGS
#undef SET_ENUM_VALUE

	profile_notify_sensitivity_cb (profile, NULL, editor);
	g_signal_connect (profile, "notify",
	                  G_CALLBACK (profile_notify_sensitivity_cb),
	                  editor);
	g_signal_connect (profile,
	                  "forgotten",
	                  G_CALLBACK (profile_forgotten_cb),
	                  editor);

	terminal_profile_editor_focus_widget (editor, widget_name);

	gtk_window_set_transient_for (GTK_WINDOW (editor),
	                              GTK_WINDOW (transient_parent));
	gtk_window_present (GTK_WINDOW (editor));
}
static void
chat_text_view_populate_popup (EmpathyChatTextView *view,
			  GtkMenu        *menu,
			  gpointer        user_data)
{
	EmpathyChatTextViewPriv *priv;
	GtkTextTagTable    *table;
	GtkTextTag         *tag;
	gint                x, y;
	GtkTextIter         iter, start, end;
	GtkWidget          *item;
	gchar              *str = NULL;
	
	priv = GET_PRIV (view);
	
	/* Clear menu item */
	if (gtk_text_buffer_get_char_count (priv->buffer) > 0) {
		item = gtk_menu_item_new ();
		gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
		gtk_widget_show (item);
		
		item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLEAR, NULL);
		gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
		gtk_widget_show (item);
		
		g_signal_connect (item,
				  "activate",
				  G_CALLBACK (chat_text_view_clear_view_cb),
				  view);
	}
	
	/* Link context menu items */
	table = gtk_text_buffer_get_tag_table (priv->buffer);
	tag = gtk_text_tag_table_lookup (table, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK);
	
	gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
	
	gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view),
					       GTK_TEXT_WINDOW_WIDGET,
					       x, y,
					       &x, &y);
	
	gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &iter, x, y);
	
	start = end = iter;
	
	if (gtk_text_iter_backward_to_tag_toggle (&start, tag) &&
	    gtk_text_iter_forward_to_tag_toggle (&end, tag)) {
		    str = gtk_text_buffer_get_text (priv->buffer,
						    &start, &end, FALSE);
	    }
	
	if (EMP_STR_EMPTY (str)) {
		g_free (str);
		return;
	}
	
	/* NOTE: Set data just to get the string freed when not needed. */
	g_object_set_data_full (G_OBJECT (menu),
				"url", str,
				(GDestroyNotify) g_free);
	
	item = gtk_menu_item_new ();
	gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
	gtk_widget_show (item);
	
	item = gtk_menu_item_new_with_mnemonic (_("_Copy Link Address"));
	g_signal_connect (item,
			  "activate",
			  G_CALLBACK (chat_text_view_copy_address_cb),
			  str);
	gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
	gtk_widget_show (item);
	
	item = gtk_menu_item_new_with_mnemonic (_("_Open Link"));
	g_signal_connect (item,
			  "activate",
			  G_CALLBACK (chat_text_view_open_address_cb),
			  str);
	gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
	gtk_widget_show (item);
}
示例#25
0
void
dialog_recent_used (WBCGtk *wbcg)
{
	GtkBuilder *gui;
	GtkDialog *dialog;

	/* Only pop up one copy per workbook */
	if (gnumeric_dialog_raise_if_exists (wbcg, RECENT_KEY))
		return;

	gui = gnm_gtk_builder_load ("recent.ui", NULL, GO_CMD_CONTEXT (wbcg));
        if (gui == NULL)
                return;

	dialog = GTK_DIALOG (go_gtk_builder_get_widget (gui, "recent_dialog"));

	g_signal_connect (G_OBJECT (dialog), "response",
			  G_CALLBACK (cb_response), wbcg);


	{
		GtkWidget *w = GTK_WIDGET (wbcg_toplevel (wbcg));
		int width, height, vsep;
		PangoLayout *layout =
			gtk_widget_create_pango_layout (w, "Mg19");

		gtk_widget_style_get (go_gtk_builder_get_widget (gui, "docs_treeview"),
				      "vertical_separator", &vsep,
				      NULL);

		pango_layout_get_pixel_size (layout, &width, &height);
		gtk_widget_set_size_request (go_gtk_builder_get_widget (gui, "docs_scrolledwindow"),
					     width * 60 / 4,
					     (2 * height + vsep) * (5 + 1));
		g_object_unref (layout);
	}

	g_signal_connect_swapped (gtk_builder_get_object (gui, "existing_only_button"),
				  "toggled", G_CALLBACK (populate_recent_model), gui);
	g_signal_connect_swapped (gtk_builder_get_object (gui, "gnumeric_only_button"),
				  "toggled", G_CALLBACK (populate_recent_model), gui);

	populate_recent_model (gui);

	gtk_tree_view_column_set_cell_data_func
		(GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (gui, "url_column")),
		 GTK_CELL_RENDERER (gtk_builder_get_object (gui, "url_renderer")),
		 url_renderer_func,
		 NULL,
		 NULL);

	gtk_tree_view_column_set_cell_data_func
		(GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (gui, "age_column")),
		 GTK_CELL_RENDERER (gtk_builder_get_object (gui, "age_renderer")),
		 age_renderer_func,
		 g_date_time_new_now_local (),
		 (GDestroyNotify)g_date_time_unref);

	/* ---------------------------------------- */

	g_object_set_data_full (G_OBJECT (dialog), "gui", gui, g_object_unref);
	go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog));
	gtk_widget_show_all (GTK_WIDGET (dialog));
}
GtkWidget * AP_UnixDialog_Paragraph::_constructWindowContents(GtkWidget *windowMain)
{
	// grab the string set
	const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();

	GtkWidget * vboxContents;
	GtkWidget * tabMain;
	GtkWidget * boxSpacing;
	GtkWidget * hboxAlignment;
	GtkComboBox * listAlignment;
	GtkWidget * spinbuttonLeft;
	GtkWidget * spinbuttonRight;
	GtkComboBox * listSpecial;
	GtkWidget * spinbuttonBy;
	GtkWidget * spinbuttonBefore;
	GtkWidget * spinbuttonAfter;
	GtkComboBox * listLineSpacing;
	GtkWidget * spinbuttonAt;
	GtkWidget * labelAlignment;
	GtkWidget * labelBy;
	GtkWidget * hboxIndentation;
	GtkWidget * labelIndentation;
	GtkWidget * labelLeft;
	GtkWidget * labelRight;
	GtkWidget * labelSpecial;
	GtkWidget * hseparator3;
	GtkWidget * hboxSpacing;
	GtkWidget * labelSpacing;
	GtkWidget * labelAfter;
	GtkWidget * labelLineSpacing;
	GtkWidget * labelAt;

	GtkWidget * hseparator1;
	GtkWidget * labelBefore;
	GtkWidget * labelIndents;
	GtkWidget * boxBreaks;
	GtkWidget * hboxPagination;
	GtkWidget * labelPagination;
	GtkWidget * hseparator5;
	GtkWidget * checkbuttonWidowOrphan;
	GtkWidget * checkbuttonKeepLines;
	GtkWidget * checkbuttonPageBreak;
	GtkWidget * checkbuttonSuppress;
	GtkWidget * checkbuttonHyphenate;
	GtkWidget * hseparator6;
	GtkWidget * checkbuttonKeepNext;
	GtkWidget * labelBreaks;
	GtkWidget * checkbuttonDomDirection;

	gchar * unixstr = NULL;

	vboxContents = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_show (vboxContents);

	tabMain = gtk_notebook_new ();
	gtk_widget_show (tabMain);
	gtk_box_pack_start (GTK_BOX (vboxContents), tabMain, FALSE, TRUE, 0);


	// "Indents and Spacing" page
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
	boxSpacing = gtk_table_new (3, 4, FALSE);
#else	
	boxSpacing = gtk_table_new (7, 4, FALSE);
#endif
	gtk_widget_show (boxSpacing);
	gtk_table_set_row_spacings (GTK_TABLE(boxSpacing), 5);
	gtk_table_set_col_spacings (GTK_TABLE(boxSpacing), 5);
	gtk_container_set_border_width (GTK_CONTAINER(boxSpacing), 5);

	UT_UTF8String s;
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_TabLabelIndentsAndSpacing,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelIndents = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelIndents);

	gtk_notebook_append_page (GTK_NOTEBOOK (tabMain), boxSpacing, labelIndents);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelAlignment,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelAlignment = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelAlignment);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelAlignment, 0,1, 0,1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelAlignment), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelAlignment), 1, 0.5);

	hboxAlignment = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_show (hboxAlignment);
	listAlignment = GTK_COMBO_BOX(gtk_combo_box_new ());
	XAP_makeGtkComboBoxText(listAlignment, G_TYPE_INT);
	/**/ g_object_set_data(G_OBJECT(listAlignment), WIDGET_ID_TAG, (gpointer) id_MENU_ALIGNMENT);
	gtk_widget_show (GTK_WIDGET(listAlignment));
	gtk_box_pack_start (GTK_BOX (hboxAlignment), GTK_WIDGET(listAlignment), FALSE, FALSE, 0);
	gtk_table_attach ( GTK_TABLE(boxSpacing), hboxAlignment, 1,2, 0,1,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	XAP_appendComboBoxTextAndInt(listAlignment, " ", 0); // add an empty menu option to fix bug 594
	
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_AlignLeft,s);
	XAP_appendComboBoxTextAndInt(listAlignment, s.utf8_str(), align_LEFT);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_AlignCentered,s);
	XAP_appendComboBoxTextAndInt(listAlignment, s.utf8_str(), align_CENTERED);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_AlignRight,s);
	XAP_appendComboBoxTextAndInt(listAlignment, s.utf8_str(), align_RIGHT);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_AlignJustified,s);
	XAP_appendComboBoxTextAndInt(listAlignment, s.utf8_str(), align_JUSTIFIED);
	gtk_combo_box_set_active(listAlignment, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_DomDirection,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonDomDirection = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonDomDirection), WIDGET_ID_TAG, (gpointer) id_CHECK_DOMDIRECTION);
	gtk_widget_show (checkbuttonDomDirection);
	gtk_table_attach ( GTK_TABLE(boxSpacing), checkbuttonDomDirection, 3,4,0,1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	hboxIndentation = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_show (hboxIndentation);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelIndentation,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelIndentation = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelIndentation);
	gtk_box_pack_start (GTK_BOX (hboxIndentation), labelIndentation, FALSE, FALSE, 0);
	gtk_label_set_justify (GTK_LABEL (labelIndentation), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelIndentation), 0, 0.5);

	hseparator3 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_show (hseparator3);
	gtk_box_pack_start (GTK_BOX (hboxIndentation), hseparator3, TRUE, TRUE, 0);
	gtk_table_attach ( GTK_TABLE(boxSpacing), hboxIndentation, 0,4, 1,2,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelLeft,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelLeft = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelLeft);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelLeft, 0,1, 2,3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelLeft), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelLeft), 1, 0.5);


//	spinbuttonLeft_adj = gtk_adjustment_new (0, 0, 100, 0.1, 10, 10);
//	spinbuttonLeft = gtk_spin_button_new (NULL, 1, 1);
	spinbuttonLeft = gtk_entry_new();
	g_object_ref (spinbuttonLeft);
	g_object_set_data_full (G_OBJECT (windowMain), "spinbuttonLeft", spinbuttonLeft,
							  (GDestroyNotify) g_object_unref);
	/**/ g_object_set_data(G_OBJECT(spinbuttonLeft), WIDGET_ID_TAG, (gpointer) id_SPIN_LEFT_INDENT);
	gtk_widget_show (spinbuttonLeft);
	gtk_table_attach ( GTK_TABLE(boxSpacing), spinbuttonLeft, 1,2, 2,3,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelRight,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelRight = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelRight);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelRight, 0,1, 3,4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelRight), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelRight), 1, 0.5);

//	spinbuttonRight_adj = gtk_adjustment_new (0, 0, 100, 0.1, 10, 10);
//	spinbuttonRight = gtk_spin_button_new (NULL, 1, 1);
	spinbuttonRight = gtk_entry_new();
	/**/ g_object_set_data(G_OBJECT(spinbuttonRight), WIDGET_ID_TAG, (gpointer) id_SPIN_RIGHT_INDENT);
	gtk_widget_show (spinbuttonRight);
	gtk_table_attach ( GTK_TABLE(boxSpacing), spinbuttonRight, 1,2, 3,4,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelSpecial,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelSpecial = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelSpecial);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelSpecial, 2,3, 2,3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
	gtk_label_set_justify (GTK_LABEL (labelSpecial), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelSpecial), 1, 0.5);
#else
	gtk_label_set_justify (GTK_LABEL (labelSpecial), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelSpecial), 0, 0.5);
#endif

	listSpecial = GTK_COMBO_BOX(gtk_combo_box_new ());
	XAP_makeGtkComboBoxText(listSpecial, G_TYPE_INT);
	/**/ g_object_set_data(G_OBJECT(listSpecial), WIDGET_ID_TAG, (gpointer) id_MENU_SPECIAL_INDENT);
	gtk_widget_show (GTK_WIDGET(listSpecial));
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
	gtk_table_attach ( GTK_TABLE(boxSpacing), (GtkWidget*)listSpecial, 3, 4, 2, 3,
                    (GtkAttachOptions) (GTK_SHRINK),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
#else
	gtk_table_attach ( GTK_TABLE(boxSpacing), (GtkWidget*)listSpecial, 2,3, 3,4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

#endif
	XAP_appendComboBoxTextAndInt(listSpecial, " ", 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpecialNone,s);
	XAP_appendComboBoxTextAndInt(listSpecial, s.utf8_str(), indent_NONE);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpecialFirstLine,s);
	XAP_appendComboBoxTextAndInt(listSpecial, s.utf8_str(), indent_FIRSTLINE);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpecialHanging,s);
	XAP_appendComboBoxTextAndInt(listSpecial, s.utf8_str(),  indent_HANGING);
	gtk_combo_box_set_active(listSpecial, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelBy,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelBy = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelBy);
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelBy, 2, 3, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelBy), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelBy), 1, 0.5);
#else
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelBy, 3,4, 2,3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelBy), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelBy), 0, 0.5);
#endif
//	spinbuttonBy_adj = gtk_adjustment_new (0.5, 0, 100, 0.1, 10, 10);
//	spinbuttonBy = gtk_spin_button_new (NULL, 1, 1);
	spinbuttonBy = gtk_entry_new();
	/**/ g_object_set_data(G_OBJECT(spinbuttonBy), WIDGET_ID_TAG, (gpointer) id_SPIN_SPECIAL_INDENT);
	gtk_widget_show (spinbuttonBy);
	gtk_table_attach ( GTK_TABLE(boxSpacing), spinbuttonBy, 3,4, 3,4,
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
                    (GtkAttachOptions) (GTK_SHRINK|GTK_EXPAND),
#else
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
#endif
                    (GtkAttachOptions) (GTK_FILL), 0, 0);


	hboxSpacing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_show (hboxSpacing);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelSpacing,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelSpacing = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_box_pack_start (GTK_BOX (hboxSpacing), labelSpacing, FALSE, FALSE, 0);
	gtk_label_set_justify (GTK_LABEL (labelSpacing), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelSpacing), 0, 0.5);

	hseparator1 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start (GTK_BOX (hboxSpacing), hseparator1, TRUE, TRUE, 0);
	gtk_table_attach ( GTK_TABLE(boxSpacing), hboxSpacing, 0,4, 4,5,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelBefore,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelBefore = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelBefore, 0,1, 5,6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelBefore), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelBefore), 1, 0.5);

//	spinbuttonBefore_adj = gtk_adjustment_new (0, 0, 1500, 0.1, 10, 10);
//	spinbuttonBefore = gtk_spin_button_new (NULL, 1, 1);
	spinbuttonBefore = gtk_entry_new();
	/**/ g_object_set_data(G_OBJECT(spinbuttonBefore), WIDGET_ID_TAG, (gpointer) id_SPIN_BEFORE_SPACING);
	gtk_table_attach ( GTK_TABLE(boxSpacing), spinbuttonBefore, 1,2, 5,6,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelAfter,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelAfter = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelAfter, 0,1, 6,7,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelAfter), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment (GTK_MISC (labelAfter), 1, 0.5);

//	spinbuttonAfter_adj = gtk_adjustment_new (0, 0, 1500, 0.1, 10, 10);
//	spinbuttonAfter = gtk_spin_button_new (NULL, 1, 1);
	spinbuttonAfter = gtk_entry_new();
	/**/ g_object_set_data(G_OBJECT(spinbuttonAfter), WIDGET_ID_TAG, (gpointer) id_SPIN_AFTER_SPACING);
	gtk_table_attach ( GTK_TABLE(boxSpacing), spinbuttonAfter, 1,2, 6,7,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelLineSpacing,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelLineSpacing = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelLineSpacing, 2,3, 5,6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelLineSpacing), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelLineSpacing), 0, 0.5);

	listLineSpacing = GTK_COMBO_BOX(gtk_combo_box_new ());
	XAP_makeGtkComboBoxText(listLineSpacing, G_TYPE_INT);
	/**/ g_object_set_data(G_OBJECT(listLineSpacing), WIDGET_ID_TAG, (gpointer) id_MENU_SPECIAL_SPACING);
	gtk_table_attach ( GTK_TABLE(boxSpacing), GTK_WIDGET(listLineSpacing), 2,3, 6,7,
					   (GtkAttachOptions) (GTK_FILL),
					   (GtkAttachOptions) (GTK_FILL), 0, 0);

	XAP_appendComboBoxTextAndInt(listLineSpacing, " ", 0); // add an empty menu option to fix bug 594
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpacingSingle,s);
	XAP_appendComboBoxTextAndInt(listLineSpacing, s.utf8_str(), spacing_SINGLE);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpacingHalf,s);
	XAP_appendComboBoxTextAndInt(listLineSpacing, s.utf8_str(), spacing_ONEANDHALF);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpacingDouble,s);
	XAP_appendComboBoxTextAndInt(listLineSpacing, s.utf8_str(), spacing_DOUBLE);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpacingAtLeast,s);
	XAP_appendComboBoxTextAndInt(listLineSpacing, s.utf8_str(), spacing_ATLEAST);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpacingExactly,s);
	XAP_appendComboBoxTextAndInt(listLineSpacing, s.utf8_str(), spacing_EXACTLY);
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_SpacingMultiple,s);
	XAP_appendComboBoxTextAndInt(listLineSpacing, s.utf8_str(), spacing_MULTIPLE);
	gtk_combo_box_set_active(listLineSpacing, 0);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelAt,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelAt = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_table_attach ( GTK_TABLE(boxSpacing), labelAt, 3,4, 5,6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
	gtk_label_set_justify (GTK_LABEL (labelAt), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelAt), 0, 0.5);

//	spinbuttonAt_adj = gtk_adjustment_new (0.5, 0, 100, 0.1, 10, 10);
//	spinbuttonAt = gtk_spin_button_new (NULL, 1, 1);
	spinbuttonAt = gtk_entry_new();
	/**/ g_object_set_data(G_OBJECT(spinbuttonAt), WIDGET_ID_TAG, (gpointer) id_SPIN_SPECIAL_SPACING);
	gtk_table_attach ( GTK_TABLE(boxSpacing), spinbuttonAt, 3,4, 6,7,
                    (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

//TODO: In hildon only hide components for future features
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
#else
	gtk_widget_show (labelSpacing);
	gtk_widget_show (hseparator1);
	gtk_widget_show (labelBefore);
	gtk_widget_show (spinbuttonBefore);
	gtk_widget_show (labelAfter);
	gtk_widget_show (spinbuttonAfter);
	gtk_widget_show (labelLineSpacing);
	gtk_widget_show (GTK_WIDGET(listLineSpacing));
	gtk_widget_show (labelAt);	
	gtk_widget_show (spinbuttonAt);
#endif /* HAVE_HILDON */ 	

	// The "Line and Page Breaks" page
	boxBreaks = gtk_table_new (6, 2, FALSE);
	gtk_widget_show (boxBreaks);
	gtk_table_set_row_spacings (GTK_TABLE(boxBreaks), 5);
	gtk_table_set_col_spacings (GTK_TABLE(boxBreaks), 5);
	gtk_container_set_border_width (GTK_CONTAINER(boxBreaks), 5);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_TabLabelLineAndPageBreaks,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelBreaks = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelBreaks);

	gtk_notebook_append_page (GTK_NOTEBOOK (tabMain), boxBreaks, labelBreaks);


	// Pagination headline
	hboxPagination = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_show (hboxPagination);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelPagination,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelPagination = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelPagination);
	gtk_box_pack_start (GTK_BOX (hboxPagination), labelPagination, FALSE, FALSE, 0);

	hseparator5 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_show (hseparator5);
	gtk_box_pack_start (GTK_BOX (hboxPagination), hseparator5, TRUE, TRUE, 0);

	gtk_table_attach ( GTK_TABLE(boxBreaks), hboxPagination, 0,2, 0,1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);


	// Pagination toggles
	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_PushWidowOrphanControl,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonWidowOrphan = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonWidowOrphan), WIDGET_ID_TAG, (gpointer) id_CHECK_WIDOW_ORPHAN);
	gtk_widget_show (checkbuttonWidowOrphan);
	gtk_table_attach ( GTK_TABLE(boxBreaks), checkbuttonWidowOrphan, 0,1, 1,2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_PushKeepWithNext,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonKeepNext = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonKeepNext), WIDGET_ID_TAG, (gpointer) id_CHECK_KEEP_NEXT);
	gtk_widget_show (checkbuttonKeepNext);
	gtk_table_attach ( GTK_TABLE(boxBreaks), checkbuttonKeepNext, 1,2, 1,2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_PushKeepLinesTogether,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonKeepLines = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonKeepLines), WIDGET_ID_TAG, (gpointer) id_CHECK_KEEP_LINES);
	gtk_widget_show (checkbuttonKeepLines);
	gtk_table_attach ( GTK_TABLE(boxBreaks), checkbuttonKeepLines, 0,1, 2,3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_PushPageBreakBefore,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonPageBreak = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonPageBreak), WIDGET_ID_TAG, (gpointer) id_CHECK_PAGE_BREAK);
	gtk_widget_show (checkbuttonPageBreak);
	gtk_table_attach ( GTK_TABLE(boxBreaks), checkbuttonPageBreak, 1,2, 2,3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );


	hseparator6 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_show (hseparator6);
	gtk_table_attach ( GTK_TABLE(boxBreaks), hseparator6, 0,2, 3,4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_PushSuppressLineNumbers,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonSuppress = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonSuppress), WIDGET_ID_TAG, (gpointer) id_CHECK_SUPPRESS);
	gtk_widget_show (checkbuttonSuppress);
	gtk_table_attach ( GTK_TABLE(boxBreaks), checkbuttonSuppress, 0,1, 4,5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_PushNoHyphenate,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	checkbuttonHyphenate = gtk_check_button_new_with_label (unixstr);
	FREEP(unixstr);
	/**/ g_object_set_data(G_OBJECT(checkbuttonHyphenate), WIDGET_ID_TAG, (gpointer) id_CHECK_NO_HYPHENATE);
	gtk_widget_show (checkbuttonHyphenate);
	gtk_table_attach ( GTK_TABLE(boxBreaks), checkbuttonHyphenate, 0,1, 5,6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0 );

	// End of notebook. Next comes the preview area.
#if !defined(EMBEDDED_TARGET) || EMBEDDED_TARGET != EMBEDDED_TARGET_HILDON
	GtkWidget * hboxPreview;
	GtkWidget * labelPreview;
	GtkWidget * hboxPreviewFrame;
	GtkWidget * framePreview;
	GtkWidget * drawingareaPreview;

	GtkWidget * hseparator4;

	hboxPreview = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_show (hboxPreview);

	pSS->getValueUTF8(AP_STRING_ID_DLG_Para_LabelPreview,s);
	UT_XML_cloneNoAmpersands(unixstr, s.utf8_str());
	labelPreview = gtk_label_new (unixstr);
	FREEP(unixstr);
	gtk_widget_show (labelPreview);
	gtk_box_pack_start (GTK_BOX (hboxPreview), labelPreview, FALSE, TRUE, 0);
	gtk_label_set_justify (GTK_LABEL (labelPreview), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (labelPreview), 0, 0.5);

	hseparator4 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_show (hseparator4);
	gtk_box_pack_start (GTK_BOX (hboxPreview), hseparator4, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vboxContents), hboxPreview, TRUE, TRUE, 0);


	hboxPreviewFrame = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_show (hboxPreviewFrame);

	framePreview = gtk_frame_new (NULL);
	gtk_widget_show (framePreview);

	gtk_box_pack_start (GTK_BOX (hboxPreviewFrame), framePreview, TRUE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vboxContents), hboxPreviewFrame, FALSE, TRUE, 0);
	gtk_widget_set_size_request (framePreview, 400, 150);
	gtk_frame_set_shadow_type (GTK_FRAME (framePreview), GTK_SHADOW_NONE);

	drawingareaPreview = createDrawingArea ();
	gtk_widget_show (drawingareaPreview);
	gtk_container_add (GTK_CONTAINER (framePreview), drawingareaPreview);
#endif

	// Update member variables with the important widgets that
	// might need to be queried or altered later.

	m_windowContents = vboxContents;

	m_listAlignment = GTK_WIDGET(listAlignment);

//	m_spinbuttonLeft_adj = spinbuttonLeft_adj;
	m_spinbuttonLeft = spinbuttonLeft;

//	m_spinbuttonRight_adj = spinbuttonRight_adj;
	m_spinbuttonRight = spinbuttonRight;
	m_listSpecial = GTK_WIDGET(listSpecial);
//	m_spinbuttonBy_adj = spinbuttonBy_adj;
	m_spinbuttonBy = spinbuttonBy;
//	m_spinbuttonBefore_adj = spinbuttonBefore_adj;
	m_spinbuttonBefore = spinbuttonBefore;
//	m_spinbuttonAfter_adj = spinbuttonAfter_adj;
	m_spinbuttonAfter = spinbuttonAfter;
	m_listLineSpacing = GTK_WIDGET(listLineSpacing);
//	m_spinbuttonAt_adj = spinbuttonAt_adj;
	m_spinbuttonAt = spinbuttonAt;

#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
	m_drawingareaPreview = NULL;
#else
	m_drawingareaPreview = drawingareaPreview;
#endif 

	m_checkbuttonWidowOrphan = checkbuttonWidowOrphan;
	m_checkbuttonKeepLines = checkbuttonKeepLines;
	m_checkbuttonPageBreak = checkbuttonPageBreak;
	m_checkbuttonSuppress = checkbuttonSuppress;
	m_checkbuttonHyphenate = checkbuttonHyphenate;
	m_checkbuttonKeepNext = checkbuttonKeepNext;
	m_checkbuttonDomDirection = checkbuttonDomDirection;

	return vboxContents;
}
示例#27
0
GtkWindow* create_notification(UrlClickedCb url_clicked)
{
	GtkWidget* win;
	GtkWidget* main_vbox;
	GtkWidget* vbox;
	GtkWidget* close_button;
	GtkWidget* image;
	GtkWidget* alignment;
	AtkObject* atkobj;
	WindowData* windata;
	GdkVisual *visual;
	GdkScreen* screen;

	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-updated", G_CALLBACK(on_style_updated), windata);
	g_signal_connect(G_OBJECT(win), "map-event", G_CALLBACK(on_window_map), windata);
	g_signal_connect(G_OBJECT(win), "draw", G_CALLBACK(on_draw), windata);
	g_signal_connect(G_OBJECT(win), "realize", G_CALLBACK(on_window_realize), windata);

	windata->win = win;

	windata->composited = FALSE;

	screen = gtk_window_get_screen(GTK_WINDOW(win));

	visual = gdk_screen_get_rgba_visual(screen);
	if (visual != NULL)
	{
		gtk_widget_set_visual(win, visual);

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

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

	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);
#if GTK_CHECK_VERSION (3, 0, 0)
	g_signal_connect(G_OBJECT(main_vbox), "style-updated", G_CALLBACK(on_style_updated), windata);
#else
	g_signal_connect(G_OBJECT(main_vbox), "style-set", G_CALLBACK(on_style_set), windata);
#endif
	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_box_new(GTK_ORIENTATION_HORIZONTAL, 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_box_new(GTK_ORIENTATION_VERTICAL, 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();
	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);

	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_icon_name ("window-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);
	gtk_widget_show(windata->summary_label);
	gtk_box_pack_start(GTK_BOX(vbox), windata->summary_label, TRUE, TRUE, 0);
#if GTK_CHECK_VERSION (3, 16, 0)
	gtk_label_set_xalign (GTK_LABEL (windata->summary_label), 0.0);
	gtk_label_set_yalign (GTK_LABEL (windata->summary_label), 0.0);
#else
	gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0.0, 0.0);
#endif
	gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);
	gtk_label_set_line_wrap_mode (GTK_LABEL (windata->summary_label), PANGO_WRAP_WORD_CHAR);

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

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


	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 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_widget_show(windata->body_label);
	gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
#if GTK_CHECK_VERSION (3, 16, 0)
	gtk_label_set_xalign (GTK_LABEL (windata->body_label), 0.0);
	gtk_label_set_yalign (GTK_LABEL (windata->body_label), 0.0);
#else
	gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0.0, 0.0);
#endif
	gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
	gtk_label_set_line_wrap_mode (GTK_LABEL (windata->body_label), PANGO_WRAP_WORD_CHAR);
    gtk_label_set_max_width_chars (GTK_LABEL (windata->body_label), 50);
	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_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_show(windata->actions_box);
	gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);

	return GTK_WINDOW(win);
}
示例#28
0
文件: gtkmet.c 项目: bgnori/gnubg
static GtkWidget *GTKWriteMET(const unsigned int nRows, const unsigned int nCols, const unsigned int nAway0, const unsigned int nAway1)
{
  unsigned int i, j;
  char sz[ 16 ];
  GtkWidget *pwScrolledWindow = gtk_scrolled_window_new( NULL, NULL );
  GtkWidget *pwTable = gtk_table_new( nRows + 1, nCols + 1, TRUE );
  GtkWidget *pw;
  GtkWidget *pwBox = gtk_vbox_new( FALSE, 0 );
  mettable *pmt;

  pmt = (mettable *) g_malloc ( sizeof ( mettable ) );
  pmt->pwTable = pwTable;

  gtk_box_pack_start( GTK_BOX( pwBox ), 
                      pmt->pwName = gtk_label_new( (char*) miCurrent.szName ),
                      FALSE, FALSE, 4 );
  gtk_box_pack_start( GTK_BOX( pwBox ),
                      pmt->pwFileName = gtk_label_new( (char*) miCurrent.szFileName ),
                      FALSE, FALSE, 4 );
  gtk_box_pack_start( GTK_BOX( pwBox ),
                      pmt->pwDescription = gtk_label_new( (char*) miCurrent.szDescription ),
                      FALSE, FALSE, 4 );

  gtk_box_pack_start( GTK_BOX( pwBox ), pwScrolledWindow, TRUE, TRUE, 0 );

  gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(
                                                             pwScrolledWindow ), pwTable );

  /* header for rows */

  for( i = 0; i < nCols; i++ ) {
    sprintf( sz, _("%d-away"), i + 1 );
    gtk_table_attach_defaults( GTK_TABLE( pwTable ),
                               pw = gtk_label_new( sz ),
                               i + 1, i + 2, 0, 1 );
    if ( i == nAway1 ) {
      gtk_widget_set_name ( GTK_WIDGET ( pw ),
                            "gnubg-met-matching-score" );
    }
  }

  /* header for columns */

  for( i = 0; i < nRows; i++ ) {
    sprintf( sz, _("%d-away"), i + 1 );
    gtk_table_attach_defaults( GTK_TABLE( pwTable ),
                               pw = gtk_label_new( sz ),
                               0, 1, i + 1, i + 2 );
    if ( i == nAway0 ) {
      gtk_widget_set_name ( GTK_WIDGET ( pw ),
                            "gnubg-met-matching-score" );
    }

  }


  /* fill out table */
    
  for( i = 0; i < nRows; i++ )
    for( j = 0; j < nCols; j++ ) {

      pmt->aapwLabel[ i ][ j ] = gtk_label_new( NULL );

      gtk_table_attach_defaults( GTK_TABLE( pmt->pwTable ),
                                 pmt->aapwLabel[ i ][ j ],
                                 j + 1, j + 2, i + 1, i + 2 );

      if ( i == nAway0 && j == nAway1 ) {
        gtk_widget_set_name ( GTK_WIDGET ( pmt->aapwLabel[ i ][ j ] ),
                              "gnubg-met-the-score" );
      }
      else if ( i == nAway0 || j == nAway1 ) {
        gtk_widget_set_name ( GTK_WIDGET ( pmt->aapwLabel[ i ][ j ] ),
                              "gnubg-met-matching-score" );
      }
    }

  gtk_table_set_col_spacings( GTK_TABLE( pwTable ), 4 );

  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( pwScrolledWindow ),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC );

  g_object_set_data_full ( G_OBJECT ( pwBox ), "mettable", pmt, g_free );

  return pwBox;

}
static void
impl_activate (PlumaPlugin *plugin,
	       PlumaWindow *window)
{
	PlumaDrawspacesPlugin *ds_plugin;
	GtkUIManager *manager;
	GError *error = NULL;
	GtkAction *action;
	WindowData *data;
	ActionData *action_data;

	pluma_debug (DEBUG_PLUGINS);

	ds_plugin = PLUMA_DRAWSPACES_PLUGIN (plugin);

	data = g_slice_new (WindowData);
	action_data = g_slice_new (ActionData);

	action_data->window = window;
	action_data->plugin = ds_plugin;

	get_config_options (data, ds_plugin);

	manager = pluma_window_get_ui_manager (window);

	data->action_group = gtk_action_group_new ("PlumaDrawspacesPluginActions");
	gtk_action_group_set_translation_domain (data->action_group,
						 GETTEXT_PACKAGE);
	gtk_action_group_add_toggle_actions_full (data->action_group,
						  action_entries,
						  G_N_ELEMENTS (action_entries),
						  action_data,
						  (GDestroyNotify) free_action_data);

	/* Lets set the default value */
	action = gtk_action_group_get_action (data->action_group,
					      "DrawSpaces");
	g_signal_handlers_block_by_func (action, on_active_toggled, action_data);
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
				      data->enable);
	g_signal_handlers_unblock_by_func (action, on_active_toggled, action_data);

	gtk_ui_manager_insert_action_group (manager, data->action_group, -1);

	data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
							 submenu,
							 -1,
							 &error);
	if (error)
	{
		g_warning ("%s", error->message);
		g_error_free (error);
	}

	g_object_set_data_full (G_OBJECT (window),
				WINDOW_DATA_KEY,
				data,
				(GDestroyNotify) free_window_data);

	if (data->enable)
	{
		draw_spaces_in_window (window, ds_plugin);
	}

	g_signal_connect (window, "tab-added",
			  G_CALLBACK (tab_added_cb), ds_plugin);
}
示例#30
0
GtkWidget*
create_volume_window (void)
{
	accel_group = gtk_accel_group_new ();

	volume_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (volume_window, 60, 240);
	gtk_container_set_border_width (GTK_CONTAINER (volume_window), 2);

	gtk_window_set_resizable (GTK_WINDOW (volume_window), FALSE);
	gtk_window_set_position (GTK_WINDOW (volume_window), GTK_WIN_POS_MOUSE);
	gtk_window_set_decorated (GTK_WINDOW (volume_window), FALSE);
	gtk_window_set_skip_taskbar_hint( GTK_WINDOW (volume_window), TRUE );

	frame = gtk_frame_new (_("Volume"));

	vbox1 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox1);
	gtk_container_add (GTK_CONTAINER (frame), vbox1);
	gtk_container_add (GTK_CONTAINER (volume_window), frame);
	gtk_widget_show (frame);
	vol_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (1, 0, 100, 1, 10, 0));

	/* get original adjustments */
	get_current_levels();

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


	/* ajustment, climb rate, digits */
	spinbutton1 = gtk_spin_button_new (GTK_ADJUSTMENT (vol_adjustment), 1, 0);
	gtk_widget_show (spinbutton1);

	gtk_box_pack_start (GTK_BOX (hbox1), spinbutton1, TRUE, FALSE, 0);
	gtk_widget_set_size_request (spinbutton1, -1, 22);
	g_signal_connect ((gpointer) spinbutton1, "value-changed",
			  G_CALLBACK (on_spinbutton1_button_release_event),
			  NULL);
	g_object_set_data_full(G_OBJECT (volume_window), "spinbutton1", 
			       gtk_widget_ref (spinbutton1),
			       (GDestroyNotify) gtk_widget_unref);

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

	vscale1 = gtk_vscale_new (GTK_ADJUSTMENT (vol_adjustment));
	gtk_widget_show (vscale1);
	gtk_range_set_inverted (GTK_RANGE (vscale1), TRUE);
	gtk_box_pack_start (GTK_BOX (hbox3), vscale1, TRUE, TRUE, 0);
	gtk_scale_set_draw_value (GTK_SCALE (vscale1), FALSE);
	g_signal_connect ((gpointer) vscale1, "button-release-event",
			  G_CALLBACK (on_vscale1_button_release_event),
			  vol_adjustment);
	g_object_set_data_full(G_OBJECT (volume_window), "vscale1",
			       gtk_widget_ref (vscale1),
			       (GDestroyNotify) gtk_widget_unref);

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

	g_signal_connect ((gpointer) volume_window, "destroy",
			  G_CALLBACK (gtk_widget_destroy),
			  NULL);

	g_object_set_data (G_OBJECT (volume_window), "volume_window", volume_window);
	g_object_set_data_full (G_OBJECT (volume_window), "frame",
			        gtk_widget_ref (frame), 
				(GDestroyNotify) gtk_widget_unref);
	g_object_set_data_full (G_OBJECT (volume_window), "vbox1",
			        gtk_widget_ref (vbox1), 
				(GDestroyNotify) gtk_widget_unref);
	g_object_set_data_full (G_OBJECT (volume_window), "hbox1",
			        gtk_widget_ref (hbox1), 
				(GDestroyNotify) gtk_widget_unref);
	g_object_set_data_full (G_OBJECT (volume_window), "hbox3",
			        gtk_widget_ref (hbox3), 
				(GDestroyNotify) gtk_widget_unref);
	g_object_set_data_full (G_OBJECT (volume_window), "hbox4",
			        gtk_widget_ref (hbox4), 
				(GDestroyNotify) gtk_widget_unref);

	gtk_window_add_accel_group (GTK_WINDOW (volume_window), accel_group);

	vol_spin = spinbutton1;

	return volume_window;
}