Ejemplo n.º 1
0
static gboolean
sharpen_dialog (GimpDrawable *drawable)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *preview;
  GtkWidget *table;
  GtkObject *adj;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, TRUE);

  dialog = gimp_dialog_new (_("Sharpen"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

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

  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  preview = gimp_drawable_preview_new (drawable, NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
  gtk_widget_show (preview);

  g_signal_connect (preview, "invalidated",
                    G_CALLBACK (preview_update),
                    NULL);

  table = gtk_table_new (1, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
  gtk_widget_show (table);

  adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
                              _("_Sharpness:"), SCALE_WIDTH, 0,
                              sharpen_params.sharpen_percent,
                              1, 99, 1, 10, 0,
                              TRUE, 0, 0,
                              NULL, NULL);
  g_signal_connect (adj, "value-changed",
                    G_CALLBACK (gimp_int_adjustment_update),
                    &sharpen_params.sharpen_percent);
  g_signal_connect_swapped (adj, "value-changed",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
Ejemplo n.º 2
0
static void _context_menu_document(GHtml * ghtml, GtkWidget * menu)
{
	GtkWidget * menuitem;
	GtkWidget * image;

	/* back */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_BACK, NULL);
	if(!ghtml_can_go_back(ghtml->widget))
		gtk_widget_set_sensitive(menuitem, FALSE);
	else
		g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
					surfer_go_back), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* forward */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_FORWARD,
			NULL);
	if(!ghtml_can_go_forward(ghtml->widget))
		gtk_widget_set_sensitive(menuitem, FALSE);
	else
		g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
					surfer_go_forward), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* refresh */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_REFRESH, NULL);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_refresh), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* save page */
	menuitem = gtk_image_menu_item_new_with_mnemonic(
			_("_Save page as..."));
	image = gtk_image_new_from_stock(GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_save_dialog), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* print */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, NULL);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(surfer_print),
			ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* select all */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_SELECT_ALL,
			NULL);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_select_all), ghtml->surfer);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* separator */
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
	/* view source */
	menuitem = gtk_image_menu_item_new_with_mnemonic(_("View so_urce"));
	image = gtk_image_new_from_icon_name("surfer-view-html-source",
			GTK_ICON_SIZE_MENU);
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				surfer_view_source), ghtml->surfer);
	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
#ifdef WITH_INSPECTOR
	/* inspect */
	menuitem = gtk_image_menu_item_new_with_mnemonic(
			_("_Inspect this page"));
	g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
				_on_inspect_page), ghtml);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
#endif
}
Ejemplo n.º 3
0
/* properties window is centered on `parent', parent == NULL => window centered on screen */
GtkWidget *mpd_new_properties_window(GtkWindow *parent) {
	if(debug) {
		fprintf(log_file, "[%s:%3i] %s() called\n", __FILE__, __LINE__, __FUNCTION__);
		fflush(log_file);
	}
	GtkWidget *win;
	GtkWidget *vbox;
	GtkWidget *frame;
	GtkWidget *table;
	GtkWidget *hbox;
	GtkWidget *button;
	GtkWidget *check_btn;
	GList *value_list = NULL;
	value_list = g_list_append(value_list, win);

	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(win), "Properties");
	gtk_window_set_default_size(GTK_WINDOW(win), 300, 200);
	if(parent != NULL) {
		gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT);
		gtk_window_set_transient_for(GTK_WINDOW(win), parent);
	}
	else
		gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ALWAYS);
	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(win), vbox);

	/* mpd settings */
	frame = gtk_frame_new("MPD settings");
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);

	table = gtk_table_new(2, 5, TRUE);
	gtk_container_add(GTK_CONTAINER(frame), table);
	v_pos = 0;

	/* connect on startup */
	check_btn = gtk_check_button_new_with_label("Auto-Connect to MPD:");
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_btn), mpd_info.auto_connect);
	gtk_table_attach(GTK_TABLE(table), check_btn, 0,5, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0,0);
	v_pos++;
	value_list = g_list_append(value_list, check_btn);

	/* mpd host */
	if(mpd_info.msi.host == NULL)
		mpd_info.msi.host = g_string_new("");
	config_entry_new(table, "MPD host:", 1, mpd_info.msi.host->str, value_list);

	/* mpd port */
	char port[6];
	snprintf(port, 6, "%i", mpd_info.msi.port);
	config_entry_new(table, "MPD port:", 1, port, value_list);

	/* mpd password */
	if(mpd_info.msi.pw == NULL)
		mpd_info.msi.pw = g_string_new("");
	config_entry_new(table, "MPD password:"******"%i", mpd_info.xfade_secs);
	config_entry_new(table, "Crossfade timeout:", 1, xfade, value_list);

	/* playlist settings */
	frame = gtk_frame_new("General settings");
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);

	table = gtk_table_new(1,5,FALSE);
	gtk_container_add(GTK_CONTAINER(frame), table);
	v_pos = 0;

	/* update interval */
	gchar update_iv[5];
	snprintf(update_iv, 5, "%i", mpd_info.update_interval);
	config_entry_new(table, "Update interval", 2, update_iv, value_list);

	/* verbosity */
	v_pos ++;
	GtkWidget *label, *combo;
	gint now = (verbose == 1) ? 2 : debug;
	label = gtk_label_new("Verbosity:");
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
	combo = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Level 0 (almost nothing)");
	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Level 1 (some debug information)");
	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Level 2 (quite verbose, not recommended!)");
	gtk_combo_box_set_active(GTK_COMBO_BOX(combo), now);
	value_list = g_list_append(value_list, combo);
	gtk_table_attach(GTK_TABLE(table), combo, 2, 4, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);

	/* status display formats (tooltip, title-/statusbar) */
	frame = gtk_frame_new("Text formats");
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);
	table = gtk_table_new(3, 5, TRUE);
	gtk_container_add(GTK_CONTAINER(frame), table);
	v_pos = 0;

	/* tooltip */
#ifdef APPLET
	if(mpd_info.msf.tooltip_fmt == NULL)
		mpd_info.msf.tooltip_fmt = g_string_new("[\%s] \%a - \%t [\%z/\%Z]");
	config_entry_new(table, "Tooltip string", 2, mpd_info.msf.tooltip_fmt->str, value_list);
	if(mpd_info.msf.applet_fmt == NULL)
		mpd_info.msf.applet_fmt = g_string_new("MPD: \%a");
	config_entry_new(table, "Applet string", 2, mpd_info.msf.applet_fmt->str, value_list);
	check_btn = gtk_check_button_new_with_label("Activate Applet text");
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_btn), musicus_applet.show_text);
	gtk_table_attach(GTK_TABLE(table), check_btn, 0,5, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0,0);
	v_pos++;
	value_list = g_list_append(value_list, check_btn);
#endif

	if(mpd_info.msf.title_fmt == NULL)
		mpd_info.msf.title_fmt = g_string_new("\%a - \%t [\%s]");
	config_entry_new(table, "Titlebar string", 2, mpd_info.msf.title_fmt->str, value_list);

	if(mpd_info.msf.statusbar_fmt == NULL)
		mpd_info.msf.statusbar_fmt = g_string_new("[\%s] \%z/\%Z");
	config_entry_new(table, "Statusbar string", 2, mpd_info.msf.statusbar_fmt->str, value_list);

	/* explanation */
	label = gtk_label_new("\%s = mpd state (playing | paused)");
	gtk_table_attach(GTK_TABLE(table), label, 0, 5, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
	v_pos++;
	label = gtk_label_new("%t = song title \%a = artist name");
	gtk_table_attach(GTK_TABLE(table), label, 0, 5, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
	v_pos++;
	label = gtk_label_new("%z = current time %Z = song duration");
	gtk_table_attach(GTK_TABLE(table), label, 0, 5, v_pos, v_pos+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
	v_pos++;

	/* buttons */
	hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);

	button = gtk_button_new_with_label("Cancel");
	g_signal_connect_swapped(G_OBJECT(button), "clicked",
					 		 G_CALLBACK(delete_widget), win);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_with_label("OK");
	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(save_new_settings), value_list);
	g_signal_connect_swapped(G_OBJECT(button), "clicked",
							 G_CALLBACK(delete_widget), win);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	return win;
}
Ejemplo n.º 4
0
static GtkWidget *
gth_file_tool_resize_get_options (GthFileTool *base)
{
	GthFileToolResize *self = (GthFileToolResize *) base;
	cairo_surface_t   *source;
	GtkWidget         *window;
	GtkWidget         *viewer_page;
	GtkWidget         *viewer;
	GtkAllocation      allocation;
	int                preview_width;
	int                preview_height;
	GtkWidget         *options;
	char              *text;

	source = gth_image_viewer_page_tool_get_source (GTH_IMAGE_VIEWER_PAGE_TOOL (self));
	if (source == NULL)
		return NULL;

	self->priv->original_width = cairo_image_surface_get_width (source);
	self->priv->original_height = cairo_image_surface_get_height (source);

	window = gth_file_tool_get_window (base);
	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
	viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));

	gtk_widget_get_allocation (GTK_WIDGET (viewer), &allocation);
	preview_width = self->priv->original_width;
	preview_height = self->priv->original_height;
	if (scale_keeping_ratio (&preview_width, &preview_height, allocation.width, allocation.height, FALSE))
		self->priv->preview = _cairo_image_surface_scale_fast (source, preview_width, preview_height);
	else
		self->priv->preview = cairo_surface_reference (source);

	_gtk_widget_get_screen_size (window, &self->priv->screen_width, &self->priv->screen_height);
	self->priv->new_image = NULL;
	self->priv->new_width = self->priv->original_width;
	self->priv->new_height = self->priv->original_height;
	self->priv->high_quality = g_settings_get_boolean (self->priv->settings, PREF_RESIZE_HIGH_QUALITY);
	self->priv->unit = g_settings_get_enum (self->priv->settings, PREF_RESIZE_UNIT);
	self->priv->builder = _gtk_builder_new_from_file ("resize-options.ui", "file_tools");
	self->priv->apply_to_original = FALSE;

	update_dimensione_info_label (self,
				      "original_dimensions_label",
				      self->priv->original_width,
				      self->priv->original_height,
				      TRUE);

	options = _gtk_builder_get_widget (self->priv->builder, "options");
	gtk_widget_show (options);

	if (self->priv->unit == GTH_UNIT_PIXELS) {
		gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("resize_width_spinbutton")), 0);
		gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("resize_height_spinbutton")), 0);
		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("resize_width_spinbutton")),
					   g_settings_get_double (self->priv->settings, PREF_RESIZE_WIDTH));
		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("resize_height_spinbutton")),
					   g_settings_get_double (self->priv->settings, PREF_RESIZE_HEIGHT));
	}
	else if (self->priv->unit == GTH_UNIT_PERCENTAGE) {
		gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("resize_width_spinbutton")), 2);
		gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("resize_height_spinbutton")), 2);
		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("resize_width_spinbutton")),
					   g_settings_get_double (self->priv->settings, PREF_RESIZE_WIDTH));
		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("resize_height_spinbutton")),
					   g_settings_get_double (self->priv->settings, PREF_RESIZE_HEIGHT));
	}
	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("unit_combobox")), self->priv->unit);

	self->priv->ratio_combobox = _gtk_combo_box_new_with_texts (_("None"), _("Square"), NULL);
	text = g_strdup_printf (_("%d x %d (Image)"), self->priv->original_width, self->priv->original_height);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("image_size_label")), text);
	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (self->priv->ratio_combobox), text);
	g_free (text);
	text = g_strdup_printf (_("%d x %d (Screen)"), self->priv->screen_width, self->priv->screen_height);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("screen_size_label")), text);
	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (self->priv->ratio_combobox), text);
	g_free (text);
	_gtk_combo_box_append_texts (GTK_COMBO_BOX_TEXT (self->priv->ratio_combobox),
				     _("5:4"),
				     _("4:3 (DVD, Book)"),
				     _("7:5"),
				     _("3:2 (Postcard)"),
				     _("16:10"),
				     _("16:9 (DVD)"),
				     _("1.85:1"),
				     _("2.39:1"),
				     _("Custom"),
				     NULL);
	gtk_widget_show (self->priv->ratio_combobox);
	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("ratio_combobox_box")), self->priv->ratio_combobox, TRUE, TRUE, 0);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("high_quality_checkbutton")),
				      self->priv->high_quality);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("invert_ratio_checkbutton")),
				      g_settings_get_boolean (self->priv->settings, PREF_RESIZE_ASPECT_RATIO_INVERT));

	gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("ratio_w_spinbutton")),
				   MAX (g_settings_get_int (self->priv->settings, PREF_RESIZE_ASPECT_RATIO_WIDTH), 1));
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("ratio_h_spinbutton")),
				   MAX (g_settings_get_int (self->priv->settings, PREF_RESIZE_ASPECT_RATIO_HEIGHT), 1));

	g_signal_connect_swapped (GET_WIDGET ("options_close_button"),
				  "clicked",
				  G_CALLBACK (gtk_widget_hide),
				  GET_WIDGET ("options_dialog"));
	g_signal_connect (GET_WIDGET ("options_dialog"),
			  "delete-event",
			  G_CALLBACK (gtk_widget_hide_on_delete),
			  NULL);
	g_signal_connect (GET_WIDGET ("resize_width_spinbutton"),
			  "value-changed",
			  G_CALLBACK (selection_width_value_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("resize_height_spinbutton"),
			  "value-changed",
			  G_CALLBACK (selection_height_value_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("high_quality_checkbutton"),
			  "toggled",
			  G_CALLBACK (high_quality_checkbutton_toggled_cb),
			  self);
	g_signal_connect (GET_WIDGET ("unit_combobox"),
			  "changed",
			  G_CALLBACK (unit_combobox_changed_cb),
			  self);
	g_signal_connect (self->priv->ratio_combobox,
			  "changed",
			  G_CALLBACK (ratio_combobox_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("ratio_w_spinbutton"),
			  "value_changed",
			  G_CALLBACK (ratio_value_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("ratio_h_spinbutton"),
			  "value_changed",
			  G_CALLBACK (ratio_value_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("invert_ratio_checkbutton"),
			  "toggled",
			  G_CALLBACK (invert_ratio_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("image_size_button"),
			  "clicked",
			  G_CALLBACK (image_size_button_clicked_cb),
			  self);
	g_signal_connect (GET_WIDGET ("screen_size_button"),
			  "clicked",
			  G_CALLBACK (screen_size_button_clicked_cb),
			  self);

	gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->ratio_combobox),
				  g_settings_get_enum (self->priv->settings, PREF_RESIZE_ASPECT_RATIO));

	gth_image_viewer_set_zoom_quality (GTH_IMAGE_VIEWER (viewer), GTH_ZOOM_QUALITY_HIGH);

	return options;
}
Ejemplo n.º 5
0
Compose * compose_new(Config * config)
{
	Compose * compose;
	GtkAccelGroup * group;
	GtkWidget * vbox;
	GtkWidget * toolbar;
	GtkToolItem * toolitem;
	GtkSizeGroup * sizegroup;
	GtkWidget * vpaned;
	GtkWidget * vbox2;
	GtkWidget * widget;
	GtkCellRenderer * renderer;
	GtkTreeViewColumn * column;
	GtkTreeIter iter;
	char const * headers[] = {
		"To:", "Cc:", "Bcc:", "Reply-To:", "Newsgroup:",
		"Followup-To:" };
	size_t i;
	gint size;

	if((compose = malloc(sizeof(*compose))) == NULL)
	{
		compose_error(NULL, strerror(errno), 0);
		return NULL;
	}
	compose->mime = mime_new(NULL);
	/* check errors */
	if(compose->mime == NULL)
	{
		free(compose);
		return NULL;
	}
	compose->config = config;
	compose->standalone = FALSE;
	/* window */
	group = gtk_accel_group_new();
	compose->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_add_accel_group(GTK_WINDOW(compose->window), group);
	g_object_unref(group);
#ifndef EMBEDDED
	gtk_window_set_default_size(GTK_WINDOW(compose->window), 512, 384);
#else
	gtk_window_set_default_size(GTK_WINDOW(compose->window), 200, 300);
#endif
	gtk_window_set_title(GTK_WINDOW(compose->window), _("Compose"));
#if GTK_CHECK_VERSION(2, 6, 0)
	gtk_window_set_icon_name(GTK_WINDOW(compose->window), "mailer");
#endif
	g_signal_connect_swapped(G_OBJECT(compose->window), "delete-event",
			G_CALLBACK(_compose_on_closex), compose);
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
	vbox = gtk_vbox_new(FALSE, 0);
#endif
	/* menubar */
#ifndef EMBEDDED
	widget = desktop_menubar_create(_compose_menubar, compose, group);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
#endif
	/* toolbar */
	toolbar = desktop_toolbar_create(_compose_toolbar, compose, group);
	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, TRUE, 0);
	/* from */
	sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	toolbar = gtk_toolbar_new();
	widget = gtk_label_new(_("From: "));
#if GTK_CHECK_VERSION(3, 14, 0)
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(widget), 0.1, 0.5);
#endif
	gtk_widget_set_size_request(widget, 80, -1);
	gtk_size_group_add_widget(sizegroup, widget);
	toolitem = gtk_tool_item_new();
	gtk_container_add(GTK_CONTAINER(toolitem), widget);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
#if GTK_CHECK_VERSION(2, 24, 0)
	compose->from = gtk_combo_box_text_new_with_entry();
#else
	compose->from = gtk_combo_box_entry_new_text();
#endif
	toolitem = gtk_tool_item_new();
	gtk_tool_item_set_expand(toolitem, TRUE);
	gtk_container_add(GTK_CONTAINER(toolitem), compose->from);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
	/* paned */
#if GTK_CHECK_VERSION(3, 0, 0)
	vpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
#else
	vpaned = gtk_vpaned_new();
#endif
	if(gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &size, &size) != TRUE)
		size = 24;
	gtk_paned_set_position(GTK_PANED(vpaned), size * 2);
	/* headers */
	widget = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	compose->h_store = gtk_list_store_new(CHC_COUNT, G_TYPE_STRING,
			G_TYPE_STRING, G_TYPE_BOOLEAN);
	compose->h_store_filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(
				compose->h_store), NULL);
	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(
				compose->h_store_filter),
			_compose_on_headers_filter, compose, NULL);
	compose->h_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
				compose->h_store_filter));
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(compose->h_view),
			FALSE);
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(compose->h_view), TRUE);
	compose->h_headers = gtk_list_store_new(2, G_TYPE_STRING,
			G_TYPE_STRING);
	for(i = 0; i < sizeof(headers) / sizeof(*headers); i++)
	{
		gtk_list_store_append(compose->h_headers, &iter);
		gtk_list_store_set(compose->h_headers, &iter, 0, headers[i], 1,
				headers[i], -1);
	}
	renderer = gtk_cell_renderer_combo_new();
	g_object_set(renderer, "editable", TRUE, "model", compose->h_headers,
			"text-column", 1, NULL);
	g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(
				_on_header_field_edited), compose);
	column = gtk_tree_view_column_new_with_attributes("", renderer, "text",
			CHC_HEADER, NULL);
	gtk_tree_view_column_set_min_width(column, 80);
	gtk_tree_view_append_column(GTK_TREE_VIEW(compose->h_view), column);
	renderer = gtk_cell_renderer_text_new();
	g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
	g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(
				_on_header_edited), compose);
	column = gtk_tree_view_column_new_with_attributes("", renderer, "text",
			CHC_VALUE, NULL);
#if GTK_CHECK_VERSION(2, 4, 0)
	gtk_tree_view_column_set_expand(column, TRUE);
#endif
	gtk_tree_view_append_column(GTK_TREE_VIEW(compose->h_view), column);
	/* default to 8-bits transfers with UTF-8 encoding */
	compose_set_header(compose, "Content-Transfer-Encoding:", "8bit",
			FALSE);
	compose_set_header(compose, "Content-Type:",
			"text/plain; charset=UTF-8", FALSE);
	compose_add_field(compose, "To:", NULL);
	gtk_container_add(GTK_CONTAINER(widget), compose->h_view);
	gtk_paned_add1(GTK_PANED(vpaned), widget);
	/* paned */
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
	vbox2 = gtk_vbox_new(FALSE, 0);
#endif
	/* subject */
	toolbar = gtk_toolbar_new();
	widget = gtk_label_new(_("Subject: "));
#if GTK_CHECK_VERSION(3, 14, 0)
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(widget), 0.1, 0.5);
#endif
	gtk_size_group_add_widget(sizegroup, widget);
	toolitem = gtk_tool_item_new();
	gtk_container_add(GTK_CONTAINER(toolitem), widget);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
	compose->subject = gtk_entry_new();
	toolitem = gtk_tool_item_new();
	gtk_tool_item_set_expand(toolitem, TRUE);
	gtk_container_add(GTK_CONTAINER(toolitem), compose->subject);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
	gtk_box_pack_start(GTK_BOX(vbox2), toolbar, FALSE, TRUE, 0);
	/* view */
	widget = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	compose->view = _new_text_view(compose);
	compose_set_font(compose, _compose_get_font(compose));
	gtk_container_add(GTK_CONTAINER(widget), compose->view);
	gtk_box_pack_start(GTK_BOX(vbox2), widget, TRUE, TRUE, 0);
	gtk_paned_add2(GTK_PANED(vpaned), vbox2);
	gtk_box_pack_start(GTK_BOX(vbox), vpaned, TRUE, TRUE, 0);
	/* attachments */
	compose->a_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(compose->a_window),
			GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
	compose->a_store = gtk_list_store_new(CAC_COUNT, G_TYPE_STRING,
			G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
	compose->a_view = gtk_icon_view_new_with_model(GTK_TREE_MODEL(
				compose->a_store));
	gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(compose->a_view),
			CAC_ICON);
	gtk_icon_view_set_selection_mode(GTK_ICON_VIEW(compose->a_view),
			GTK_SELECTION_MULTIPLE);
	gtk_icon_view_set_text_column(GTK_ICON_VIEW(compose->a_view),
			CAC_BASENAME);
	gtk_container_add(GTK_CONTAINER(compose->a_window), compose->a_view);
	gtk_widget_show_all(compose->a_view);
	gtk_widget_set_no_show_all(compose->a_window, TRUE);
	gtk_box_pack_start(GTK_BOX(vbox), compose->a_window, FALSE, TRUE, 0);
	/* statusbar */
	compose->statusbar = gtk_statusbar_new();
	compose->statusbar_id = 0;
	gtk_box_pack_start(GTK_BOX(vbox), compose->statusbar, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(compose->window), vbox);
	/* about dialog */
	compose->ab_window = NULL;
	/* signature */
	compose_append_signature(compose);
	compose_set_modified(compose, FALSE);
	compose_scroll_to_offset(compose, 0);
	/* display */
	gtk_widget_grab_focus(compose->view);
	gtk_widget_show_all(vbox);
	gtk_widget_show(compose->window);
	return compose;
}
Ejemplo n.º 6
0
Widget BolfView(){

	GtkTooltips *Tooltips;
	Tooltips=gtk_tooltips_new();

	Widget Window, InputText, SearchButton, SelectType, Table, SelectText, Slider, News;
	Widget NijiaM, KamerM, HipHop, AfricaM;
	Widget MusicLabel, GameLabel, FunLabel, MovieLabel, SportLabel;

	GtkWidget *pageLayoutExpander, *scrolledWindow;
	pageLayoutExpander = gtk_expander_new_with_mnemonic("Page");

	MusicLabel= gtk_label_new("Music");
	GameLabel= gtk_label_new("Games");
	FunLabel= gtk_label_new("Funny");
	MovieLabel= gtk_label_new("Movies");
	SportLabel= gtk_label_new("Sports");


	//	Warning = gtk_label_new("Click On Me  \n If You wanna Quit \n Or Cancel if you dont");
	//declaring the url entry;
	UrlText=gtk_entry_new();
	gtk_entry_set_visibility(GTK_ENTRY(UrlText),TRUE);
	gtk_widget_set_size_request(UrlText,600,25);
	gtk_entry_set_text (GTK_ENTRY(UrlText),"http://DONOT WRITE HERE!!!!!!");
	gtk_tooltips_set_tip(Tooltips,UrlText,"This is to displace th current URL",NULL);

	
	//declaring the search text
	InputText=gtk_entry_new();
	gtk_entry_set_visibility(GTK_ENTRY(InputText),TRUE);
	gtk_widget_set_size_request(InputText,20,40);
	gtk_tooltips_set_tip(Tooltips,InputText,"Enter Your Search Here!!!!",NULL);
	
	/* create Webview */
	
	web[count] = webkit_web_view_new();


	//declaring the search button;
	SearchButton=gtk_button_new();
	SearchButton=ImageButton("pictures/search.jpeg");
	gtk_widget_set_size_request(SearchButton,130,80);
	gtk_tooltips_set_tip(Tooltips,SearchButton,"Search Button",NULL);
	g_signal_connect(SearchButton, "clicked",  G_CALLBACK(InputConnect), InputText);
	

	//creating a slider	
	Slider=MyEvent("pictures/ani1.gif");
	//gtk_widget_set_size_request(Slider,1000,3000);
	gtk_tooltips_set_tip(Tooltips,Slider,"News",NULL);
	g_signal_connect_swapped(Slider, "button_press_event", G_CALLBACK(Newso),NULL);

	//creating news
	News=MyEvent("pictures/ani2.gif");
	//gtk_widget_set_size_request(News,400,150);
	gtk_tooltips_set_tip(Tooltips,News,"News",NULL);
	g_signal_connect_swapped(News, "button_press_event", G_CALLBACK(Newso),NULL);

	//Music	
	NijiaM=MyEvent("pictures/concour.jpeg");
	gtk_widget_set_size_request(NijiaM,175,80);
	gtk_tooltips_set_tip(Tooltips,NijiaM,"Nijia Music",NULL);
	g_signal_connect_swapped(NijiaM, "button_press_event", G_CALLBACK(NijiaMusic),NULL);
	
	HipHop=MyEvent("pictures/hiphop.jpeg");
	gtk_widget_set_size_request(HipHop,175,80);
	gtk_tooltips_set_tip(Tooltips,HipHop,"Hip, HOp, R&B",NULL);
	g_signal_connect_swapped(HipHop, "button_press_event", G_CALLBACK(HipHopMusic),NULL);

	KamerM=MyEvent("pictures/camerhits.jpeg");
	gtk_widget_set_size_request(KamerM,175,80);
	gtk_tooltips_set_tip(Tooltips,KamerM,"Kamer Hits",NULL);
	g_signal_connect_swapped(KamerM, "button_press_event", G_CALLBACK(KamerHits),NULL);

	AfricaM=MyEvent("pictures/cam.jpeg");
	gtk_widget_set_size_request(AfricaM,175,80);
	gtk_tooltips_set_tip(Tooltips,AfricaM,"Africa Music",NULL);
	g_signal_connect_swapped(AfricaM,"button_press_event",G_CALLBACK(AfricaMusic),NULL);

	//Movies	
	Widget Nolly, Holly,Bolly, Horos;

	Nolly=MyEvent("pictures/nollywood.jpeg");
	gtk_widget_set_size_request(Nolly,175,80);
	gtk_tooltips_set_tip(Tooltips,Nolly,"NollyWood(Nigeria Film Industry)",NULL);
	g_signal_connect_swapped(Nolly, "button_press_event", G_CALLBACK(Nollywood),NULL);
	
	Holly=MyEvent("pictures/hollywood.jpeg");
	gtk_widget_set_size_request(Holly,175,80);
	gtk_tooltips_set_tip(Tooltips,Holly,"Hollywood(America Film Industry)",NULL);
	g_signal_connect_swapped(Holly, "button_press_event", G_CALLBACK(Hollywood),NULL);

	Bolly=MyEvent("pictures/bollywood.jpeg");
	gtk_widget_set_size_request(Bolly,175,80);
	gtk_tooltips_set_tip(Tooltips,Bolly,"Bollywood(The Indians)",NULL);
	g_signal_connect_swapped(Bolly, "button_press_event", G_CALLBACK(Bollywood),NULL);

	Horos=MyEvent("pictures/horos.jpeg");
	gtk_widget_set_size_request(Horos,175,80);
	gtk_tooltips_set_tip(Tooltips,Horos,"Horos Movies",NULL);
	g_signal_connect_swapped(Horos,"button_press_event",G_CALLBACK(Horosmov),NULL);

	//funny movies

	Widget African,American,Europe,Kids;
	African=MyEvent("pictures/basket.jpeg");
	gtk_widget_set_size_request(African,175,80);
	gtk_tooltips_set_tip(Tooltips,African,"Africa Fun",NULL);
	g_signal_connect_swapped(African, "button_press_event", G_CALLBACK(AfricaFun),NULL);
	
	American=MyEvent("pictures/amerifun.jpeg");
	gtk_widget_set_size_request(American,175,80);
	gtk_tooltips_set_tip(Tooltips,American,"American Fun",NULL);
	g_signal_connect_swapped(American, "button_press_event", G_CALLBACK(AmericaFun),NULL);

	Europe=MyEvent("pictures/africanfunny.jpeg");
	gtk_widget_set_size_request(Europe,175,80);
	gtk_tooltips_set_tip(Tooltips,Europe,"General Fun",NULL);
	g_signal_connect_swapped(Europe, "button_press_event", G_CALLBACK(NijiaBoys),NULL);

	Kids=MyEvent("pictures/kids.jpeg");
	gtk_widget_set_size_request(Kids,175,80);
	gtk_tooltips_set_tip(Tooltips,Kids,"Kid Movies And Funs",NULL);
	g_signal_connect_swapped(Kids,"button_press_event",G_CALLBACK(KidsMovies),NULL);

	//Games
	Widget Race,War,HerosGame,KidGame;
	Race=MyEvent("pictures/race.jpeg");
	gtk_widget_set_size_request(Race,175,80);
	gtk_tooltips_set_tip(Tooltips,Race,"Racee Games",NULL);
	g_signal_connect_swapped(Race, "button_press_event", G_CALLBACK(RaceGame),NULL);
	
	War=MyEvent("pictures/war.jpeg");
	gtk_widget_set_size_request(War,175,80);
	gtk_tooltips_set_tip(Tooltips,War,"War Games",NULL);
	g_signal_connect_swapped(War, "button_press_event", G_CALLBACK(WarGame),NULL);

	HerosGame=MyEvent("pictures/horos2.jpeg");
	gtk_widget_set_size_request(HerosGame,175,80);
	gtk_tooltips_set_tip(Tooltips,HerosGame,"Horo Games",NULL);
	g_signal_connect_swapped(HerosGame, "button_press_event", G_CALLBACK(HeroGame),NULL);

	KidGame=MyEvent("pictures/kidgame.jpeg");
	gtk_widget_set_size_request(KidGame,175,80);
	gtk_tooltips_set_tip(Tooltips,KidGame,"Games For Children",NULL);
	g_signal_connect_swapped(KidGame,"button_press_event",G_CALLBACK(KidGames),NULL);

	//sports
	Widget Foot,Basket,Resl,Others;
	Foot=MyEvent("pictures/fifa.png");
	gtk_widget_set_size_request(Foot,175,80);
	gtk_tooltips_set_tip(Tooltips,Foot,"Football",NULL);
	g_signal_connect(Foot, "button_press_event", G_CALLBACK(Football),UrlText);
	
	Basket=MyEvent("pictures/basketball.jpeg");
	gtk_widget_set_size_request(Basket,175,80);
	gtk_tooltips_set_tip(Tooltips,Basket,"Basketball",NULL);
	g_signal_connect(Basket, "button_press_event", G_CALLBACK(Basketball),UrlText);

	Resl=MyEvent("pictures/resling.jpeg");
	gtk_widget_set_size_request(Resl,175,80);
	gtk_tooltips_set_tip(Tooltips,Resl,"Resling",NULL);
	g_signal_connect(Resl, "button_press_event", G_CALLBACK(Resling),UrlText);
	

	Others=MyEvent("pictures/games.jpeg");
	gtk_widget_set_size_request(Others,175,80);
	gtk_tooltips_set_tip(Tooltips,Others,"Rugby,Handball, MotoGP, Athletic and Other sports",NULL);
	g_signal_connect(Others,"button_press_event",G_CALLBACK(OtherSports),UrlText);


	//define the select type of entertianment;
	SelectType=gtk_combo_new();
	gtk_entry_set_text(GTK_ENTRY((GTK_COMBO(SelectType))-> entry),"Mp3 Music");
	GList *list=NULL;
	list=g_list_append(list," Music Vidios");
	list=g_list_append(list,"Movies");
	list=g_list_append(list,"Games");
	list=g_list_append(list,"Funny Vidio");
	list=g_list_append(list,"News");

	gtk_combo_set_popdown_strings(GTK_COMBO(SelectType),list);
	gtk_combo_set_case_sensitive(GTK_COMBO(SelectType),FALSE);
	//gtk_widget_set_size_request(SelectType,100,300);
	//getting the text from the combo
	SelectText=gtk_label_new(gtk_entry_get_text(GTK_ENTRY((GTK_COMBO(SelectType))->entry)));

	Widget back_button,forward_button,home_button,Iback,Iforward,Ihome;

	Iback=gtk_image_new_from_stock(GTK_STOCK_GO_BACK,1);
	Iforward=gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD,1);
	Ihome=gtk_image_new_from_stock(GTK_STOCK_HOME,1);

	back_button = gtk_button_new();
	gtk_container_add(GTK_CONTAINER(back_button),Iback);
	gtk_widget_set_size_request(back_button,40,40);
		gtk_tooltips_set_tip(Tooltips,back_button,"go back",NULL);
	forward_button = gtk_button_new();
	gtk_container_add(GTK_CONTAINER(forward_button),Iforward);	
	gtk_widget_set_size_request(forward_button,40,40);
		gtk_tooltips_set_tip(Tooltips,forward_button,"go forward",NULL);
	home_button=gtk_button_new();
	gtk_container_add(GTK_CONTAINER(home_button),Ihome);
		gtk_tooltips_set_tip(Tooltips,home_button,"Home",NULL);

	//create a table and insert struffs.
	Table=gtk_table_new(50,50,FALSE);
	gtk_table_attach_defaults(GTK_TABLE(Table),UrlText,10,40,0,1);
	gtk_table_attach(GTK_TABLE(Table),back_button,8,10,0,1,1,1,0,0);
	gtk_table_attach(GTK_TABLE(Table),forward_button,40,42,0,1,1,1,0,0);
	gtk_table_attach_defaults(GTK_TABLE(Table),home_button,46,48,0,1);
	gtk_table_attach(GTK_TABLE(Table), Slider,12,25,12,14, 1, 1, 0, 0 );	
	gtk_table_attach(GTK_TABLE(Table), News,30,35,12,14, 1, 1, 0, 0 );	
	
	//input search
	gtk_table_attach_defaults(GTK_TABLE(Table),InputText,15,30,15,18);
	gtk_table_attach_defaults(GTK_TABLE(Table),SelectType,30,32,15,18);
	gtk_table_attach(GTK_TABLE(Table),SearchButton,32,36,15,17, 1, 1, 0, 0 );

	//Labels
	gtk_table_attach(GTK_TABLE(Table), MusicLabel,8,14,17,18, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), MovieLabel,16,22,17,18, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), FunLabel,24,30,17,18, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), GameLabel,32,38,17,18, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), SportLabel,40,46,17,18, 1, 1, 0, 0 );

	//Music Search
	gtk_table_attach(GTK_TABLE(Table), AfricaM,8,14,18,25, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), NijiaM,8,14,26,30, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), KamerM,8,14,31,35, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), HipHop,8,14,36,40, 1, 1, 0, 0 );
	
	//movies Search
	gtk_table_attach(GTK_TABLE(Table), Nolly,16,22,18,25, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Holly,16,22,26,30, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Bolly,16,22,31,35, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Horos,16,22,36,40, 1, 1, 0, 0 );

	//Funny Vidios
	gtk_table_attach(GTK_TABLE(Table), African,24,30,18,25, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), American,24,30,26,30, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Europe,24,30,31,35, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Kids,24,30,36,40, 1, 1, 0, 0 );

	//Game Search
	gtk_table_attach(GTK_TABLE(Table), Race,32,38,18,25, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), War,32,38,26,30, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), HerosGame,32,38,31,35, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), KidGame,32,38,36,40, 1, 1, 0, 0 );

	//Sports
	gtk_table_attach(GTK_TABLE(Table), Foot,40,46,18,25, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Basket,40,46,26,30, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Resl,40,46,31,35, 1, 1, 0, 0 );
	gtk_table_attach(GTK_TABLE(Table), Others,40,46,36,40, 1, 1, 0, 0 );

	

	scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(scrolledWindow), web[count]);
	gtk_widget_show_all(scrolledWindow);

	gtk_container_add( GTK_CONTAINER(pageLayoutExpander), scrolledWindow);
	gtk_table_attach_defaults(GTK_TABLE(Table), pageLayoutExpander,0,50,11,50);
	g_signal_connect_swapped(WEBKIT_WEB_VIEW(web[count]),"load-finished",G_CALLBACK(viewSearchedPage),pageLayoutExpander);


	g_signal_connect(InputText, "activate",  G_CALLBACK(activate), web[count]);

	g_signal_connect(WEBKIT_WEB_VIEW(web[count]),"load-progress-changed",G_CALLBACK(progress),UrlText);
	g_signal_connect(WEBKIT_WEB_VIEW(web[count]),"load-finished",G_CALLBACK(finished),UrlText);
	g_signal_connect_swapped(G_OBJECT(Window), "destroy",G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(back_button, "clicked",  G_CALLBACK(back), web[count]);
	g_signal_connect(forward_button, "clicked",  G_CALLBACK(forward), web[count]);
 	g_signal_connect(home_button, "clicked",  G_CALLBACK(Home), web[count]);
 	g_signal_connect(NijiaM, "button_press_event",  G_CALLBACK(NijiaM), web[count]);
 	
 	

	return Table;
}
/**
 * nautilus_window_initialize_menus
 *
 * Create and install the set of menus for this window.
 * @window: A recently-created NautilusWindow.
 */
void
nautilus_window_initialize_menus (NautilusWindow *window)
{
    GtkActionGroup *action_group;
    GtkUIManager *ui_manager;
    GtkAction *action;
    gint i;

    window->details->ui_manager = gtk_ui_manager_new ();
    ui_manager = window->details->ui_manager;

    /* shell actions */
    action_group = gtk_action_group_new ("ShellActions");
    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
    window->details->main_action_group = action_group;
    gtk_action_group_add_actions (action_group,
                                  main_entries, G_N_ELEMENTS (main_entries),
                                  window);
    gtk_action_group_add_toggle_actions (action_group,
                                         main_toggle_entries, G_N_ELEMENTS (main_toggle_entries),
                                         window);
    gtk_action_group_add_radio_actions (action_group,
                                        view_radio_entries, G_N_ELEMENTS (view_radio_entries),
                                        -1, G_CALLBACK (action_view_radio_changed),
                                        window);

    action = nautilus_option_menu_action_new ("Zoom Options",
             _("Zoom"), _("Zoom Options"), NULL);
    gtk_action_group_add_action (action_group, action);
    g_object_unref (action);

    nautilus_window_menus_set_visibility_for_app_menu (window);
    window->details->app_menu_visibility_id =
        g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
                                  "notify::gtk-shell-shows-app-menu",
                                  G_CALLBACK (nautilus_window_menus_set_visibility_for_app_menu), window);

    action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_UP);
    g_object_set (action, "short_label", _("_Up"), NULL);

    action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_HOME);
    g_object_set (action, "short_label", _("_Home"), NULL);

    /* Alt+N for the first 10 tabs */
    for (i = 0; i < 10; ++i) {
        gchar action_name[80];
        gchar accelerator[80];

        snprintf(action_name, sizeof (action_name), "Tab%d", i);
        action = gtk_action_new (action_name, NULL, NULL, NULL);
        g_object_set_data (G_OBJECT (action), "num", GINT_TO_POINTER (i));
        g_signal_connect (action, "activate",
                          G_CALLBACK (action_tab_change_action_activate_callback), window);
        snprintf(accelerator, sizeof (accelerator), "<alt>%d", (i+1)%10);
        gtk_action_group_add_action_with_accel (action_group, action, accelerator);
        g_object_unref (action);
        gtk_ui_manager_add_ui (ui_manager,
                               gtk_ui_manager_new_merge_id (ui_manager),
                               "/",
                               action_name,
                               action_name,
                               GTK_UI_MANAGER_ACCELERATOR,
                               FALSE);

    }

    gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
    g_object_unref (action_group); /* owned by ui_manager */

    gtk_window_add_accel_group (GTK_WINDOW (window),
                                gtk_ui_manager_get_accel_group (ui_manager));

    g_signal_connect (ui_manager, "connect-proxy",
                      G_CALLBACK (connect_proxy_cb), window);

    /* add the UI */
    gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-shell-ui.xml", NULL);

    /* set actions for option menu items */
    populate_option_menu_items (window);
}
Ejemplo n.º 8
0
void create_kbm_window()
{
  if (hime_kbm_window) {
    gtk_window_present(GTK_WINDOW(hime_kbm_window));
    return;
  }

  load_setttings();

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

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

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

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


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


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

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


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

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

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

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

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

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

    group_tsin_space_opt = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));

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

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

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


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


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


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


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


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


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

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

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

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

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

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

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

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

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

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

  gtk_widget_show_all (hime_kbm_window);

  return;
}
Ejemplo n.º 9
0
static int open(GtkWidget* parent_window, gboolean not_import)
{
    GtkWidget* dialog;
    int val;
    const char* title;
    char* filter = file_ops_join_ext("*", dish_file_extension());
    global_settings* settings = settings_get();

    if (not_import)
        title = "Open bank";
    else
        title = "Import bank";

    dialog = gtk_file_chooser_dialog_new( title,
                                          GTK_WINDOW(parent_window),
                                          GTK_FILE_CHOOSER_ACTION_OPEN,
                                          GTK_STOCK_CANCEL,
                                          GTK_RESPONSE_CANCEL,
                                          GTK_STOCK_OPEN,
                                          GTK_RESPONSE_ACCEPT, NULL);

    if (dish_file_has_state())
    {
        const char* tmp = 0;
        tmp = dish_file_state_is_full() ? dish_file_state_parent_dir()
                                        : dish_file_state_bank_dir();
        gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog), tmp);
    }
    else
        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
                                           settings->last_bank_dir);

    file_chooser_add_filter(dialog, "Petri-Foo files", filter);
    file_chooser_add_filter(dialog, "All files", "*");

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
    {

        char* name = (char*) gtk_file_chooser_get_filename(
                                        GTK_FILE_CHOOSER(dialog));

        val = (not_import)  ? dish_file_read(name)
                            : dish_file_import(name);
        if (val < 0)
        {
            GtkWidget* msg = gtk_message_dialog_new(GTK_WINDOW(dialog),
                                    GTK_DIALOG_MODAL,
                                    GTK_MESSAGE_ERROR,
                                    GTK_BUTTONS_CLOSE,
                                    "Failed to read bank %s\n.", name);

            g_signal_connect_swapped(G_OBJECT(msg), "response",
                                    G_CALLBACK(gtk_widget_destroy), msg);
            gtk_widget_show (msg);
        }
        else
        {
            if (recent_manager && not_import)
                gtk_recent_manager_add_item(recent_manager,
                                    g_filename_to_uri(name, NULL, NULL));

            if (settings->last_bank_dir)
                free(settings->last_bank_dir);

            settings->last_bank_dir = g_path_get_dirname(name);
        }
    }
    else
    {
        val = -1;
    }

    gtk_widget_destroy(dialog);

    free(filter);

    return val;
}
Ejemplo n.º 10
0
/*!
  \brief present_viewer_choices() presents the user with the a list of 
  variables from EITHER the realtime vars (if in realtime mode) or from a 
  datalog (playback mode)
  */
G_MODULE_EXPORT void present_viewer_choices(void)
{
	GtkWidget *window = NULL;
	GtkWidget *table = NULL;
	GtkWidget *frame = NULL;
	GtkWidget *vbox = NULL;
	GtkWidget *hbox = NULL;
	GtkWidget *button = NULL;
	GtkWidget *label = NULL;
	GtkWidget *sep = NULL;
	GtkWidget *darea = NULL;
	GList *list = NULL;
	gconstpointer * object = NULL;
	gint i = 0;
	gint j = 0;
	gint k = 0;
	gint table_rows = 0;
	gint table_cols = 5;
	gchar * name = NULL;
	gchar * tooltip = NULL;
	gboolean playback = FALSE;
	Rtv_Map *rtv_map = NULL;
	Log_Info *log_info;

	log_info = DATA_GET(global_data,"log_info");
	rtv_map = DATA_GET(global_data,"rtv_map");
	darea = lookup_widget("logviewer_trace_darea");
	lv_data->darea = darea;
	playback = (GBOOLEAN)DATA_GET(global_data,"playback_mode");

	if (!darea)
	{
		MTXDBG(CRITICAL,_("Pointer to drawing area was NULL, returning!!!\n"));
		return;
	}

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(lookup_widget("main_window")));
	gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
	/* Playback mode..... */
	if (playback)
	{
		gtk_window_set_title(GTK_WINDOW(window),
				_("Playback Mode: Logviewer Choices"));
		frame = gtk_frame_new(_("Select Variables to playback from the list below..."));
		max_viewables = log_info->field_count;
	}
	else
	{
		/* Realtime Viewing mode... */
		gtk_window_set_title(GTK_WINDOW(window),
				_("Realtime Mode: Logviewer Choices"));
		frame = gtk_frame_new(_("Select Realtime Variables to view from the list below..."));
		max_viewables = rtv_map->derived_total;

	}
	g_signal_connect_swapped(G_OBJECT(window),"destroy_event",
			G_CALLBACK(reenable_select_params_button),
			NULL);
	g_signal_connect_swapped(G_OBJECT(window),"destroy_event",
			G_CALLBACK(save_default_choices),
			NULL);
	g_signal_connect_swapped(G_OBJECT(window),"destroy_event",
			G_CALLBACK(gtk_widget_destroy),
			(gpointer)window);
	g_signal_connect_swapped(G_OBJECT(window),"delete_event",
			G_CALLBACK(reenable_select_params_button),
			NULL);
	g_signal_connect_swapped(G_OBJECT(window),"delete_event",
			G_CALLBACK(save_default_choices),
			NULL);
	g_signal_connect_swapped(G_OBJECT(window),"delete_event",
			G_CALLBACK(gtk_widget_destroy),
			(gpointer)window);

	gtk_container_set_border_width(GTK_CONTAINER(window),5);
	gtk_container_add(GTK_CONTAINER(window),frame);

	vbox = gtk_vbox_new(FALSE,0);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
	gtk_container_add(GTK_CONTAINER(frame),vbox);

	table_rows = ceil((float)max_viewables/(float)table_cols);
	table = gtk_table_new(table_rows,table_cols,TRUE);
	gtk_table_set_row_spacings(GTK_TABLE(table),2);
	gtk_table_set_col_spacings(GTK_TABLE(table),5);
	gtk_container_set_border_width(GTK_CONTAINER(table),0);
	gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,0);

	j = 0;
	k = 0;
	if(get_list("viewables"))
	{
		g_list_free(get_list("viewables"));
		remove_list("viewables");
	}

	for (i=0;i<max_viewables;i++)
	{
		if (playback)
			list = g_list_prepend(list,(gpointer)g_ptr_array_index(log_info->log_list,i));
		else
			list = g_list_prepend(list,(gpointer)g_ptr_array_index(rtv_map->rtv_list,i));
	}
	if (playback)
		list=g_list_sort_with_data(list,list_object_sort,(gpointer)"lview_name");
	else
		list=g_list_sort_with_data(list,list_object_sort,(gpointer)"dlog_gui_name");

	for (i=0;i<max_viewables;i++)
	{
		object = NULL;
		name = NULL;
		tooltip = NULL;

		object = g_list_nth_data(list,i);

		if (playback)
			name = g_strdup(DATA_GET(object,"lview_name"));
		else
		{
			name = g_strdup(DATA_GET(object,"dlog_gui_name"));
			tooltip = g_strdup(DATA_GET(object,"tooltip"));
		}

		button = gtk_check_button_new();
		label = gtk_label_new(NULL);
		gtk_label_set_markup(GTK_LABEL(label),name);
		gtk_container_add(GTK_CONTAINER(button),label);
		store_list("viewables",g_list_prepend(
					get_list("viewables"),(gpointer)button));
		if (tooltip)
			gtk_widget_set_tooltip_text(button,tooltip);

		if (object)
		{
			OBJ_SET(button,"object",(gpointer)object);
			/* so we can set the state from elsewhere...*/
			DATA_SET(object,"lview_button",(gpointer)button);
			if ((GBOOLEAN)DATA_GET(object,"being_viewed"))
				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),TRUE);
		}
		g_signal_connect(G_OBJECT(button),"toggled",
				G_CALLBACK(view_value_set),
				NULL);
		gtk_table_attach (GTK_TABLE (table), button, j, j+1, k, k+1,
				(GtkAttachOptions) (GTK_FILL),
				(GtkAttachOptions) (0), 0, 0);
		j++;

		if (j == table_cols)
		{
			k++;
			j = 0;
		}
		g_free(name);
	}
	g_list_free(list);

	sep = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(vbox),sep,FALSE,TRUE,20);

	hbox = gtk_hbox_new(FALSE,20);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,0);
	button = gtk_button_new_with_label("Select All");
	gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,15);
	OBJ_SET(button,"state",GINT_TO_POINTER(TRUE));
	g_signal_connect(G_OBJECT(button),"clicked",
			G_CALLBACK(set_all_lview_choices_state),
			GINT_TO_POINTER(TRUE));
	button = gtk_button_new_with_label("De-select All");
	gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,15);
	OBJ_SET(button,"state",GINT_TO_POINTER(FALSE));
	g_signal_connect(G_OBJECT(button),"clicked",
			G_CALLBACK(set_all_lview_choices_state),
			GINT_TO_POINTER(FALSE));

	button = gtk_button_new_with_label("Close");
	gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,TRUE,0);
	g_signal_connect_swapped(G_OBJECT(button),"clicked",
			G_CALLBACK(reenable_select_params_button),
			NULL);
	g_signal_connect_swapped(G_OBJECT(button),"clicked",
			G_CALLBACK(save_default_choices),
			NULL);
	g_signal_connect_swapped(G_OBJECT(button),"clicked",
			G_CALLBACK(gtk_widget_destroy),
			(gpointer)window);

	set_default_lview_choices_state();
	gtk_widget_show_all(window);
	return;
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
#endif
{
	gboolean opt_force_online = FALSE;
	gboolean opt_help = FALSE;
	gboolean opt_login = FALSE;
	gboolean opt_nologin = FALSE;
	gboolean opt_version = FALSE;
	gboolean opt_si = TRUE;     /* Check for single instance? */
	char *opt_config_dir_arg = NULL;
	char *opt_login_arg = NULL;
	char *opt_session_arg = NULL;
	char *search_path;
	GList *accounts;
#ifdef HAVE_SIGNAL_H
	int sig_indx;	/* for setting up signal catching */
	sigset_t sigset;
	char errmsg[BUFSIZ];
	GIOChannel *signal_channel;
	GIOStatus signal_status;
	guint signal_channel_watcher;
#ifndef DEBUG
	char *segfault_message_tmp;
#endif
	GError *error;
#endif
	int opt;
	gboolean gui_check;
	gboolean debug_enabled;
	gboolean migration_failed = FALSE;
	GList *active_accounts;

	struct option long_options[] = {
		{"config",       required_argument, NULL, 'c'},
		{"debug",        no_argument,       NULL, 'd'},
		{"force-online", no_argument,       NULL, 'f'},
		{"help",         no_argument,       NULL, 'h'},
		{"login",        optional_argument, NULL, 'l'},
		{"multiple",     no_argument,       NULL, 'm'},
		{"nologin",      no_argument,       NULL, 'n'},
		{"session",      required_argument, NULL, 's'},
		{"version",      no_argument,       NULL, 'v'},
		{"display",      required_argument, NULL, 'D'},
		{"sync",         no_argument,       NULL, 'S'},
		{0, 0, 0, 0}
	};

#ifdef DEBUG
	debug_enabled = TRUE;
#else
	debug_enabled = FALSE;
#endif

#if !GLIB_CHECK_VERSION(2, 32, 0)
	/* GLib threading system is automaticaly initialized since 2.32.
	 * For earlier versions, it have to be initialized before calling any
	 * Glib or GTK+ functions.
	 */
	g_thread_init(NULL);
#endif

	g_set_prgname("Pidgin");

#ifdef ENABLE_NLS
	bindtextdomain(PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);
#endif

#ifdef HAVE_SETLOCALE
	/* Locale initialization is not complete here.  See gtk_init_check() */
	setlocale(LC_ALL, "");
#endif

#ifdef HAVE_SIGNAL_H

#ifndef DEBUG
		/* We translate this here in case the crash breaks gettext. */
		segfault_message_tmp = g_strdup_printf(_(
			"%s %s has segfaulted and attempted to dump a core file.\n"
			"This is a bug in the software and has happened through\n"
			"no fault of your own.\n\n"
			"If you can reproduce the crash, please notify the developers\n"
			"by reporting a bug at:\n"
			"%ssimpleticket/\n\n"
			"Please make sure to specify what you were doing at the time\n"
			"and post the backtrace from the core file.  If you do not know\n"
			"how to get the backtrace, please read the instructions at\n"
			"%swiki/GetABacktrace\n"),
			PIDGIN_NAME, DISPLAY_VERSION, PURPLE_DEVEL_WEBSITE, PURPLE_DEVEL_WEBSITE
		);

		/* we have to convert the message (UTF-8 to console
		   charset) early because after a segmentation fault
		   it's not a good practice to allocate memory */
		error = NULL;
		segfault_message = g_locale_from_utf8(segfault_message_tmp,
						      -1, NULL, NULL, &error);
		if (segfault_message != NULL) {
			g_free(segfault_message_tmp);
		}
		else {
			/* use 'segfault_message_tmp' (UTF-8) as a fallback */
			g_warning("%s\n", error->message);
			g_error_free(error);
			segfault_message = segfault_message_tmp;
		}
#else
		/* Don't mark this for translation. */
		segfault_message = g_strdup(
			"Hi, user.  We need to talk.\n"
			"I think something's gone wrong here.  It's probably my fault.\n"
			"No, really, it's not you... it's me... no no no, I think we get along well\n"
			"it's just that.... well, I want to see other people.  I... what?!?  NO!  I \n"
			"haven't been cheating on you!!  How many times do you want me to tell you?!  And\n"
			"for the last time, it's just a rash!\n"
		);
#endif

	/*
	 * Create a socket pair for receiving unix signals from a signal
	 * handler.
	 */
	if (socketpair(AF_UNIX, SOCK_STREAM, 0, signal_sockets) < 0) {
		perror("Failed to create sockets for GLib signal handling");
		exit(1);
	}
	signal_channel = g_io_channel_unix_new(signal_sockets[1]);

	/*
	 * Set the channel encoding to raw binary instead of the default of
	 * UTF-8, because we'll be sending integers across instead of strings.
	 */
	error = NULL;
	signal_status = g_io_channel_set_encoding(signal_channel, NULL, &error);
	if (signal_status != G_IO_STATUS_NORMAL) {
		fprintf(stderr, "Failed to set the signal channel to raw "
				"binary: %s", error->message);
		exit(1);
	}
	signal_channel_watcher = g_io_add_watch(signal_channel, G_IO_IN, mainloop_sighandler, NULL);
	g_io_channel_unref(signal_channel);

	/* Let's not violate any PLA's!!!! */
	/* jseymour: whatever the fsck that means */
	/* Robot101: for some reason things like gdm like to block     *
	 * useful signals like SIGCHLD, so we unblock all the ones we  *
	 * declare a handler for. thanks JSeymour and Vann.            */
	if (sigemptyset(&sigset)) {
		snprintf(errmsg, sizeof(errmsg), "Warning: couldn't initialise empty signal set");
		perror(errmsg);
	}
	for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) {
		if(signal(catch_sig_list[sig_indx], sighandler) == SIG_ERR) {
			snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d for catching",
				catch_sig_list[sig_indx]);
			perror(errmsg);
		}
		if(sigaddset(&sigset, catch_sig_list[sig_indx])) {
			snprintf(errmsg, sizeof(errmsg), "Warning: couldn't include signal %d for unblocking",
				catch_sig_list[sig_indx]);
			perror(errmsg);
		}
	}
	for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) {
		if(signal(ignore_sig_list[sig_indx], SIG_IGN) == SIG_ERR) {
			snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d to ignore",
				ignore_sig_list[sig_indx]);
			perror(errmsg);
		}
	}

	if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) {
		snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals");
		perror(errmsg);
	}
#endif

	/* scan command-line options */
	opterr = 1;
	while ((opt = getopt_long(argc, argv,
#ifndef _WIN32
				  "c:dfhmnl::s:v",
#else
				  "c:dfhmnl::v",
#endif
				  long_options, NULL)) != -1) {
		switch (opt) {
		case 'c':	/* config dir */
			g_free(opt_config_dir_arg);
			opt_config_dir_arg = g_strdup(optarg);
			break;
		case 'd':	/* debug */
			debug_enabled = TRUE;
			break;
		case 'f':	/* force-online */
			opt_force_online = TRUE;
			break;
		case 'h':	/* help */
			opt_help = TRUE;
			break;
		case 'n':	/* no autologin */
			opt_nologin = TRUE;
			break;
		case 'l':	/* login, option username */
			opt_login = TRUE;
			g_free(opt_login_arg);
			if (optarg != NULL)
				opt_login_arg = g_strdup(optarg);
			break;
		case 's':	/* use existing session ID */
			g_free(opt_session_arg);
			opt_session_arg = g_strdup(optarg);
			break;
		case 'v':	/* version */
			opt_version = TRUE;
			break;
		case 'm':   /* do not ensure single instance. */
			opt_si = FALSE;
			break;
		case 'D':   /* --display */
		case 'S':   /* --sync */
			/* handled by gtk_init_check below */
			break;
		case '?':	/* show terse help */
		default:
			show_usage(argv[0], TRUE);
#ifdef HAVE_SIGNAL_H
			g_free(segfault_message);
#endif
			return 0;
			break;
		}
	}

	/* show help message */
	if (opt_help) {
		show_usage(argv[0], FALSE);
#ifdef HAVE_SIGNAL_H
		g_free(segfault_message);
#endif
		return 0;
	}
	/* show version message */
	if (opt_version) {
		printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION,
		                                 purple_core_get_version());
#ifdef HAVE_SIGNAL_H
		g_free(segfault_message);
#endif
		return 0;
	}

	/* set a user-specified config directory */
	if (opt_config_dir_arg != NULL) {
		purple_util_set_user_dir(opt_config_dir_arg);
	}

	/*
	 * We're done piddling around with command line arguments.
	 * Fire up this baby.
	 */

	purple_debug_set_enabled(debug_enabled);

	/* If we're using a custom configuration directory, we
	 * do NOT want to migrate, or weird things will happen. */
	if (opt_config_dir_arg == NULL)
	{
		if (!purple_core_migrate())
		{
			migration_failed = TRUE;
		}
	}

	search_path = g_build_filename(purple_user_dir(), "gtkrc-2.0", NULL);
	gtk_rc_add_default_file(search_path);
	g_free(search_path);

	gui_check = gtk_init_check(&argc, &argv);
	if (!gui_check) {
		char *display = gdk_get_display();

		printf("%s %s\n", PIDGIN_NAME, DISPLAY_VERSION);

		g_warning("cannot open display: %s", display ? display : "unset");
		g_free(display);
#ifdef HAVE_SIGNAL_H
		g_free(segfault_message);
#endif

		return 1;
	}

	g_set_application_name(PIDGIN_NAME);

#ifdef _WIN32
	winpidgin_init(hint);
#endif

	if (migration_failed)
	{
		char *old = g_strconcat(purple_home_dir(),
		                        G_DIR_SEPARATOR_S ".gaim", NULL);
		const char *text = _(
			"%s encountered errors migrating your settings "
			"from %s to %s. Please investigate and complete the "
			"migration by hand. Please report this error at http://developer.pidgin.im");
		GtkWidget *dialog;

		dialog = gtk_message_dialog_new(NULL,
		                                0,
		                                GTK_MESSAGE_ERROR,
		                                GTK_BUTTONS_CLOSE,
		                                text, PIDGIN_NAME,
		                                old, purple_user_dir());
		g_free(old);

		g_signal_connect_swapped(dialog, "response",
		                         G_CALLBACK(gtk_main_quit), NULL);

		gtk_widget_show_all(dialog);

		gtk_main();

#ifdef HAVE_SIGNAL_H
		g_free(segfault_message);
#endif
		return 0;
	}

	purple_core_set_ui_ops(pidgin_core_get_ui_ops());
	purple_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops());

	/*
	 * Set plugin search directories. Give priority to the plugins
	 * in user's home directory.
	 */
	search_path = g_build_filename(purple_user_dir(), "plugins", NULL);
	if (g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR) != 0 && errno != EEXIST)
		fprintf(stderr, "Couldn't create plugins dir\n");
	purple_plugins_add_search_path(search_path);
	g_free(search_path);
	purple_plugins_add_search_path(LIBDIR);

	if (!purple_core_init(PIDGIN_UI)) {
		fprintf(stderr,
				"Initialization of the libpurple core failed. Dumping core.\n"
				"Please report this!\n");
#ifdef HAVE_SIGNAL_H
		g_free(segfault_message);
#endif
		abort();
	}

	if (opt_si && !purple_core_ensure_single_instance()) {
#ifdef HAVE_DBUS
		DBusConnection *conn = purple_dbus_get_connection();
		DBusMessage *message = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE,
				DBUS_INTERFACE_PURPLE, "PurpleBlistSetVisible");
		gboolean tr = TRUE;
		dbus_message_append_args(message, DBUS_TYPE_INT32, &tr, DBUS_TYPE_INVALID);
		dbus_connection_send_with_reply_and_block(conn, message, -1, NULL);
		dbus_message_unref(message);
#endif
		gdk_notify_startup_complete();
		purple_core_quit();
		g_printerr(_("Exiting because another libpurple client is already running.\n"));
#ifdef HAVE_SIGNAL_H
		g_free(segfault_message);
#endif
		return 0;
	}

	/* TODO: Move blist loading into purple_blist_init() */
	purple_set_blist(purple_blist_new());
	purple_blist_load();

	/* load plugins we had when we quit */
	purple_plugins_load_saved(PIDGIN_PREFS_ROOT "/plugins/loaded");

	/* TODO: Move pounces loading into purple_pounces_init() */
	purple_pounces_load();

	ui_main();

#ifdef USE_SM
	pidgin_session_init(argv[0], opt_session_arg, opt_config_dir_arg);
#endif
	if (opt_session_arg != NULL) {
		g_free(opt_session_arg);
		opt_session_arg = NULL;
	}
	if (opt_config_dir_arg != NULL) {
		g_free(opt_config_dir_arg);
		opt_config_dir_arg = NULL;
	}

	/* This needs to be before purple_blist_show() so the
	 * statusbox gets the forced online status. */
	if (opt_force_online)
		purple_network_force_online();

	/*
	 * We want to show the blist early in the init process so the
	 * user feels warm and fuzzy (not cold and prickley).
	 */
	purple_blist_show();

	if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"))
		pidgin_debug_window_show();

	if (opt_login) {
		/* disable all accounts */
		for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) {
			PurpleAccount *account = accounts->data;
			purple_account_set_enabled(account, PIDGIN_UI, FALSE);
		}
		/* honor the startup status preference */
		if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))
			purple_savedstatus_activate(purple_savedstatus_get_startup());
		/* now enable the requested ones */
		dologin_named(opt_login_arg);
		if (opt_login_arg != NULL) {
			g_free(opt_login_arg);
			opt_login_arg = NULL;
		}
	} else if (opt_nologin)	{
		/* Set all accounts to "offline" */
		PurpleSavedStatus *saved_status;

		/* If we've used this type+message before, lookup the transient status */
		saved_status = purple_savedstatus_find_transient_by_type_and_message(
							PURPLE_STATUS_OFFLINE, NULL);

		/* If this type+message is unique then create a new transient saved status */
		if (saved_status == NULL)
			saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE);

		/* Set the status for each account */
		purple_savedstatus_activate(saved_status);
	} else {
		/* Everything is good to go--sign on already */
		if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))
			purple_savedstatus_activate(purple_savedstatus_get_startup());
		purple_accounts_restore_current_statuses();
	}

	if ((active_accounts = purple_accounts_get_all_active()) == NULL)
	{
		pidgin_accounts_window_show();
	}
	else
	{
		g_list_free(active_accounts);
	}

	/* GTK clears the notification for us when opening the first window,
	 * but we may have launched with only a status icon, so clear the it
	 * just in case. */
	gdk_notify_startup_complete();

#ifdef _WIN32
	winpidgin_post_init();
#endif

	gtk_main();

#ifdef HAVE_SIGNAL_H
	g_free(segfault_message);
	g_source_remove(signal_channel_watcher);
	close(signal_sockets[0]);
	close(signal_sockets[1]);
#endif

#ifdef _WIN32
	winpidgin_cleanup();
#endif

	return 0;
}
Ejemplo n.º 12
0
Download * download_new(DownloadPrefs * prefs, char const * url)
{
    Download * download;
    char * p;
    char buf[256];
    GtkWidget * vbox;
    GtkWidget * hbox;
    GtkSizeGroup * left;
    GtkWidget * widget;
    PangoFontDescription * bold;
    unsigned long id;

    /* verify arguments */
    if(prefs == NULL || url == NULL)
    {
        errno = EINVAL;
        _download_error(NULL, NULL, 1);
        return NULL;
    }
    if((download = malloc(sizeof(*download))) == NULL)
    {
        _download_error(NULL, "malloc", 1);
        return NULL;
    }
    /* initialize structure */
    download->prefs.output = (prefs->output != NULL) ? strdup(prefs->output)
                             : NULL;
    download->prefs.user_agent = (prefs->user_agent != NULL)
                                 ? strdup(prefs->user_agent) : NULL;
    if((p = _ghtml_make_url(NULL, url)) != NULL)
        url = p;
    download->url = strdup(url);
    free(p);
    if(download->url != NULL && prefs->output == NULL)
        download->prefs.output = strdup(basename(download->url));
    download->conn = NULL;
    download->data_received = 0;
    download->content_length = 0;
    download->timeout = 0;
    download->pulse = 0;
    /* verify initialization */
    if((prefs->output != NULL && download->prefs.output == NULL)
            || (prefs->user_agent != NULL
                && download->prefs.user_agent == NULL)
            || download->url == NULL
            || gettimeofday(&download->tv, NULL) != 0)
    {
        _download_error(NULL, "gettimeofday", 1);
        download_delete(download);
        return NULL;
    }
    /* window */
    if(prefs->embedded == 0)
    {
        download->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        snprintf(buf, sizeof(buf), "%s %s", _("Download"),
                 download->url);
#if GTK_CHECK_VERSION(2, 6, 0)
        gtk_window_set_icon_name(GTK_WINDOW(download->window),
                                 "stock_download");
#endif
        gtk_window_set_resizable(GTK_WINDOW(download->window), FALSE);
        gtk_window_set_title(GTK_WINDOW(download->window), buf);
        g_signal_connect_swapped(download->window, "delete-event",
                                 G_CALLBACK(_download_on_closex), download);
    }
    else
    {
        download->window = gtk_plug_new(0);
        g_signal_connect_swapped(download->window, "embedded",
                                 G_CALLBACK(_download_on_embedded), download);
    }
#if GTK_CHECK_VERSION(3, 0, 0)
    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
#else
    vbox = gtk_vbox_new(FALSE, 2);
#endif
    bold = pango_font_description_new();
    pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
    left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
    /* address */
#if GTK_CHECK_VERSION(3, 0, 0)
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
    hbox = gtk_hbox_new(FALSE, 4);
#endif
    widget = gtk_label_new(_("Address: "));
#if GTK_CHECK_VERSION(3, 0, 0)
    gtk_widget_override_font(widget, bold);
    g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
    gtk_widget_modify_font(widget, bold);
    gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
    gtk_size_group_add_widget(left, widget);
    gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
    download->address = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(download->address), download->url);
    gtk_editable_set_editable(GTK_EDITABLE(download->address), FALSE);
    gtk_box_pack_start(GTK_BOX(hbox), download->address, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    /* labels */
    _download_label(vbox, bold, left, _("File: "), &download->filename,
                    download->prefs.output);
    _download_label(vbox, bold, left, _("Status: "), &download->status,
                    _("Resolving..."));
    _download_label(vbox, bold, left, _("Received: "), &download->received,
                    _("0.0 kB"));
    _download_label(vbox, bold, left, _("Remaining: "),
                    &download->remaining, _("Unknown"));
    /* progress bar */
    download->progress = gtk_progress_bar_new();
    gtk_box_pack_start(GTK_BOX(vbox), download->progress, FALSE, FALSE, 0);
    /* checkbox */
    download->check = gtk_check_button_new_with_label(
                          _("Close window when the download is complete"));
    gtk_box_pack_start(GTK_BOX(vbox), download->check, FALSE, FALSE, 0);
    /* button */
#if GTK_CHECK_VERSION(3, 0, 0)
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
    hbox = gtk_hbox_new(FALSE, 4);
#endif
    download->cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    g_signal_connect_swapped(download->cancel, "clicked", G_CALLBACK(
                                 _download_on_cancel), download);
    gtk_box_pack_end(GTK_BOX(hbox), download->cancel, FALSE, TRUE, 0);
    download->browse = gtk_button_new_with_mnemonic("_Open folder");
    gtk_widget_set_no_show_all(download->browse, TRUE);
    widget = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
    gtk_button_set_image(GTK_BUTTON(download->browse), widget);
    g_signal_connect_swapped(download->browse, "clicked", G_CALLBACK(
                                 _download_on_browse), download);
    gtk_box_pack_end(GTK_BOX(hbox), download->browse, FALSE, TRUE, 0);
    gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(download->window), 4);
    gtk_container_add(GTK_CONTAINER(download->window), vbox);
    download->timeout = g_idle_add(_download_on_idle, download);
    _download_refresh(download);
    gtk_widget_show_all(vbox);
    if(prefs->embedded == 0)
        gtk_widget_show(download->window);
    else
    {
        id = gtk_plug_get_id(GTK_PLUG(download->window));
        printf("%lu\n", id);
        fclose(stdout);
    }
    _download_cnt++;
    return download;
}
Ejemplo n.º 13
0
/* Object initialization
 * Create private structure and set up default values
 */
static void nojs_preferences_init(NoJSPreferences *self)
{
	NoJSPreferencesPrivate		*priv;
	GtkTreeSortable				*sortableList;
	GtkCellRenderer				*renderer;
	GtkTreeViewColumn			*column;
	GtkWidget					*widget;
	gchar						*dialogTitle;
	GtkWidget					*scrolled;
	GtkWidget					*vbox;
	GtkWidget					*hbox;
	gint						width, height;
	GtkListStore				*list;
	GtkTreeIter					listIter;

	priv=self->priv=NOJS_PREFERENCES_GET_PRIVATE(self);

	/* Set up default values */
	priv->manager=NULL;

	/* Get content area to add gui controls to */
	priv->contentArea=gtk_dialog_get_content_area(GTK_DIALOG(self));
#if GTK_CHECK_VERSION (3, 0, 0)
	vbox=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
#else
	vbox=gtk_vbox_new(FALSE, 0);
#endif

	/* Set up dialog */
	dialogTitle=_("Configure NoJS");

	gtk_window_set_title(GTK_WINDOW(self), dialogTitle);
	gtk_window_set_icon_name(GTK_WINDOW(self), GTK_STOCK_PROPERTIES);

	sokoke_widget_get_text_size(GTK_WIDGET(self), "M", &width, &height);
	gtk_window_set_default_size(GTK_WINDOW(self), width*52, -1);

	widget=sokoke_xfce_header_new(gtk_window_get_icon_name(GTK_WINDOW(self)), dialogTitle);
	if(widget) gtk_box_pack_start(GTK_BOX(priv->contentArea), widget, FALSE, FALSE, 0);

	gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);

	/* Set up description */
	widget=gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(widget),
            _("Below is a list of all web sites and the policy set for them. "
							"You can delete policies by marking the entries and clicking on <i>Delete</i>."));
	gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 4);

	/* Set up domain list */
	priv->listStore=gtk_list_store_new(N_COLUMN,
										G_TYPE_STRING,	/* DOMAIN_COLUMN */
										G_TYPE_STRING	/* POLICY_COLUMN */);

	sortableList=GTK_TREE_SORTABLE(priv->listStore);
	gtk_tree_sortable_set_sort_func(sortableList,
										DOMAIN_COLUMN,
										(GtkTreeIterCompareFunc)_nojs_preferences_sort_string_callback,
										GINT_TO_POINTER(DOMAIN_COLUMN),
										NULL);
	gtk_tree_sortable_set_sort_func(sortableList,
										POLICY_COLUMN,
										(GtkTreeIterCompareFunc)_nojs_preferences_sort_string_callback,
										GINT_TO_POINTER(POLICY_COLUMN),
										NULL);
	gtk_tree_sortable_set_sort_column_id(sortableList, DOMAIN_COLUMN, GTK_SORT_ASCENDING);

	/* Set up domain addition widgets */
#ifdef HAVE_GTK3
	hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
#else
	hbox=gtk_hbox_new(FALSE, 0);
#endif

	priv->addDomainEntry=gtk_entry_new();
	gtk_entry_set_max_length(GTK_ENTRY(priv->addDomainEntry), 64);
	gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainEntry);
	g_signal_connect_swapped(priv->addDomainEntry, "changed", G_CALLBACK(_nojs_preferences_on_add_domain_entry_changed), self);

	list=gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
	gtk_list_store_append(list, &listIter);
	gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_ACCEPT, 1, _("Accept"), -1);
	gtk_list_store_append(list, &listIter);
	gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_ACCEPT_TEMPORARILY, 1, _("Accept for session"), -1);
	gtk_list_store_append(list, &listIter);
	gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_BLOCK, 1, _("Block"), -1);

	priv->addDomainPolicyCombo=gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
	gtk_combo_box_set_active(GTK_COMBO_BOX(priv->addDomainPolicyCombo), 0);
	gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainPolicyCombo);

	renderer=gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, TRUE);
	gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, "text", 1);

	priv->addDomainButton=gtk_button_new_from_stock(GTK_STOCK_ADD);
	gtk_widget_set_sensitive(priv->addDomainButton, FALSE);
	gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainButton);
	g_signal_connect_swapped(priv->addDomainButton, "clicked", G_CALLBACK(_nojs_preferences_on_add_domain_clicked), self);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);

	/* Set up domain list view */
	priv->list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->listStore));

#if !GTK_CHECK_VERSION (3, 0, 0)
	gtk_widget_set_size_request(priv->list, -1, 300);
#endif

	priv->listSelection=gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->list));
	gtk_tree_selection_set_mode(priv->listSelection, GTK_SELECTION_MULTIPLE);
	g_signal_connect_swapped(priv->listSelection, "changed", G_CALLBACK(_nojs_preferences_changed_selection), self);

	renderer=gtk_cell_renderer_text_new();
	column=gtk_tree_view_column_new_with_attributes(_("Domain"),
													renderer,
													"text", DOMAIN_COLUMN,
													NULL);
	gtk_tree_view_column_set_sort_column_id(column, DOMAIN_COLUMN);
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column);

	renderer=gtk_cell_renderer_combo_new();
	g_object_set(G_OBJECT(renderer), "model", list, "text-column", 1, "has-entry", false, "editable", true, NULL);
	g_signal_connect_swapped(renderer, "editing-started", G_CALLBACK(_nojs_preferences_on_policy_editing_started), self);
	g_signal_connect_swapped(renderer, "editing-canceled", G_CALLBACK(_nojs_preferences_on_policy_editing_canceled), self);
	g_signal_connect_swapped(renderer, "edited", G_CALLBACK(_nojs_preferences_on_policy_edited), self);
	column=gtk_tree_view_column_new_with_attributes(_("Policy"),
													renderer,
													"text", POLICY_COLUMN,
													NULL);
	gtk_tree_view_column_set_sort_column_id(column, POLICY_COLUMN);
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column);

	scrolled=gtk_scrolled_window_new(NULL, NULL);
#if GTK_CHECK_VERSION (3, 0, 0)
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), height*10);
#endif
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrolled), priv->list);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
	gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 5);

	/* Set up JavaScript domain list management buttons */
#if GTK_CHECK_VERSION (3, 0, 0)
	hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
#else
	hbox=gtk_hbox_new(FALSE, 0);
#endif

	priv->deleteButton=gtk_button_new_from_stock(GTK_STOCK_DELETE);
	gtk_widget_set_sensitive(priv->deleteButton, FALSE);
	gtk_container_add(GTK_CONTAINER(hbox), priv->deleteButton);
	g_signal_connect_swapped(priv->deleteButton, "clicked", G_CALLBACK(_nojs_preferences_on_delete_selection), self);

	priv->deleteAllButton=gtk_button_new_with_mnemonic(_("Delete _all"));
	gtk_button_set_image(GTK_BUTTON(priv->deleteAllButton), gtk_image_new_from_stock(GTK_STOCK_DELETE, GTK_ICON_SIZE_BUTTON));
	gtk_widget_set_sensitive(priv->deleteAllButton, FALSE);
	gtk_container_add(GTK_CONTAINER(hbox), priv->deleteAllButton);
	g_signal_connect_swapped(priv->deleteAllButton, "clicked", G_CALLBACK(_nojs_preferences_on_delete_all), self);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);

	/* Add "allow-all-sites" checkbox */
	priv->allowAllSitesCheckbox=gtk_check_button_new_with_mnemonic(_("A_llow scripts at all sites"));
	priv->signalAllowAllSitesToggledID=g_signal_connect_swapped(priv->allowAllSitesCheckbox,
																"toggled",
																G_CALLBACK(_nojs_preferences_on_allow_all_sites_changed),
																self);
	gtk_box_pack_start(GTK_BOX(vbox), priv->allowAllSitesCheckbox, FALSE, TRUE, 5);

	/* Add "block-unknown-domains" checkbox */
	priv->blockUnknownDomainsCheckbox=gtk_check_button_new_with_mnemonic(_("Bloc_k scripts at unknown domains by default"));
	priv->signalBlockUnknownDomainsToggledID=g_signal_connect_swapped(priv->blockUnknownDomainsCheckbox,
																		"toggled",
																		G_CALLBACK(_nojs_preferences_on_block_unknown_domains_changed),
																		self);
	gtk_box_pack_start(GTK_BOX(vbox), priv->blockUnknownDomainsCheckbox, FALSE, TRUE, 5);

	/* Add "check-second-level-only" checkbox */
	priv->checkSecondLevelOnlyCheckbox=gtk_check_button_new_with_mnemonic(_("S_et permissions on second-level domain"));
	priv->signalCheckSecondLevelOnlyToggledID=g_signal_connect_swapped(priv->checkSecondLevelOnlyCheckbox,
																		"toggled",
																		G_CALLBACK(_nojs_preferences_on_check_second_level_only_changed),
																		self);
	gtk_box_pack_start(GTK_BOX(vbox), priv->checkSecondLevelOnlyCheckbox, FALSE, TRUE, 5);

	/* Finalize setup of content area */
	gtk_box_pack_start(GTK_BOX(priv->contentArea), vbox, TRUE, TRUE, 0);
}
Ejemplo n.º 14
0
/* Set/get properties */
static void nojs_preferences_set_property(GObject *inObject,
											guint inPropID,
											const GValue *inValue,
											GParamSpec *inSpec)
{
	NoJSPreferences			*self=NOJS_PREFERENCES(inObject);
	NoJSPreferencesPrivate	*priv=self->priv;
	GObject					*manager;

	switch(inPropID)
	{
		/* Construct-only properties */
		case PROP_MANAGER:
			/* Release old manager if available and disconnect signals */
			if(priv->manager)
			{
				if(priv->signalManagerChangedDatabaseID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedDatabaseID);
				priv->signalManagerChangedDatabaseID=0;

				if(priv->signalManagerChangedAllowAllSitesID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedAllowAllSitesID);
				priv->signalManagerChangedAllowAllSitesID=0;

				if(priv->signalManagerChangedUnknownDomainPolicyID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedUnknownDomainPolicyID);
				priv->signalManagerChangedUnknownDomainPolicyID=0;

				if(priv->signalManagerChangedCheckSecondLevelID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedCheckSecondLevelID);
				priv->signalManagerChangedCheckSecondLevelID=0;

				g_object_unref(priv->manager);
				priv->manager=NULL;
			}

			/* Set new JavaScript permission manager and
			 * listen to changes in database property
			 */
			manager=g_value_get_object(inValue);
			if(manager)
			{
				priv->manager=g_object_ref(manager);

				priv->signalManagerChangedDatabaseID=
					g_signal_connect_swapped(priv->manager,
												"notify::database-filename",
												G_CALLBACK(_nojs_preferences_on_manager_database_changed),
												self);
				_nojs_preferences_on_manager_database_changed(self, NULL, priv->manager);

				priv->signalManagerChangedAllowAllSitesID=
					g_signal_connect_swapped(priv->manager,
												"notify::allow-all-sites",
												G_CALLBACK(_nojs_preferences_on_manager_allow_all_sites_changed),
												self);
				_nojs_preferences_on_manager_allow_all_sites_changed(self, NULL, priv->manager);

				priv->signalManagerChangedUnknownDomainPolicyID=
					g_signal_connect_swapped(priv->manager,
												"notify::unknown-domain-policy",
												G_CALLBACK(_nojs_preferences_on_manager_unknown_domain_policy_changed),
												self);
				_nojs_preferences_on_manager_unknown_domain_policy_changed(self, NULL, priv->manager);

				priv->signalManagerChangedCheckSecondLevelID=
					g_signal_connect_swapped(priv->manager,
												"notify::only-second-level",
												G_CALLBACK(_nojs_preferences_on_manager_only_second_level_changed),
												self);
				_nojs_preferences_on_manager_only_second_level_changed(self, NULL, priv->manager);
			}
			break;

		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
			break;
	}
}
Ejemplo n.º 15
0
/****************************************************************
  Worklist editor shell.
*****************************************************************/
GtkWidget *create_worklist(void)
{
  GtkWidget *editor, *table, *sw, *bbox;
  GtkWidget *src_view, *dst_view, *label, *button;
  GtkWidget *menubar, *item, *menu, *image;
  GtkWidget *table2, *arrow, *check;
  GtkSizeGroup *group;
  GtkListStore *src_store, *dst_store;
  struct worklist_data *ptr;

  ptr = fc_malloc(sizeof(*ptr));

  src_store = gtk_list_store_new(1, G_TYPE_INT);
  dst_store = gtk_list_store_new(1, G_TYPE_INT);

  ptr->global_worklist_id = -1;
  ptr->pcity = NULL;
  ptr->src = src_store;
  ptr->dst = dst_store;
  ptr->future = FALSE;


  /* create shell. */ 
  editor = gtk_grid_new();
  gtk_grid_set_row_spacing(GTK_GRID(editor), 6);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(editor),
                                 GTK_ORIENTATION_VERTICAL);
  g_signal_connect(editor, "destroy", G_CALLBACK(worklist_destroy), ptr);
  g_object_set_data(G_OBJECT(editor), "data", ptr);

  ptr->editor = editor;

  /* add source and target lists.  */
  table = gtk_grid_new();
  gtk_container_add(GTK_CONTAINER(editor), table);

  group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
				      GTK_SHADOW_ETCHED_IN);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_grid_attach(GTK_GRID(table), sw, 3, 1, 2, 1);

  src_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(src_store));
  gtk_widget_set_hexpand(src_view, TRUE);
  gtk_widget_set_vexpand(src_view, TRUE);
  g_object_unref(src_store);
  gtk_size_group_add_widget(group, src_view);
  gtk_widget_set_name(src_view, "small_font");

  populate_view(GTK_TREE_VIEW(src_view), &ptr->pcity, &ptr->src_col);
  gtk_container_add(GTK_CONTAINER(sw), src_view);

  label = g_object_new(GTK_TYPE_LABEL,
		       "use-underline", TRUE,
		       "mnemonic-widget", src_view,
		       "label", _("Source _Tasks:"),
		       "xalign", 0.0, "yalign", 0.5, NULL);
  gtk_grid_attach(GTK_GRID(table), label, 3, 0, 1, 1);

  check = gtk_check_button_new_with_mnemonic(_("Show _Future Targets"));
  gtk_grid_attach(GTK_GRID(table), check, 4, 0, 1, 1);
  g_signal_connect(check, "toggled", G_CALLBACK(future_callback), ptr);


  table2 = gtk_grid_new();
  gtk_grid_attach(GTK_GRID(table), table2, 2, 1, 1, 1);

  button = gtk_button_new();
  gtk_widget_set_margin_top(button, 24);
  gtk_widget_set_margin_bottom(button, 24);
  ptr->prepend_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 0, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_prepend), ptr);
  gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE);

  button = gtk_button_new();
  ptr->up_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 1, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_NONE);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_bubble_up), ptr);
  gtk_widget_set_sensitive(ptr->up_cmd, FALSE);

  button = gtk_button_new();
  ptr->down_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 2, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_bubble_down), ptr);
  gtk_widget_set_sensitive(ptr->down_cmd, FALSE);

  button = gtk_button_new();
  gtk_widget_set_margin_top(button, 24);
  gtk_widget_set_margin_bottom(button, 24);
  ptr->append_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 3, 1, 1);

  arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(queue_append), ptr);
  gtk_widget_set_sensitive(ptr->append_cmd, FALSE);

  button = gtk_button_new();
  gtk_widget_set_margin_top(button, 24);
  gtk_widget_set_margin_bottom(button, 24);
  ptr->remove_cmd = button;
  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
  gtk_grid_attach(GTK_GRID(table2), button, 0, 4, 1, 1);
  
  arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN);
  gtk_container_add(GTK_CONTAINER(button), arrow);
  g_signal_connect_swapped(button, "clicked",
                           G_CALLBACK(queue_remove), ptr);
  gtk_widget_set_sensitive(ptr->remove_cmd, FALSE);

  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
				      GTK_SHADOW_ETCHED_IN);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_grid_attach(GTK_GRID(table), sw, 0, 1, 2, 1);

  dst_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dst_store));
  gtk_widget_set_hexpand(dst_view, TRUE);
  gtk_widget_set_vexpand(dst_view, TRUE);
  g_object_unref(dst_store);
  gtk_size_group_add_widget(group, dst_view);
  gtk_widget_set_name(dst_view, "small_font");

  populate_view(GTK_TREE_VIEW(dst_view), &ptr->pcity, &ptr->dst_col);
  gtk_container_add(GTK_CONTAINER(sw), dst_view);

  label = g_object_new(GTK_TYPE_LABEL,
		       "use-underline", TRUE,
		       "mnemonic-widget", dst_view,
		       "label", _("Target _Worklist:"),
		       "xalign", 0.0, "yalign", 0.5, NULL);
  gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);

  /* add bottom menu and buttons. */
  bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
  gtk_box_set_spacing(GTK_BOX(bbox), 10);
  gtk_container_add(GTK_CONTAINER(editor), bbox);

  menubar = gtk_aux_menu_bar_new();
  gtk_container_add(GTK_CONTAINER(bbox), menubar);
  gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), menubar, TRUE);

  menu = gtk_menu_new();

  image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
  item = gtk_image_menu_item_new_with_mnemonic(_("_Add Global Worklist"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
  g_signal_connect(menu, "show",
		   G_CALLBACK(popup_add_menu), ptr);
  ptr->add_cmd = item;
  gtk_widget_set_sensitive(ptr->add_cmd, FALSE);

  button = gtk_button_new_from_stock(GTK_STOCK_HELP);
  gtk_container_add(GTK_CONTAINER(bbox), button);
  g_signal_connect(button, "clicked",
		   G_CALLBACK(help_callback), ptr);
  ptr->help_cmd = button;
  gtk_widget_set_sensitive(ptr->help_cmd, FALSE);

  button = gtk_button_new_with_mnemonic(_("Change Prod_uction"));
  gtk_container_add(GTK_CONTAINER(bbox), button);
  g_signal_connect(button, "clicked",
		   G_CALLBACK(change_callback), ptr);
  ptr->change_cmd = button;
  gtk_widget_set_sensitive(ptr->change_cmd, FALSE);

  ptr->src_view = src_view;
  ptr->dst_view = dst_view;
  ptr->src_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(src_view));
  ptr->dst_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dst_view));
  gtk_tree_selection_set_mode(ptr->dst_selection, GTK_SELECTION_MULTIPLE);

  /* DND and other state changing callbacks. */
  gtk_tree_view_set_reorderable(GTK_TREE_VIEW(dst_view), TRUE);
  g_signal_connect(dst_view, "drag_end",
		   G_CALLBACK(dst_dnd_callback), ptr);

  g_signal_connect(src_view, "row_activated",
		   G_CALLBACK(src_row_callback), ptr);
  g_signal_connect(src_view, "key_press_event",
		   G_CALLBACK(src_key_press_callback), ptr);

  g_signal_connect(dst_view, "row_activated",
		   G_CALLBACK(dst_row_callback), ptr);
  g_signal_connect(dst_view, "key_press_event",
		   G_CALLBACK(dst_key_press_callback), ptr);

  g_signal_connect(ptr->src_selection, "changed",
      		   G_CALLBACK(src_selection_callback), ptr);
  g_signal_connect(ptr->dst_selection, "changed",
      		   G_CALLBACK(dst_selection_callback), ptr);


  gtk_widget_show_all(table);
  gtk_widget_show_all(bbox);

  return editor;
}
Ejemplo n.º 16
0
static int basic_save_as(GtkWidget* parent_window, gboolean not_export)
{
    GtkWidget *dialog;
    int val;
    const char* title;
    char* filter = file_ops_join_ext("*", dish_file_extension());
    char* untitled_dish = file_ops_join_ext(untitled_name,
                                            dish_file_extension());

    global_settings* settings = settings_get();

    if (not_export)
        title = "Basic Save bank as";
    else
        title = "Basic Export as";

    dialog = gtk_file_chooser_dialog_new(title,
                                    GTK_WINDOW(parent_window),
                                    GTK_FILE_CHOOSER_ACTION_SAVE,
                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                    GTK_STOCK_SAVE_AS, GTK_RESPONSE_ACCEPT,
                                    NULL);

    gtk_file_chooser_set_do_overwrite_confirmation(
                                    GTK_FILE_CHOOSER(dialog), TRUE);
    if (!dish_file_has_state())
    {
        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
                                            settings->last_bank_dir);
        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog),
                                            untitled_dish);
    }
    else
    {
        const char* tmp = 0;
        char* fn = 0;
        char* pdir = 0; /* parent of session dir */

        if (dish_file_state_is_full())
        {
            tmp = dish_file_state_parent_dir();

            if (session_is_active()
             && (pdir = file_ops_parent_dir(tmp)) != 0)
            {
                tmp = pdir;
            }
        }
        else
            tmp = dish_file_state_bank_dir();

        debug("tmp:     '%s'\n", tmp);
        debug("parent:  '%s'\n", dish_file_state_parent_dir());
        debug("bank:    '%s'\n", dish_file_state_bank_dir());

        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), tmp);
        fn = file_ops_join_ext( dish_file_state_bank_name(),
                                dish_file_extension());

        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fn);
        free(fn);
        free(pdir);
    }

    file_chooser_add_filter(dialog, "Petri-Foo files", filter);
    file_chooser_add_filter(dialog, "All files", "*");

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
    {
        char *name = (char *)
            gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));

        if ((val = dish_file_write_basic(name)) < 0)
        {
            GtkWidget* msg = gtk_message_dialog_new(GTK_WINDOW(dialog),
                                    GTK_DIALOG_MODAL,
                                    GTK_MESSAGE_ERROR,
                                    GTK_BUTTONS_CLOSE,
                                    "Failed to write file %s\n.", name);

            g_signal_connect_swapped(G_OBJECT(msg), "response",
                                    G_CALLBACK(gtk_widget_destroy), msg);
            gtk_widget_show (msg);
        }
        else
        {
            if (recent_manager && not_export)
                gtk_recent_manager_add_item (recent_manager, 
                    g_filename_to_uri(name, NULL, NULL));
        }
    }
    else
    {
        val = -1;
    }

    gtk_widget_destroy(dialog);

    free(filter);

    return val;
}
Ejemplo n.º 17
0
void create_gtab_conf_window()
{
  if (hime_gtab_conf_window) {
    gtk_window_present(GTK_WINDOW(hime_gtab_conf_window));
    return;
  }

  load_settings();

  hime_gtab_conf_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  if (hime_setup_window_type_utility)
    gtk_window_set_type_hint(GTK_WINDOW(hime_gtab_conf_window), GDK_WINDOW_TYPE_HINT_UTILITY);
  gtk_window_set_position(GTK_WINDOW(hime_gtab_conf_window), GTK_WIN_POS_MOUSE);
  gtk_window_set_has_resize_grip(GTK_WINDOW(hime_gtab_conf_window), FALSE);

  g_signal_connect (G_OBJECT (hime_gtab_conf_window), "delete_event",
                    G_CALLBACK (close_gtab_conf_window),
                    NULL);

  gtk_window_set_title (GTK_WINDOW (hime_gtab_conf_window), _("倉頡/行列/大易設定"));
  gtk_container_set_border_width (GTK_CONTAINER (hime_gtab_conf_window), 3);

  GtkWidget *vbox_top = gtk_vbox_new (FALSE, 10);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (hime_gtab_conf_window), vbox_top);

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


  GtkWidget *frame_gtab_l = gtk_frame_new(_("外觀"));
  gtk_container_set_border_width (GTK_CONTAINER (frame_gtab_l), 5);
  gtk_box_pack_start (GTK_BOX (hbox_lr), frame_gtab_l, TRUE, TRUE, 0);
  GtkWidget *vbox_gtab_l = gtk_vbox_new (FALSE, 0);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_gtab_l), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (frame_gtab_l), vbox_gtab_l);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_gtab_l), 10);


  GtkWidget *frame_gtab_r = gtk_frame_new(_("行為"));
  gtk_container_set_border_width (GTK_CONTAINER (frame_gtab_r), 5);
  gtk_box_pack_start (GTK_BOX (hbox_lr), frame_gtab_r, TRUE, TRUE, 0);
  GtkWidget *vbox_gtab_r = gtk_vbox_new (FALSE, 0);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_gtab_r), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (frame_gtab_r), vbox_gtab_r);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_gtab_r), 10);

#define SPC 1

  GtkWidget *hbox_gtab_pre_select = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_pre_select, FALSE, FALSE, 0);
  opt_gtab_pre_select = gtk_label_new (_("預覽/預選 字"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_pre_select),opt_gtab_pre_select,  FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_gtab_pre_select), create_auto_select_by_phrase_opts(&opt_gtab_pre_select, gtab_pre_select),  FALSE, FALSE, 0);

  GtkWidget *hbox_gtab_disp_partial_match = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_disp_partial_match, FALSE, FALSE, 0);
  opt_gtab_disp_partial_match = gtk_label_new (_("預選列中顯示部份符合的字"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_disp_partial_match), opt_gtab_disp_partial_match,  FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_gtab_disp_partial_match), create_auto_select_by_phrase_opts(&opt_gtab_disp_partial_match, gtab_disp_partial_match), FALSE, FALSE, 0);

  GtkWidget *hbox_gtab_disp_key_codes = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_disp_key_codes, FALSE, FALSE, 0);
  check_button_gtab_disp_key_codes = gtk_check_button_new_with_label (_("顯示字根"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_disp_key_codes), check_button_gtab_disp_key_codes,  FALSE, FALSE, 0);

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_disp_key_codes),
     gtab_disp_key_codes);


  GtkWidget *hbox_gtab_disp_im_name = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_disp_im_name, FALSE, FALSE, 0);
  check_button_gtab_disp_im_name = gtk_check_button_new_with_label (_("顯示輸入法名稱"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_disp_im_name), check_button_gtab_disp_im_name,  FALSE, FALSE, 0);

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_disp_im_name),
     gtab_disp_im_name);

  GtkWidget *hbox_gtab_hide_row2 = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_hide_row2, FALSE, FALSE, 0);
  check_button_gtab_hide_row2 = gtk_check_button_new_with_label (_("隱藏第二列 (輸入鍵…)"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_hide_row2), check_button_gtab_hide_row2,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_hide_row2),
     gtab_hide_row2);


  GtkWidget *hbox_gtab_in_row1 = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_in_row1, FALSE, FALSE, 0);
  check_button_gtab_in_row1 = gtk_check_button_new_with_label (_("將字根移至第一列"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_in_row1), check_button_gtab_in_row1,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_in_row1),
     gtab_in_row1);

  GtkWidget *hbox_gtab_vertical_select = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_l), hbox_gtab_vertical_select, FALSE, FALSE, 0);
  GtkWidget *label_gtab_vertical_select = gtk_label_new (_("垂直選擇"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_vertical_select), label_gtab_vertical_select,  FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_gtab_vertical_select), create_auto_select_by_phrase_opts(&opt_gtab_vertical_select, gtab_vertical_select),  FALSE, FALSE, 0);

  GtkWidget *hbox_gtab_press_full_auto_send = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_press_full_auto_send, FALSE, FALSE, 0);
  GtkWidget *label_gtab_gtab_press_full_auto_send = gtk_label_new(_("按滿字根自動送字"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_press_full_auto_send), label_gtab_gtab_press_full_auto_send, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_gtab_press_full_auto_send), create_auto_select_by_phrase_opts(&opt_gtab_press_full_auto_send, gtab_press_full_auto_send),  FALSE, FALSE, 0);

  GtkWidget *hbox_gtab_auto_select_by_phrase = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_auto_select_by_phrase, FALSE, FALSE, 0);
  GtkWidget *label_gtab_auto_select = gtk_label_new(_("由詞庫自動選字"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_auto_select_by_phrase), label_gtab_auto_select,  FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_gtab_auto_select_by_phrase), create_auto_select_by_phrase_opts(&opt_auto_select_by_phrase, gtab_auto_select_by_phrase),  FALSE, FALSE, 0);
  check_button_gtab_phrase_pre_select = gtk_check_button_new_with_label (_("使用預選詞"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_auto_select_by_phrase), check_button_gtab_phrase_pre_select,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_phrase_pre_select), gtab_phrase_pre_select);


  GtkWidget *hbox_gtab_dup_select_bell = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_dup_select_bell, FALSE, FALSE, 0);
  check_button_gtab_dup_select_bell = gtk_check_button_new_with_label (_("有重複字時,發出嗶聲"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_dup_select_bell),check_button_gtab_dup_select_bell,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_dup_select_bell),
     gtab_dup_select_bell);

  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), create_spc_opts(), FALSE, FALSE, 0);

  GtkWidget *hbox_gtab_invalid_key_in = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_invalid_key_in, FALSE, FALSE, 0);
  check_button_gtab_invalid_key_in = gtk_check_button_new_with_label (_("可鍵入錯誤字根 (傳統)"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_invalid_key_in), check_button_gtab_invalid_key_in,  FALSE, FALSE, 0);

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_invalid_key_in),
     gtab_invalid_key_in);


  GtkWidget *hbox_gtab_shift_phrase_key = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_shift_phrase_key, FALSE, FALSE, 0);
  check_button_gtab_shift_phrase_key = gtk_check_button_new_with_label (_("可用 Shift 輸入片語 (預設為 Alt-Shift)"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_shift_phrase_key), check_button_gtab_shift_phrase_key,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_shift_phrase_key),
     gtab_shift_phrase_key);

  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), create_en_pho_key_sel(_("切換[中/英]輸入")), FALSE, FALSE, 0);

#if 0
  GtkWidget *hbox_hime_capslock_lower = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_hime_capslock_lower, FALSE, FALSE, 0);
  check_button_hime_capslock_lower = gtk_check_button_new_with_label (_("\t用小寫字母"));
  gtk_box_pack_start (GTK_BOX (hbox_hime_capslock_lower), check_button_hime_capslock_lower,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_hime_capslock_lower),
     hime_capslock_lower);
#endif

  GtkWidget *hbox_gtab_unique_auto_send = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_unique_auto_send, FALSE, FALSE, 0);
  GtkWidget *label_gtab_unique_auto_send = gtk_label_new (_("唯一選擇時自動送出"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_unique_auto_send), label_gtab_unique_auto_send,  FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_gtab_unique_auto_send),  create_auto_select_by_phrase_opts(&opt_gtab_unique_auto_send, gtab_unique_auto_send),  FALSE, FALSE, 0);

  GtkWidget *hbox_gtab_que_wild_card = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_que_wild_card, FALSE, FALSE, 0);
  check_button_gtab_que_wild_card = gtk_check_button_new_with_label (_("使用?萬用字元"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_que_wild_card), check_button_gtab_que_wild_card,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_que_wild_card),
     gtab_que_wild_card);

  GtkWidget *hbox_gtab_que_wild_card_asterisk = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_que_wild_card_asterisk, FALSE, FALSE, 0);
  check_button_gtab_que_wild_card_asterisk = gtk_check_button_new_with_label (_("使用*萬用字元"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_que_wild_card_asterisk), check_button_gtab_que_wild_card_asterisk,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_que_wild_card_asterisk),
     gtab_que_wild_card_asterisk);

  GtkWidget *hbox_gtab_pho_query = gtk_hbox_new (FALSE, SPC);
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), hbox_gtab_pho_query, FALSE, FALSE, 0);
  check_button_gtab_pho_query = gtk_check_button_new_with_label (_("使用` 查詢同音字"));
  gtk_box_pack_start (GTK_BOX (hbox_gtab_pho_query), check_button_gtab_pho_query,  FALSE, FALSE, 0);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_gtab_pho_query),
     gtab_pho_query);

  GtkWidget *button_edit_append = gtk_button_new_with_label(_("編輯預設輸入法的使用者外加字詞"));
  gtk_box_pack_start (GTK_BOX (vbox_gtab_r), button_edit_append, FALSE, FALSE, 0);

  g_signal_connect_swapped (G_OBJECT (button_edit_append), "clicked",
                            G_CALLBACK (cb_gtab_edit_append), NULL);


  GtkWidget *hbox_cancel_ok = gtk_hbox_new (FALSE, 10);
  gtk_grid_set_column_homogeneous(GTK_GRID(hbox_cancel_ok), TRUE);
  gtk_box_pack_start (GTK_BOX (vbox_top), hbox_cancel_ok, FALSE, FALSE, 0);

  GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  if (button_order)
    gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
  else
    gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);

  g_signal_connect (G_OBJECT (button_cancel), "clicked",
                            G_CALLBACK (close_gtab_conf_window),
                            G_OBJECT (hime_gtab_conf_window));

  GtkWidget *button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
#if !GTK_CHECK_VERSION(2,91,2)
  if (button_order)
    gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 0);
  else
    gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 0);
#else
  if (button_order)
    gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_LEFT, 1, 1);
  else
    gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_RIGHT, 1, 1);
#endif

  g_signal_connect_swapped (G_OBJECT (button_ok), "clicked",
                            G_CALLBACK (cb_gtab_conf_ok),
                            G_OBJECT (hime_gtab_conf_window));

  GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button_ok);

  gtk_widget_show_all (hime_gtab_conf_window);

  return;
}
Ejemplo n.º 18
0
static Launcher *
create_launcher (const char *location)
{
	GKeyFile *key_file;
	char     *scheme;
	gboolean  is_uri;
	gboolean  loaded;
	Launcher *launcher;
	GError   *error = NULL;
	char     *new_location;

	if (!location) {
		g_printerr (_("No URI provided for panel launcher desktop file\n"));
		return NULL;
	}

	new_location = NULL;
	key_file = g_key_file_new ();

	scheme = g_uri_parse_scheme (location);
	is_uri = scheme != NULL;
	g_free (scheme);

	if (!is_uri && !g_path_is_absolute (location)) {
		/* try to first load a file in our config directory, and if it
		 * doesn't exist there, try to find it in the xdg data dirs */
		char *path;

		path = panel_make_full_path (NULL, location);

		if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
			g_free (path);
			path = panel_g_lookup_in_applications_dirs (location);
			/* it's important to keep the full path if the desktop
			 * file comes from a data dir: when the user will edit
			 * it, we'll want to save it in PANEL_LAUNCHERS_PATH
			 * with a random name (and not evolution.desktop, eg)
			 * and having only a basename as location will make
			 * this impossible */
			if (path)
				new_location = g_strdup (path);
		}

		if (path) {
			loaded = g_key_file_load_from_file (key_file, path,
							    G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
							    &error);
			g_free (path);
		} else {
			loaded = FALSE;
		}
	} else
		loaded = panel_key_file_load_from_uri (key_file, location,
						       G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
						       &error);

	if (!loaded) {
		g_printerr (_("Unable to open desktop file %s for panel launcher%s%s\n"),
			    location,
			    error ? ": " : "",
			    error ? error->message : "");
		if (error)
			g_error_free (error);

		g_key_file_free (key_file);

		return NULL; /*button is null*/
	}

	if (!new_location)
		new_location = g_strdup (location);

	launcher = g_new0 (Launcher, 1);

	launcher->info = NULL;
	launcher->button = NULL;
	launcher->location = new_location;
	launcher->key_file = key_file;
	launcher->prop_dialog = NULL;
	launcher->destroy_handler = 0;

	/* Icon will be setup later */
	launcher->button = button_widget_new (NULL /* icon */,
					      FALSE,
					      PANEL_ORIENTATION_TOP);

	gtk_widget_show (launcher->button);

	/*gtk_drag_dest_set (GTK_WIDGET (launcher->button),
			   GTK_DEST_DEFAULT_ALL,
			   dnd_targets, 2,
			   GDK_ACTION_COPY);*/
	gtk_drag_dest_set (GTK_WIDGET (launcher->button),
			   0, NULL, 0, 0);

	g_signal_connect (launcher->button, "drag_data_get",
			   G_CALLBACK (drag_data_get_cb), launcher);
	g_signal_connect (launcher->button, "drag_data_received",
			   G_CALLBACK (drag_data_received_cb), launcher);
	g_signal_connect (launcher->button, "drag_motion",
			   G_CALLBACK (drag_motion_cb), launcher);
	g_signal_connect (launcher->button, "drag_drop",
			   G_CALLBACK (drag_drop_cb), launcher);
	g_signal_connect (launcher->button, "drag_leave",
			   G_CALLBACK (drag_leave_cb), launcher);
	g_signal_connect_swapped (launcher->button, "clicked",
				  G_CALLBACK (launcher_launch), launcher);

	launcher->destroy_handler =
			g_signal_connect (launcher->button, "destroy",
					  G_CALLBACK (destroy_launcher),
					  launcher);

	return launcher;
}
Ejemplo n.º 19
0
/*--------------------------------------------------------------------------*/
void
gl_object_editor_prepare_text_page (glObjectEditor       *editor)
{
	gl_debug (DEBUG_EDITOR, "START");

	/* Extract widgets from XML tree. */
        gl_builder_util_get_widgets (editor->priv->builder,
                                     "text_page_vbox",         &editor->priv->text_page_vbox,
                                     "text_family_hbox",       &editor->priv->text_family_hbox,
                                     "text_size_spin",         &editor->priv->text_size_spin,
                                     "text_bold_toggle",       &editor->priv->text_bold_toggle,
                                     "text_italic_toggle",     &editor->priv->text_italic_toggle,
                                     "text_color_hbox",        &editor->priv->text_color_hbox,
                                     "text_color_radio",       &editor->priv->text_color_radio,
                                     "text_color_key_radio",   &editor->priv->text_color_key_radio,
                                     "text_color_key_hbox",    &editor->priv->text_color_key_hbox,
                                     "text_left_toggle",       &editor->priv->text_left_toggle,
                                     "text_center_toggle",     &editor->priv->text_center_toggle,
                                     "text_right_toggle",      &editor->priv->text_right_toggle,
                                     "text_top_toggle",        &editor->priv->text_top_toggle,
                                     "text_vcenter_toggle",    &editor->priv->text_vcenter_toggle,
                                     "text_bottom_toggle",     &editor->priv->text_bottom_toggle,
                                     "text_line_spacing_spin", &editor->priv->text_line_spacing_spin,
                                     "text_auto_shrink_check", &editor->priv->text_auto_shrink_check,
                                     NULL);

	editor->priv->text_family_combo = gl_font_combo_new ("Sans");
        gtk_box_pack_start (GTK_BOX (editor->priv->text_family_hbox),
                            editor->priv->text_family_combo,
                            TRUE, TRUE, 0);

	editor->priv->text_color_combo = gl_color_combo_new (_("Default"),
                                                             GL_COLOR_TEXT_DEFAULT,
                                                             gl_prefs_model_get_default_text_color (gl_prefs));
        gtk_box_pack_start (GTK_BOX (editor->priv->text_color_hbox),
                            editor->priv->text_color_combo,
                            FALSE, FALSE, 0);

        editor->priv->text_color_key_combo = gl_field_button_new (NULL);
        gtk_box_pack_start (GTK_BOX (editor->priv->text_color_key_hbox),
                            editor->priv->text_color_key_combo,
                            TRUE, TRUE, 0);


	/* Modify widgets */
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_radio), TRUE);
	gtk_widget_set_sensitive (editor->priv->text_color_combo, TRUE);
        gtk_widget_set_sensitive (editor->priv->text_color_key_combo, FALSE);

	/* Un-hide */
	gtk_widget_show_all (editor->priv->text_page_vbox);

	/* Connect signals */
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_family_combo),
				  "changed",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_size_spin),
				  "value-changed",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_bold_toggle),
				  "toggled",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_italic_toggle),
				  "toggled",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_color_combo),
				  "color_changed",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_color_key_combo),
				  "changed",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_color_radio),
				  "toggled",
				  G_CALLBACK (text_radio_toggled_cb),
				  G_OBJECT (editor));				  
	g_signal_connect_swapped (G_OBJECT (editor->priv->text_color_key_radio),
				  "toggled",
				  G_CALLBACK (text_radio_toggled_cb),
				  G_OBJECT (editor));

	g_signal_connect (G_OBJECT (editor->priv->text_left_toggle),
			  "toggled",
			  G_CALLBACK (align_toggle_cb),
			  G_OBJECT (editor));
	g_signal_connect (G_OBJECT (editor->priv->text_center_toggle),
			  "toggled",
			  G_CALLBACK (align_toggle_cb),
			  G_OBJECT (editor));
	g_signal_connect (G_OBJECT (editor->priv->text_right_toggle),
			  "toggled",
			  G_CALLBACK (align_toggle_cb),
			  G_OBJECT (editor));

	g_signal_connect (G_OBJECT (editor->priv->text_top_toggle),
			  "toggled",
			  G_CALLBACK (valign_toggle_cb),
			  G_OBJECT (editor));
	g_signal_connect (G_OBJECT (editor->priv->text_vcenter_toggle),
			  "toggled",
			  G_CALLBACK (valign_toggle_cb),
			  G_OBJECT (editor));
	g_signal_connect (G_OBJECT (editor->priv->text_bottom_toggle),
			  "toggled",
			  G_CALLBACK (valign_toggle_cb),
			  G_OBJECT (editor));

	g_signal_connect_swapped (G_OBJECT (editor->priv->text_line_spacing_spin),
				  "value-changed",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));

	g_signal_connect_swapped (G_OBJECT (editor->priv->text_auto_shrink_check),
				  "toggled",
				  G_CALLBACK (gl_object_editor_changed_cb),
				  G_OBJECT (editor));

	gl_debug (DEBUG_EDITOR, "END");
}
Ejemplo n.º 20
0
int main( int argc, char **argv )
{
    new CScene;
    new TextureMgr;

    GtkWidget*          table;
    GdkGLConfig*        GLconf;
    GdkGLContext*       GLContext;
    GtkWidget*          v_box;

    gtk_init( &argc, &argv );
    gtk_gl_init( &argc, &argv );

    da = gtk_drawing_area_new();
    GLconf = gdk_gl_config_new_by_mode( (GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE) );
    if( !( GLconf ) || !( gtk_widget_set_gl_capability( da, GLconf, NULL, TRUE, GDK_GL_RGBA_TYPE ) ) )
        g_assert_not_reached();

    g_signal_connect_after( G_OBJECT( da ), "realize", G_CALLBACK( realize_main ), NULL );
    g_signal_connect( da, "configure_event", G_CALLBACK( configure ), NULL );
    g_signal_connect( da, "expose_event", G_CALLBACK( expose ), NULL );

    gtk_widget_show( da );
    gtk_widget_realize( da );
    //GLContext = gtk_widget_get_gl_context( da );

    g_signal_connect_after( G_OBJECT( da ), "realize", G_CALLBACK( realize_sub ), NULL );
    g_signal_connect( da, "configure_event", G_CALLBACK( configure ), NULL );
    g_signal_connect( da, "expose_event", G_CALLBACK( expose ), NULL );

    g_signal_connect( G_OBJECT( da ), "motion_notify_event", G_CALLBACK( mouse_motion_cb ), (gpointer)Window );
    g_signal_connect( G_OBJECT( da ), "button_press_event", G_CALLBACK( mouse_click_cb ), (gpointer)Window );
    g_signal_connect( G_OBJECT( da ), "button_release_event", G_CALLBACK( mouse_click_cb ), (gpointer)Window );
    g_signal_connect( G_OBJECT( da ), "scroll_event", G_CALLBACK( mouse_scroll_cb ), (gpointer)Window );
    g_signal_connect( G_OBJECT( da ), "key_press_event", G_CALLBACK( keyPress ), (gpointer)Window );

    gtk_widget_show ( da );

    Window = gtk_window_new( GTK_WINDOW_TOPLEVEL );                                                             /// WINDOW
    gtk_window_set_default_size( GTK_WINDOW(Window), 800, 500 );
    gtk_window_set_title (GTK_WINDOW (Window), "Stilewski's Plant Generator");
    gtk_window_set_position (GTK_WINDOW (Window), GTK_WIN_POS_CENTER);
    g_signal_connect_swapped( Window, "destroy", G_CALLBACK( gtk_main_quit ), NULL );
    v_box = gtk_vbox_new( FALSE, 0 );
    gtk_container_add( GTK_CONTAINER( Window ), v_box );


    gtk_box_pack_start( GTK_BOX( v_box ), construct_menu(), TRUE, TRUE, 0 );                                    /// MAIN MENU
    table = gtk_table_new( 16, 16, FALSE );                                                                     /// TABLE
    gtk_table_set_col_spacing( GTK_TABLE(table), 11, 8 );
    gtk_table_set_row_spacing( GTK_TABLE(table), 13, 8 );
    gtk_table_attach_defaults( GTK_TABLE(table), da, 0, 12, 0, 14 );                                            /// DRAWING AREA
    gtk_table_attach_defaults( GTK_TABLE(table), construct_side_panel(), 12, 16, 0, 16 );                       /// SIDE PANEL
    gtk_table_attach_defaults( GTK_TABLE(table), construct_bottom_panel(), 0, 12, 14, 16 );                     /// BOTTOM PANEL
    gtk_box_pack_start( GTK_BOX( v_box ), table, TRUE, TRUE, 0 );
    gtk_box_pack_start( GTK_BOX( v_box ), construct_statusbar(), TRUE, TRUE, 0 );                               /// STATUS BAR



    gtk_widget_set_events
    (
        da,
        GDK_EXPOSURE_MASK       |
        GDK_SCROLL_MASK         |
        GDK_POINTER_MOTION_MASK |
        GDK_BUTTON_PRESS_MASK   |
        GDK_BUTTON_RELEASE_MASK |
        GDK_BUTTON_MOTION_MASK  |
        GDK_BUTTON1_MOTION_MASK |
        GDK_KEY_PRESS_MASK
    );
    gtk_toggle_button_set_mode( GTK_TOGGLE_BUTTON( checkBoxRandom ), TRUE );
    gtk_widget_show( Window );

    plant = new CPlant();

    InitGL();
    gtk_widget_show_all( Window );
    g_timeout_add( 1000 / 60, applyChanges, da );
    gtk_main();
}
Ejemplo n.º 21
0
static void _openmoko_settings(Openmoko * openmoko)
{
	GtkWidget * vbox;
	GtkWidget * hbox;
	GtkWidget * frame;
	GtkWidget * bbox;
	GtkWidget * widget;

	if(openmoko->window != NULL)
	{
		gtk_window_present(GTK_WINDOW(openmoko->window));
		return;
	}
	openmoko->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(openmoko->window), 4);
	gtk_window_set_default_size(GTK_WINDOW(openmoko->window), 200, 300);
#if GTK_CHECK_VERSION(2, 6, 0)
	gtk_window_set_icon_name(GTK_WINDOW(openmoko->window),
			"gnome-settings");
#endif
	gtk_window_set_title(GTK_WINDOW(openmoko->window),
			"Openmoko preferences");
	g_signal_connect_swapped(openmoko->window, "delete-event", G_CALLBACK(
				_settings_on_closex), openmoko);
	vbox = gtk_vbox_new(FALSE, 0);
	/* check button */
	openmoko->deepsleep = gtk_check_button_new_with_label(
			"Prevent deep sleep");
	gtk_box_pack_start(GTK_BOX(vbox), openmoko->deepsleep, FALSE, TRUE, 0);
	/* hardware */
	frame = gtk_frame_new("Hardware");
	gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
	bbox = gtk_vbox_new(TRUE, 4);
	gtk_container_set_border_width(GTK_CONTAINER(bbox), 4);
	/* bluetooth */
	hbox = gtk_hbox_new(FALSE, 4);
	widget = gtk_label_new("Bluetooth");
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
	openmoko->hw_bluetooth = gtk_toggle_button_new_with_label("OFF");
	g_signal_connect(openmoko->hw_bluetooth, "toggled", G_CALLBACK(
				_settings_on_toggled), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), openmoko->hw_bluetooth, FALSE, TRUE,
			0);
	gtk_box_pack_start(GTK_BOX(bbox), hbox, FALSE, TRUE, 0);
	/* GPS */
	hbox = gtk_hbox_new(FALSE, 4);
	widget = gtk_label_new("GPS");
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
	openmoko->hw_gps = gtk_toggle_button_new_with_label("OFF");
	g_signal_connect(openmoko->hw_gps, "toggled", G_CALLBACK(
				_settings_on_toggled), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), openmoko->hw_gps, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(bbox), hbox, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(frame), bbox);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 0);
	/* button box */
	bbox = gtk_hbutton_box_new();
	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 4);
	widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
				_settings_on_cancel), openmoko);
	gtk_container_add(GTK_CONTAINER(bbox), widget);
	widget = gtk_button_new_from_stock(GTK_STOCK_APPLY);
	g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
				_settings_on_apply), openmoko);
	gtk_container_add(GTK_CONTAINER(bbox), widget);
	widget = gtk_button_new_from_stock(GTK_STOCK_OK);
	g_signal_connect_swapped(widget, "clicked", G_CALLBACK(_settings_on_ok),
			openmoko);
	gtk_container_add(GTK_CONTAINER(bbox), widget);
	gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(openmoko->window), vbox);
	_settings_on_cancel(openmoko);
	gtk_widget_show_all(openmoko->window);
}
Ejemplo n.º 22
0
static gboolean
displace_dialog (GimpDrawable *drawable)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *table;
  GtkWidget *spinbutton;
  GtkObject *adj;
  GtkWidget *combo;
  GtkWidget *hbox;
  GtkWidget *frame;
  GtkWidget *wrap;
  GtkWidget *smear;
  GtkWidget *black;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Displace"), PLUG_IN_BINARY,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

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

  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_vbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  preview = gimp_drawable_preview_new (drawable, NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
  gtk_widget_show (preview);
  g_signal_connect_swapped (preview, "invalidated",
                            G_CALLBACK (displace),
                            drawable);

  /*  The main table  */

  table = gtk_table_new (3, 2, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 12);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);

  /*  X options  */
  toggle_x = gtk_check_button_new_with_mnemonic (_("_X displacement:"));
  gtk_table_attach (GTK_TABLE (table), toggle_x, 0, 1, 0, 1,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_x), dvals.do_x);
  gtk_widget_show (toggle_x);

  g_signal_connect (toggle_x, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &dvals.do_x);
  g_signal_connect_swapped (toggle_x, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  spinbutton = gimp_spin_button_new (&adj, dvals.amount_x,
                                     (gint) drawable->width * -2,
                                     drawable->width * 2,
                                     1, 10, 0, 1, 2);
  gtk_table_attach (GTK_TABLE (table), spinbutton, 1, 2, 0, 1,
                    GTK_FILL, GTK_FILL, 0, 0);

  g_signal_connect (adj, "value-changed",
                    G_CALLBACK (gimp_double_adjustment_update),
                    &dvals.amount_x);
  g_signal_connect_swapped (adj, "value-changed",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_widget_set_sensitive (spinbutton, dvals.do_x);
  g_object_set_data (G_OBJECT (toggle_x), "set_sensitive", spinbutton);
  gtk_widget_show (spinbutton);

  combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable);
  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_x,
                              G_CALLBACK (gimp_int_combo_box_get_active),
                              &dvals.displace_map_x);
  g_signal_connect_swapped (combo, "changed",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 0, 1,
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
  gtk_widget_show (combo);

  gtk_widget_set_sensitive (combo, dvals.do_x);
  g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo);

  /*  Y Options  */
  toggle_y = gtk_check_button_new_with_mnemonic (_("_Y displacement:"));
  gtk_table_attach (GTK_TABLE (table), toggle_y, 0, 1, 1, 2,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_y), dvals.do_y);
  gtk_widget_show (toggle_y);

  g_signal_connect (toggle_y, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &dvals.do_y);
  g_signal_connect_swapped (toggle_y, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  spinbutton = gimp_spin_button_new (&adj, dvals.amount_y,
                                     (gint) drawable->height * -2,
                                     drawable->height * 2,
                                     1, 10, 0, 1, 2);
  gtk_table_attach (GTK_TABLE (table), spinbutton, 1, 2, 1, 2,
                    GTK_FILL, GTK_FILL, 0, 0);

  g_signal_connect (adj, "value-changed",
                    G_CALLBACK (gimp_double_adjustment_update),
                    &dvals.amount_y);
  g_signal_connect_swapped (adj, "value-changed",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_widget_set_sensitive (spinbutton, dvals.do_y);
  g_object_set_data (G_OBJECT (toggle_y), "set_sensitive", spinbutton);
  gtk_widget_show (spinbutton);

  combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable);
  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_y,
                              G_CALLBACK (gimp_int_combo_box_get_active),
                              &dvals.displace_map_y);
  g_signal_connect_swapped (combo, "changed",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 1, 2,
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
  gtk_widget_show (combo);

  gtk_widget_set_sensitive (combo, dvals.do_y);
  g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo);

  hbox = gtk_hbox_new (FALSE, 24);
  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  frame = gimp_int_radio_group_new (TRUE, _("Displacement Mode"),
                                    G_CALLBACK (displace_radio_update),
                                    &dvals.mode, dvals.mode,
                                    _("_Cartesian"), CARTESIAN_MODE, NULL,
                                    _("_Polar"),     POLAR_MODE,     NULL,
                                    NULL);
  gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
  gtk_widget_show  (frame);

  frame = gimp_int_radio_group_new (TRUE, _("Edge Behavior"),
                                    G_CALLBACK (gimp_radio_button_update),
                                    &dvals.displace_type, dvals.displace_type,

                                    _("_Wrap"),  GIMP_PIXEL_FETCHER_EDGE_WRAP,
                                    &wrap,
                                    _("_Smear"), GIMP_PIXEL_FETCHER_EDGE_SMEAR,
                                    &smear,
                                    _("_Black"), GIMP_PIXEL_FETCHER_EDGE_BLACK,
                                    &black,

                                    NULL);
  gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
  gtk_widget_show  (frame);

  g_signal_connect_swapped (wrap, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);
  g_signal_connect_swapped (smear, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);
  g_signal_connect_swapped (black, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);
  displace_set_labels ();

  gtk_widget_show (table);
  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
Ejemplo n.º 23
0
int main( int argc, char *argv[])
{

  GtkWidget *window;
  GtkWidget *table;

  GtkWidget *title;
  GtkWidget *activate;
  GtkWidget *halign;
  GtkWidget *halign2;

  GtkWidget *valign;
  GtkWidget *close;
  GtkWidget *wins;

  GtkWidget *help;
  GtkWidget *ok;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_widget_set_size_request (window, 300, 250);
  gtk_window_set_resizable(GTK_WINDOW(window), FALSE);

  gtk_window_set_title(GTK_WINDOW(window), "Windows");

  gtk_container_set_border_width(GTK_CONTAINER(window), 15);

  table = gtk_table_new(8, 4, FALSE);
  gtk_table_set_col_spacings(GTK_TABLE(table), 3);

  title = gtk_label_new("Windows");
  halign = gtk_alignment_new(0, 0, 0, 0);
  gtk_container_add(GTK_CONTAINER(halign), title);
  gtk_table_attach(GTK_TABLE(table), halign, 0, 1, 0, 1, 
      GTK_FILL, GTK_FILL, 0, 0);

  wins = gtk_text_view_new();
  gtk_text_view_set_editable(GTK_TEXT_VIEW(wins), FALSE);
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(wins), FALSE);
  gtk_table_attach(GTK_TABLE(table), wins, 0, 2, 1, 3,
      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 1, 1);

  activate = gtk_button_new_with_label("Activate");
  gtk_widget_set_size_request(activate, 50, 30);
  gtk_table_attach(GTK_TABLE(table), activate, 3, 4, 1, 2, 
      GTK_FILL, GTK_SHRINK, 1, 1);

  valign = gtk_alignment_new(0, 0, 0, 0);
  close = gtk_button_new_with_label("Close");
 
  gtk_widget_set_size_request(close, 70, 30);
  gtk_container_add(GTK_CONTAINER(valign), close);
  gtk_table_set_row_spacing(GTK_TABLE(table), 1, 3);
  gtk_table_attach(GTK_TABLE(table), valign, 3, 4, 2, 3, 
      GTK_FILL, GTK_FILL | GTK_EXPAND, 1, 1);

  halign2 = gtk_alignment_new(0, 1, 0, 0);
  help = gtk_button_new_with_label("Help");
  gtk_container_add(GTK_CONTAINER(halign2), help);
  gtk_widget_set_size_request(help, 70, 30);
  gtk_table_set_row_spacing(GTK_TABLE(table), 3, 6);
  gtk_table_attach(GTK_TABLE(table), halign2, 0, 1, 4, 5, 
      GTK_FILL, GTK_FILL, 0, 0);

  ok = gtk_button_new_with_label("OK");
  gtk_widget_set_size_request(ok, 70, 30);
  gtk_table_attach(GTK_TABLE(table), ok, 3, 4, 4, 5, 
      GTK_FILL, GTK_FILL, 0, 0);

  gtk_container_add(GTK_CONTAINER(window), table);

  g_signal_connect_swapped(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), G_OBJECT(window));

  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}
Ejemplo n.º 24
0
void gui_init(dt_lib_module_t *self)
{
  /* initialize ui widgets */
  dt_lib_tool_filter_t *d = (dt_lib_tool_filter_t *)g_malloc0(sizeof(dt_lib_tool_filter_t));
  self->data = (void *)d;

  self->widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);

  /**/
  GtkWidget *widget;

  /* list label */
  widget = gtk_label_new(_("view"));
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 4);

  d->comparator = widget = gtk_toggle_button_new_with_label(comparators[dt_collection_get_rating_comparator(darktable.collection)]);
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 4);
  g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(_lib_filter_compare_button_changed),
                   (gpointer)self);
  gtk_widget_add_events(widget, GDK_SCROLL_MASK);
  g_signal_connect(G_OBJECT(widget), "scroll-event", G_CALLBACK(_comparator_scolled), self);

  /* create the filter combobox */
  d->filter = widget = gtk_combo_box_text_new();
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0);
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("all"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("unstarred only"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★ ★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★ ★ ★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("rejected only"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("all except rejected"));

  /* select the last selected value */
  gtk_combo_box_set_active(GTK_COMBO_BOX(widget), dt_collection_get_rating(darktable.collection));

  g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(_lib_filter_combobox_changed), (gpointer)self);

  /* sort by label */
  widget = gtk_label_new(_("sort by"));
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 4);

  /* sort combobox */
  d->sort = widget = gtk_combo_box_text_new();
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0);
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("filename"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("time"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("rating"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("id"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("color label"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("group"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("full path"));

  /* select the last selected value */
  gtk_combo_box_set_active(GTK_COMBO_BOX(widget), dt_collection_get_sort_field(darktable.collection));

  g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(_lib_filter_sort_combobox_changed), (gpointer)self);

  /* reverse order checkbutton */
  d->reverse = widget
      = dtgtk_togglebutton_new(dtgtk_cairo_paint_solid_arrow, CPF_DO_NOT_USE_BORDER | CPF_STYLE_BOX | CPF_DIRECTION_UP);
  if(darktable.collection->params.descending)
    dtgtk_togglebutton_set_paint(DTGTK_TOGGLEBUTTON(widget), dtgtk_cairo_paint_solid_arrow,
                                 CPF_DO_NOT_USE_BORDER | CPF_STYLE_BOX | CPF_DIRECTION_DOWN);

  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0);

  /* select the last value and connect callback */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
                               dt_collection_get_sort_descending(darktable.collection));

  g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(_lib_filter_reverse_button_changed),
                   (gpointer)self);

  /* initialize proxy */
  darktable.view_manager->proxy.filter.module = self;
  darktable.view_manager->proxy.filter.reset_filter = _lib_filter_reset;

  g_signal_connect_swapped(G_OBJECT(d->comparator), "map",
                           G_CALLBACK(_lib_filter_sync_combobox_and_comparator), self);
}
Ejemplo n.º 25
0
static gboolean
sobel_dialog (GimpDrawable *drawable)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *preview;
  GtkWidget *toggle;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Sobel Edge Detection"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

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

  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  preview = gimp_drawable_preview_new (drawable, NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
  gtk_widget_show (preview);

  g_signal_connect (preview, "invalidated",
                    G_CALLBACK (sobel_preview_update),
                    NULL);

  toggle = gtk_check_button_new_with_mnemonic (_("Sobel _horizontally"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), bvals.horizontal);
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &bvals.horizontal);
  g_signal_connect_swapped (toggle, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  toggle = gtk_check_button_new_with_mnemonic (_("Sobel _vertically"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), bvals.vertical);
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &bvals.vertical);
  g_signal_connect_swapped (toggle, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  toggle = gtk_check_button_new_with_mnemonic (_("_Keep sign of result "
                                                 "(one direction only)"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), bvals.keep_sign);
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &bvals.keep_sign);
  g_signal_connect_swapped (toggle, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
Ejemplo n.º 26
0
void _camera_import_dialog_run(_camera_import_dialog_t *data)
{
  gtk_widget_show_all(data->dialog);

  // Populate store

  // Setup a listener for previews of all files on camera
  // then initiate fetch of all previews from camera
  if(data->params->camera!=NULL)
  {
    /* setup a camctl listener */
    dt_camctl_listener_t listener= {0};
    listener.data=data;
    listener.control_status=_control_status;
    listener.camera_storage_image_filename=_camera_storage_image_filename;

    dt_job_t job;
    dt_camera_get_previews_job_init(&job,data->params->camera, &listener, CAMCTL_IMAGE_PREVIEW_DATA);
    dt_control_job_set_state_callback(&job,_preview_job_state_changed,data);
    dt_control_add_job(darktable.control, &job);
  }
  else
    return;

  // Lets run dialog
  gtk_label_set_text(GTK_LABEL(data->import.info),_("select the images from the list below that you want to import into a new filmroll"));
  gboolean all_good=FALSE;
  g_signal_connect(G_OBJECT(data->dialog),"delete-event",G_CALLBACK(_dialog_close),data);
  while(!all_good)
  {
    gint result = gtk_dialog_run (GTK_DIALOG (data->dialog));
    if( result == GTK_RESPONSE_ACCEPT)
    {
      GtkTreeIter iter;
      all_good=TRUE;
      GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtk_bin_get_child(GTK_BIN(data->import.treeview))));
      // Now build up result from store into GList **result
      if(data->params->result)
        g_list_free(data->params->result);
      data->params->result=NULL;
      GtkTreeModel *model=GTK_TREE_MODEL(data->store);
      GList *sp= gtk_tree_selection_get_selected_rows(selection,&model);
      if( sp )
      {
        do
        {
          GValue value = { 0, };
          gtk_tree_model_get_iter(GTK_TREE_MODEL (data->store),&iter,(GtkTreePath*)sp->data);
          gtk_tree_model_get_value(GTK_TREE_MODEL (data->store),&iter,1,&value);
          if (G_VALUE_HOLDS_STRING (&value))
            data->params->result = g_list_append(data->params->result,g_strdup(g_value_get_string(&value)) );
        }
        while( (sp=g_list_next(sp)) );
      }

      // Lets check jobcode, basedir etc..
      data->params->jobcode = data->import.jobname->value;
      data->params->basedirectory = data->settings.basedirectory->value;
      data->params->subdirectory = data->settings.subdirectory->value;
      data->params->filenamepattern = data->settings.namepattern->value;

      data->params->time_override = 0;
      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->settings.general.date_override)))
        data->params->time_override = parse_date_time(gtk_entry_get_text(GTK_ENTRY(data->settings.general.date_entry)));

      if( data->params->jobcode == NULL || strlen(data->params->jobcode) <=0 )
        data->params->jobcode = dt_conf_get_string("plugins/capture/camera/import/jobcode");

      if( data->params->basedirectory == NULL || strlen( data->params->basedirectory ) <= 0 )
      {
        GtkWidget *dialog=gtk_message_dialog_new(NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("please set the basedirectory settings before importing"));
        g_signal_connect_swapped (dialog, "response",G_CALLBACK (gtk_widget_destroy),dialog);
        gtk_dialog_run (GTK_DIALOG (dialog));
        all_good=FALSE;
      }
      else if( data->params->subdirectory == NULL || strlen( data->params->subdirectory ) <= 0 )
      {
        GtkWidget *dialog=gtk_message_dialog_new(NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("please set the subdirectory settings before importing"));
        g_signal_connect_swapped (dialog, "response",G_CALLBACK (gtk_widget_destroy),dialog);
        gtk_dialog_run (GTK_DIALOG (dialog));
        all_good=FALSE;
      }
      else if( data->params->filenamepattern == NULL || strlen( data->params->filenamepattern ) <= 0 )
      {
        GtkWidget *dialog=gtk_message_dialog_new(NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("please set the filenamepattern settings before importing"));
        g_signal_connect_swapped (dialog, "response",G_CALLBACK (gtk_widget_destroy),dialog);
        gtk_dialog_run (GTK_DIALOG (dialog));
        all_good=FALSE;
      }
      else if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->settings.general.date_override)) && data->params->time_override == 0)
      {
        GtkWidget *dialog=gtk_message_dialog_new(NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("please use YYYY-MM-DD format for date override"));
        g_signal_connect_swapped (dialog, "response",G_CALLBACK (gtk_widget_destroy),dialog);
        gtk_dialog_run (GTK_DIALOG (dialog));
        all_good=FALSE;
      }
    }
    else
    {
      data->params->result=NULL;
      all_good=TRUE;
    }
  }

  // Destroy and quit
  gtk_widget_destroy (data->dialog);
}
Ejemplo n.º 27
0
void create_bill_window (){

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(window), 500, 270);
	gtk_window_set_title(GTK_WINDOW(window), "Bill");
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);

	vbox = gtk_vbox_new(FALSE, 1);  // hama kotuwakma 1ka =i ,true dapuwama
	gtk_box_set_spacing (GTK_BOX(vbox), 5);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	header_label = gtk_label_new("Bill");
	gtk_box_pack_start(GTK_BOX(vbox), header_label, FALSE, FALSE, 0);//
	/////////
	layout = gtk_table_new(6, 2, FALSE);//
	gtk_table_set_row_spacings(GTK_TABLE(layout), 5);
	gtk_table_set_col_spacings(GTK_TABLE(layout), 5);

	job_bill_id_label = gtk_label_new("Bill ID : ");
	job_bill_id_txt = gtk_entry_new(); 

	date_label = gtk_label_new("Date : ");
	date_txt = gtk_entry_new(); 

	bus_reg_no_label = gtk_label_new("Bus RegNo : ");
	bus_reg_no_txt = gtk_entry_new();

	maintenance_discription_label = gtk_label_new("Maintenance Discription : ");
	maintenance_discription_txt = gtk_entry_new();


	total_label = gtk_label_new("Total : ");
	total_txt = gtk_entry_new(); 

	who_signed_label = gtk_label_new("Signed By : ");
	who_signed_txt = gtk_entry_new(); 


	gtk_misc_set_alignment (GTK_MISC (job_bill_id_label), 1, 0.5);
	gtk_misc_set_alignment (GTK_MISC (date_label), 1, 0.5);
	gtk_misc_set_alignment (GTK_MISC (bus_reg_no_label), 1, 0.5);
	gtk_misc_set_alignment (GTK_MISC (maintenance_discription_label), 1, 0.5);
	gtk_misc_set_alignment (GTK_MISC (total_label), 1, 0.5);
	gtk_misc_set_alignment (GTK_MISC (who_signed_label), 1, 0.5);


	gtk_table_attach (GTK_TABLE(layout), job_bill_id_label,0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	gtk_table_attach_defaults (GTK_TABLE(layout), job_bill_id_txt, 1, 2, 0, 1);

	gtk_table_attach (GTK_TABLE(layout), date_label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	gtk_table_attach_defaults (GTK_TABLE(layout), date_txt, 1, 2, 1, 2);

	gtk_table_attach (GTK_TABLE(layout), bus_reg_no_label, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	gtk_table_attach_defaults (GTK_TABLE(layout), bus_reg_no_txt, 1, 2, 2, 3);

	gtk_table_attach (GTK_TABLE(layout), maintenance_discription_label, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	gtk_table_attach_defaults (GTK_TABLE(layout), maintenance_discription_txt, 1, 2, 3, 4);

	gtk_table_attach (GTK_TABLE(layout), total_label, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	gtk_table_attach_defaults (GTK_TABLE(layout), total_txt, 1, 2, 4, 5);

	gtk_table_attach (GTK_TABLE(layout), who_signed_label, 0, 1, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	gtk_table_attach_defaults (GTK_TABLE(layout), who_signed_txt, 1, 2, 5, 6);



	//gtk_box_pack_start(GTK_BOX(vbox), layout, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(vbox), layout, FALSE, FALSE, 0);
	/////////

	////////////////////

	hbox = gtk_hbox_new (FALSE, 5);
	clear_button = gtk_button_new_with_label ("Clear");
	gtk_widget_set_size_request (clear_button, 100, 30);
	ok_button = gtk_button_new_with_label ("Ok");
	gtk_widget_set_size_request (ok_button, 100, 30);
	cancel_button = gtk_button_new_with_label ("Cancel");
	gtk_widget_set_size_request (cancel_button, 100, 30);

	gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
	gtk_box_pack_end(GTK_BOX(hbox), cancel_button, FALSE, FALSE, 0);
	gtk_box_pack_end(GTK_BOX(hbox), ok_button, FALSE, FALSE, 0);

	gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);


	g_signal_connect_swapped(G_OBJECT(window), "destroy",
			G_CALLBACK(gtk_widget_destroy), G_OBJECT(window));

	gtk_widget_show_all(window);

}
static gboolean
edit_connection_parameters (GoaObject  *goa_object,
                            GtkWindow  *parent,
                            GError    **out_error)
{
  GMainLoop *loop = NULL;
  TpAccount *tp_account = NULL;
  TpawAccountSettings *settings = NULL;
  GtkWidget *dialog = NULL;
  TpawAccountWidget *account_widget = NULL;
  GtkWidget *content_area = NULL;
  gboolean ret;
  GError *error = NULL;

  loop = g_main_loop_new (NULL, FALSE);

  tp_account = find_tp_account (goa_object, loop, &error);
  if (tp_account == NULL)
    goto out;

  settings = tpaw_account_settings_new_for_account (tp_account);
  wait_for_account_settings_ready (settings, loop);

  dialog = gtk_dialog_new_with_buttons (_("Connection Settings"),
      parent,
      GTK_DIALOG_MODAL
      | GTK_DIALOG_DESTROY_WITH_PARENT
      | GTK_DIALOG_USE_HEADER_BAR,
      NULL, NULL);
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

  account_widget = tpaw_account_widget_new_for_protocol (settings,
      GTK_DIALOG (dialog), FALSE);
  gtk_widget_set_margin_end (GTK_WIDGET (account_widget), 6);
  gtk_widget_set_margin_start (GTK_WIDGET (account_widget), 6);
  gtk_widget_set_margin_top (GTK_WIDGET (account_widget), 6);
  g_signal_connect (account_widget, "cancelled",
      G_CALLBACK (account_dialog_widget_cancelled_cb), &error);
  g_signal_connect_swapped (account_widget, "close",
      G_CALLBACK (g_main_loop_quit), loop);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_box_pack_start (GTK_BOX (content_area), GTK_WIDGET (account_widget),
      TRUE, TRUE, 0);

  gtk_widget_show (GTK_WIDGET (account_widget));
  gtk_widget_show (dialog);

  /* Wait for the dialog to be dismissed */
  g_main_loop_run (loop);

  gtk_widget_destroy (dialog);

out:
  if (error != NULL)
    {
      g_propagate_error (out_error, error);
      ret = FALSE;
    }
  else
    {
      ret = TRUE;
    }

  g_clear_object (&settings);
  g_clear_object (&tp_account);
  g_clear_pointer (&loop, g_main_loop_unref);

  return ret;
}
Ejemplo n.º 29
0
static void
pragha_application_startup (GApplication *application)
{
    PraghaToolbar *toolbar;
    PraghaPlaylist *playlist;
    const gchar *version = NULL;

    const GBindingFlags binding_flags =
        G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL;

    PraghaApplication *pragha = PRAGHA_APPLICATION (application);

    G_APPLICATION_CLASS (pragha_application_parent_class)->startup (application);

    /* Allocate memory for simple structures */

    pragha->preferences = pragha_preferences_get();

    pragha->cdbase = pragha_database_get();
    if (pragha_database_start_successfully(pragha->cdbase) == FALSE) {
        g_error("Unable to init music dbase");
    }

    version = pragha_preferences_get_installed_version (pragha->preferences);
    if (string_is_not_empty (version) && (g_ascii_strcasecmp (version, "1.3.1") < 0)) {
        pragha_database_compatibilize_version (pragha->cdbase);
    }

    pragha->enum_map = pragha_music_enum_get ();
    g_signal_connect (pragha->enum_map, "enum-removed",
                      G_CALLBACK(pragha_enum_map_removed_handler), pragha);

#ifdef HAVE_LIBPEAS
    pragha->plugins_engine = pragha_plugins_engine_new (pragha);
#endif

    pragha->art_cache = pragha_art_cache_get ();
    g_signal_connect (pragha->art_cache, "cache-changed",
                      G_CALLBACK(pragha_art_cache_changed_handler), pragha);

    pragha->backend = pragha_backend_new ();

    g_signal_connect (pragha->backend, "finished",
                      G_CALLBACK(pragha_backend_finished_song), pragha);
    g_signal_connect (pragha->backend, "tags-changed",
                      G_CALLBACK(pragha_backend_tags_changed), pragha);

    g_signal_connect (pragha->backend, "error",
                      G_CALLBACK(gui_backend_error_show_dialog_cb), pragha);
    g_signal_connect (pragha->backend, "error",
                      G_CALLBACK(gui_backend_error_update_current_playlist_cb), pragha);
    g_signal_connect (pragha->backend, "notify::state",
                      G_CALLBACK (pragha_menubar_update_playback_state_cb), pragha);

    /*
     * Collect widgets and construct the window.
     */

    pragha_application_construct_window (pragha);

    /* Connect Signals and Bindings. */

    toolbar = pragha->toolbar;
    g_signal_connect_swapped (toolbar, "prev",
                              G_CALLBACK(pragha_playback_prev_track), pragha);
    g_signal_connect_swapped (toolbar, "play",
                              G_CALLBACK(pragha_playback_play_pause_resume), pragha);
    g_signal_connect_swapped (toolbar, "stop",
                              G_CALLBACK(pragha_playback_stop), pragha);
    g_signal_connect_swapped (toolbar, "next",
                              G_CALLBACK(pragha_playback_next_track), pragha);
    g_signal_connect (toolbar, "unfull-activated",
                      G_CALLBACK(pragha_window_unfullscreen), pragha);
    g_signal_connect (toolbar, "album-art-activated",
                      G_CALLBACK(pragha_playback_show_current_album_art), pragha);
    g_signal_connect (toolbar, "track-info-activated",
                      G_CALLBACK(pragha_playback_edit_current_track), pragha);
    g_signal_connect (toolbar, "track-progress-activated",
                      G_CALLBACK(pragha_playback_seek_fraction), pragha);

    playlist = pragha->playlist;
    g_signal_connect (playlist, "playlist-set-track",
                      G_CALLBACK(pragha_playback_set_playlist_track), pragha);
    g_signal_connect (playlist, "playlist-change-tags",
                      G_CALLBACK(pragha_playlist_update_change_tags), pragha);
    g_signal_connect (playlist, "playlist-changed",
                      G_CALLBACK(pragha_playlist_update_statusbar_playtime), pragha);
    pragha_playlist_update_statusbar_playtime (playlist, pragha);

    g_signal_connect (pragha->library, "library-append-playlist",
                      G_CALLBACK(pragha_library_pane_append_tracks), pragha);
    g_signal_connect (pragha->library, "library-replace-playlist",
                      G_CALLBACK(pragha_library_pane_replace_tracks), pragha);
    g_signal_connect (pragha->library, "library-replace-playlist-and-play",
                      G_CALLBACK(pragha_library_pane_replace_tracks_and_play), pragha);

    g_signal_connect (G_OBJECT(pragha->mainwindow), "window-state-event",
                      G_CALLBACK(pragha_toolbar_window_state_event), toolbar);
    g_signal_connect (G_OBJECT(toolbar), "notify::timer-remaining-mode",
                      G_CALLBACK(pragha_toolbar_show_ramaning_time_cb), pragha->backend);

    g_signal_connect (pragha->backend, "notify::state",
                      G_CALLBACK(pragha_toolbar_playback_state_cb), toolbar);
    g_signal_connect (pragha->backend, "tick",
                      G_CALLBACK(pragha_toolbar_update_playback_progress), toolbar);
    g_signal_connect (pragha->backend, "buffering",
                      G_CALLBACK(pragha_toolbar_update_buffering_cb), toolbar);

    g_signal_connect (pragha->backend, "notify::state",
                      G_CALLBACK (update_current_playlist_view_playback_state_cb), pragha->playlist);

    g_object_bind_property (pragha->backend, "volume",
                            toolbar, "volume",
                            binding_flags);

    g_object_bind_property (pragha->preferences, "timer-remaining-mode",
                            toolbar, "timer-remaining-mode",
                            binding_flags);

    pragha->sidebar2_binding =
        g_object_bind_property (pragha->preferences, "secondary-lateral-panel",
                                pragha->sidebar2, "visible",
                                binding_flags);

    pragha->setting_dialog = pragha_preferences_dialog_new (pragha);

#ifdef HAVE_LIBPEAS
    pragha_plugins_engine_startup (pragha->plugins_engine);
#endif

    /* Finally fill the library and the playlist */

    pragha_init_gui_state (pragha);
}
Ejemplo n.º 30
0
/**
 * \fn void dialog_simulator_create()
 * \brief Function to create the main window.
 */
void
dialog_simulator_create ()
{
  static char *str_exit, *str_options, *str_start, *str_stop, *str_save,
    *str_help;
  static char *tip_exit, *tip_options, *tip_start, *tip_stop, *tip_save,
    *tip_help;
  DialogSimulator *dlg;

#if DEBUG
  printf ("dialog_simulator_create: start\n");
#endif

  dlg = dialog_simulator;
#if HAVE_SDL
  exit_event->type = SDL_QUIT;
#endif

  str_options = gettext ("_Options");
  str_start = gettext ("S_tart");
  str_stop = gettext ("Sto_p");
  str_save = gettext ("_Save");
  str_help = gettext ("_Help");
  str_exit = gettext ("E_xit");
  tip_options = gettext ("Fractal options");
  tip_start = gettext ("Start fractal growing");
  tip_stop = gettext ("Stop fractal growing");
  tip_save = gettext ("Save graphical");
  tip_help = gettext ("Help");
  tip_exit = gettext ("Exit");

  dlg->toolbar = (GtkToolbar *) gtk_toolbar_new ();

  dlg->button_options = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("preferences-system", GTK_ICON_SIZE_SMALL_TOOLBAR), str_options);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_options), tip_options);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_options), -1);
  g_signal_connect
    (dlg->button_options, "clicked", dialog_options_create, NULL);

  dlg->button_start = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("system-run", GTK_ICON_SIZE_SMALL_TOOLBAR), str_start);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_start), tip_start);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_start), -1);
  g_signal_connect (dlg->button_start, "clicked", fractal, NULL);

  dlg->button_stop = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("process-stop", GTK_ICON_SIZE_SMALL_TOOLBAR), str_stop);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_stop), tip_stop);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_stop), -1);
  g_signal_connect (dlg->button_stop, "clicked", fractal_stop, NULL);

  dlg->button_save = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("document-save", GTK_ICON_SIZE_SMALL_TOOLBAR), str_save);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_save), tip_save);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_save), -1);
  g_signal_connect (dlg->button_save, "clicked", dialog_simulator_save, NULL);

  dlg->button_help = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("help-about", GTK_ICON_SIZE_SMALL_TOOLBAR), str_help);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_help), tip_help);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_help), -1);
  g_signal_connect (dlg->button_help, "clicked", dialog_simulator_help, NULL);

  dlg->button_exit = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("application-exit", GTK_ICON_SIZE_SMALL_TOOLBAR), str_exit);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_exit), tip_exit);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_exit), -1);
#if HAVE_FREEGLUT
  g_signal_connect (dlg->button_exit, "clicked", glutLeaveMainLoop, NULL);
#elif HAVE_SDL
  g_signal_connect_swapped (dlg->button_exit, "clicked",
                            (void (*)) SDL_PushEvent, exit_event);
#elif HAVE_GLFW
  g_signal_connect (dlg->button_exit, "clicked", (void (*)) window_close, NULL);
#endif

  dlg->label_time = (GtkLabel *) gtk_label_new (gettext ("Calculating time"));
  dlg->entry_time =
    (GtkSpinButton *) gtk_spin_button_new_with_range (0., 1.e6, 0.1);
  gtk_widget_set_sensitive (GTK_WIDGET (dlg->entry_time), 0);

  dlg->progress = (GtkProgressBar *) gtk_progress_bar_new ();
  gtk_progress_bar_set_text (dlg->progress, gettext ("Progress"));

  dlg->hscale = (GtkScale *) gtk_scale_new_with_range
    (GTK_ORIENTATION_HORIZONTAL, -90., 0., 1.);
  dlg->vscale = (GtkScale *) gtk_scale_new_with_range
    (GTK_ORIENTATION_HORIZONTAL, 0., 90., 1.);
  gtk_scale_set_digits (dlg->hscale, 0);
  gtk_scale_set_digits (dlg->vscale, 0);
  gtk_range_set_value (GTK_RANGE (dlg->hscale), phid);
  gtk_range_set_value (GTK_RANGE (dlg->vscale), thetad);
  g_signal_connect (dlg->hscale, "value-changed", set_perspective, NULL);
  g_signal_connect (dlg->vscale, "value-changed", set_perspective, NULL);

  dlg->label_horizontal = (GtkLabel *) gtk_label_new
    (gettext ("Horizontal perspective angle (º)"));
  dlg->label_vertical = (GtkLabel *) gtk_label_new
    (gettext ("Vertical perspective angle (º)"));

  dlg->grid = (GtkGrid *) gtk_grid_new ();
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->toolbar), 0, 0, 3, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->progress), 0, 1, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->label_time), 1, 1, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->entry_time), 2, 1, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->label_horizontal), 0, 2, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->hscale), 1, 2, 2, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->label_vertical), 0, 3, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->vscale), 1, 3, 2, 1);

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

  dlg->window = (GtkWindow *) gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (dlg->window, gettext ("Fractal growing"));
  gtk_window_set_icon (dlg->window, dlg->logo_min);
  gtk_container_add (GTK_CONTAINER (dlg->window), GTK_WIDGET (dlg->grid));
  gtk_widget_show_all (GTK_WIDGET (dlg->window));
#if HAVE_FREEGLUT
  g_signal_connect (dlg->window, "delete_event", glutLeaveMainLoop, NULL);
#elif HAVE_SDL
  g_signal_connect_swapped (dlg->window, "delete_event",
                            (void (*)) SDL_PushEvent, exit_event);
#elif HAVE_GLFW
  g_signal_connect (dlg->window, "delete_event", (void (*)) window_close, NULL);
#endif

  set_perspective ();
  dialog_simulator_update ();
#if DEBUG
  printf ("dialog_simulator_create: end\n");
#endif
}