void
dialog_goto_cell (WBCGtk *wbcg)
{
	GotoState* state;
	GtkBuilder *gui;

	g_return_if_fail (wbcg != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, GOTO_KEY))
		return;
	gui = gnm_gtk_builder_new ("goto.ui", NULL, GO_CMD_CONTEXT (wbcg));
        if (gui == NULL)
                return;

	state = g_new (GotoState, 1);
	state->wbcg   = wbcg;
	state->wb     = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
	state->gui    = gui;
        state->dialog = go_gtk_builder_get_widget (state->gui, "goto_dialog");

	if (dialog_goto_init (state)) {
		go_gtk_notice_dialog (wbcg_toplevel (wbcg), GTK_MESSAGE_ERROR,
				 _("Could not create the goto dialog."));
		g_free (state);
		return;
	}

	gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
			       GOTO_KEY);

	gtk_widget_show_all (state->dialog);
}
Exemplo n.º 2
0
void
dialog_fill_series (WBCGtk *wbcg)
{
	FillSeriesState *state;
	WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
	SheetView       *sv = wb_control_cur_sheet_view (wbc);

	g_return_if_fail (wbcg != NULL);

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

	state = g_new (FillSeriesState, 1);

	if (dialog_tool_init ((GenericToolState *)state, wbcg, sv_sheet (sv),
			      GNUMERIC_HELP_LINK_FILL_SERIES,
			      "fill-series.ui", "Fill_series",
			      _("Could not create the Fill Series dialog."),
			      FILL_SERIES_KEY,
			      G_CALLBACK (cb_fill_series_ok_clicked), NULL,
			      G_CALLBACK (cb_fill_series_update_sensitivity),
			      0))
		return;

	gnm_dao_set_put (GNM_DAO (state->base.gdao), FALSE, FALSE);
	dialog_fill_series_tool_init (state);
	gtk_widget_show (state->base.dialog);

	return;
}
Exemplo n.º 3
0
/**
 * dialog_advanced_filter:
 * @wbcg:
 * @sheet:
 *
 * Show the dialog (guru).
 *
 **/
void
dialog_advanced_filter (WBCGtk *wbcg)
{
        AdvancedFilterState *state;
	WorkbookControl *wbc;

	g_return_if_fail (wbcg != NULL);

	wbc = WORKBOOK_CONTROL (wbcg);

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

	state = g_new (AdvancedFilterState, 1);

	if (dialog_tool_init (state, wbcg, wb_control_cur_sheet (wbc),
			      GNUMERIC_HELP_LINK_ADVANCED_FILTER,
			      "advanced-filter.ui", "Filter",
			      _("Could not create the Advanced Filter dialog."),
			      ADVANCED_FILTER_KEY,
			      G_CALLBACK (advanced_filter_ok_clicked_cb), NULL,
			      G_CALLBACK (advanced_filter_update_sensitivity_cb),
			      0))
		return;

	gnm_dao_set_inplace (GNM_DAO (state->gdao), _("Filter _in-place"));
	gnm_dao_set_put (GNM_DAO (state->gdao), FALSE, FALSE);
	advanced_filter_update_sensitivity_cb (NULL, state);
	tool_load_selection ((GenericToolState *)state, TRUE);

        return;
}
Exemplo n.º 4
0
void
dialog_scenario_add (WBCGtk *wbcg)
{
        ScenariosState *state;
	WorkbookControl  *wbc;
	GtkWidget        *comment_view;
	char const *error_str = _("Could not create the Scenario Add dialog.");
	GString          *buf;

	if (wbcg == NULL)
		return;

	wbc = WORKBOOK_CONTROL (wbcg);

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

	state = g_new (ScenariosState, 1);

	if (dialog_tool_init (&state->base, wbcg, wb_control_cur_sheet (wbc),
			      GNUMERIC_HELP_LINK_SCENARIOS_ADD,
			      "scenario-add.ui", "ScenarioAdd",
			      error_str,
			      "ScenarioAdd",
			      G_CALLBACK (scenario_add_ok_clicked_cb), NULL,
			      G_CALLBACK (scenario_add_update_sensitivity_cb),
			      GNM_EE_SHEET_OPTIONAL))
	{
		g_free (state);
		return;
	}

	state->name_entry = go_gtk_builder_get_widget (state->base.gui, "name_entry");
	if (state->name_entry == NULL)
	        return;

	comment_view = go_gtk_builder_get_widget (state->base.gui, "comment_view");
	if (comment_view == NULL)
	        return;
	buf = g_string_new (NULL);
	g_string_append_printf (buf, _("Created on "));
	dao_append_date (buf);
	gtk_text_buffer_set_text (gtk_text_view_get_buffer
				  (GTK_TEXT_VIEW (comment_view)), buf->str,
				  strlen (buf->str));
	g_string_free (buf, FALSE);

	state->base.gdao = NULL;

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->base.dialog),
					   wbcg,
					   GNM_DIALOG_DESTROY_SHEET_REMOVED);

	gnumeric_editable_enters (GTK_WINDOW (state->base.dialog),
				  GTK_WIDGET (state->name_entry));
	scenario_add_update_sensitivity_cb (NULL, state);
	tool_load_selection ((GenericToolState *)state, TRUE);
}
Exemplo n.º 5
0
/**
 * dialog_goal_seek:
 * @wbcg:
 * @sheet:
 *
 * Create the dialog (guru).
 *
 **/
void
dialog_goal_seek (WBCGtk *wbcg, Sheet *sheet)
{
        GoalSeekState *state;
	GladeXML *gui;

	g_return_if_fail (IS_SHEET (sheet));

	/* Testing hook.  */
	if (wbcg == NULL) {
		GnmRangeRef *range =
			g_object_get_data (G_OBJECT (sheet), "ssconvert-goal-seek");
		if (range) {
			Sheet *start_sheet, *end_sheet;
			GnmEvalPos ep;
			GnmRange r;

			gnm_rangeref_normalize (range,
						eval_pos_init_sheet (&ep, sheet),
						&start_sheet, &end_sheet,
						&r);
			g_return_if_fail (start_sheet == sheet);

			dialog_goal_seek_test (sheet, &r);
			return;
		}
	}

	g_return_if_fail (wbcg != NULL);

	/* Only pop up one copy per workbook */
	if (gnumeric_dialog_raise_if_exists (wbcg, GOALSEEK_KEY))
		return;
	gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
		"goalseek.glade", NULL, NULL);
        if (gui == NULL)
                return;

	state = g_new (GoalSeekState, 1);
	state->wbcg  = wbcg;
	state->wb    = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
	state->sheet = sheet;
	state->gui   = gui;
	state->warning_dialog = NULL;
	state->cancelled = TRUE;

	if (dialog_init (state)) {
		go_gtk_notice_dialog (wbcg_toplevel (wbcg), GTK_MESSAGE_ERROR,
				 _("Could not create the Goal-Seek dialog."));
		g_free (state);
		return;
	}

	gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
			       GOALSEEK_KEY);

	gtk_widget_show (state->dialog);
}
Exemplo n.º 6
0
void
dialog_about (WBCGtk *wbcg)
{
	GtkWidget *w, *c;
	GList *children;
	AboutState *state;

	if (gnumeric_dialog_raise_if_exists (wbcg, ABOUT_KEY))
		return;

	state = g_new0 (AboutState, 1);

	w = g_object_new (GTK_TYPE_ABOUT_DIALOG,
			  "title", _("About Gnumeric"),
			  "version", GNM_VERSION_FULL,
			  "website", "http://www.gnumeric.org/",
			  "website-label", _("Visit the Gnumeric website"),
			  "logo-icon-name", "gnumeric",
			  "copyright", _("Copyright \xc2\xa9 1998-2014"),
			  "comments", _("Free, Fast, Accurate - Pick Any Three!"),
			  NULL);
	state->dialog = w;

	g_signal_connect (w, "response",
			  G_CALLBACK (gtk_widget_destroy), NULL);
	g_signal_connect_swapped (w, "destroy",
				  G_CALLBACK (free_state), state);

	c = gtk_dialog_get_content_area (GTK_DIALOG (w));
	children = gtk_container_get_children (GTK_CONTAINER (c));

	if (children && GTK_IS_BOX (children->data)) {
		GtkWidget *vbox = children->data;
		int height;
		PangoLayout *layout;

		state->anim_area = gtk_drawing_area_new ();
		layout = gtk_widget_create_pango_layout (state->anim_area, NULL);
		pango_layout_get_pixel_size (layout, NULL, &height);
		gtk_widget_set_size_request (state->anim_area, -1, 4 * height);
		g_object_unref (layout);

		g_signal_connect (state->anim_area, "draw",
				  G_CALLBACK (about_dialog_anim_draw),
				  state);

		gtk_box_pack_end (GTK_BOX (vbox), state->anim_area, TRUE, TRUE, 0);

		create_animation (state);

		state->timer = g_timeout_add (TIME_SLICE, about_dialog_timer, state);
	}
	g_list_free (children);

	gnumeric_keyed_dialog (wbcg, GTK_WINDOW (w), ABOUT_KEY);
	gtk_widget_show_all (w);
}
Exemplo n.º 7
0
void
dialog_col_row (WBCGtk *wbcg,  char const *operation,
		ColRowCallback_t callback,
		gpointer data)
{
	GtkBuilder	*gui;
	ColRowState	*state;

	g_return_if_fail (wbcg != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, COL_ROW_DIALOG_KEY))
		return;
	gui = gnm_gtk_builder_new ("colrow.ui", NULL, GO_CMD_CONTEXT (wbcg));
	if (gui == NULL)
		return;

	state = g_new (ColRowState, 1);
	state->wbcg  = wbcg;
	state->callback = callback;
	state->data = data;
	state->gui = gui;

	state->dialog = go_gtk_builder_get_widget (state->gui, "dialog");

	state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button");
	g_signal_connect (G_OBJECT (state->ok_button),
		"clicked",
		G_CALLBACK (cb_dialog_col_row_ok_clicked), state);

	state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button");
	g_signal_connect (G_OBJECT (state->cancel_button),
		"clicked",
		G_CALLBACK (cb_dialog_col_row_cancel_clicked), state);

	gnumeric_init_help_button (
		go_gtk_builder_get_widget (state->gui, "help_button"),
		GNUMERIC_HELP_LINK_GROUP_UNGROUP);

	gtk_window_set_title (GTK_WINDOW (state->dialog), operation);

	wbc_gtk_attach_guru (state->wbcg, state->dialog);
	g_object_set_data_full (G_OBJECT (state->dialog),
		"state", state, (GDestroyNotify) cb_dialog_col_row_destroy);

	gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
			       COL_ROW_DIALOG_KEY);
	gtk_widget_show (state->dialog);
}
Exemplo n.º 8
0
/**
 * dialog_shuffle:
 * @wbcg:
 * @sheet:
 *
 * Show the dialog (guru).
 *
 **/
void
dialog_shuffle (WBCGtk *wbcg)
{
        ShuffleState    *state;
	WorkbookControl *wbc;
	GtkWidget *w;
	char const *type;
	GnmRange const *r;

	g_return_if_fail (wbcg != NULL);

	wbc = WORKBOOK_CONTROL (wbcg);

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

	state = g_new (ShuffleState, 1);

	if (dialog_tool_init (state, wbcg, wb_control_cur_sheet (wbc),
			      GNUMERIC_HELP_LINK_DATA_SHUFFLE,
			      "shuffle.ui", "Shuffling",
			      _("Could not create the Data Shuffling dialog."),
			      SHUFFLE_KEY,
			      G_CALLBACK (shuffle_ok_clicked_cb), NULL,
			      G_CALLBACK (shuffle_update_sensitivity_cb),
			      0))
		return;

	shuffle_update_sensitivity_cb (NULL, state);
	state->gdao = NULL;
	tool_load_selection ((GenericToolState *)state, FALSE);

	r = selection_first_range (state->sv, NULL, NULL);
	if (range_width (r) == 1)
		type = "shuffle_cols";
	else if (range_height (r) == 1)
		type = "shuffle_rows";
	else
		type = "shuffle_area";
	w = go_gtk_builder_get_widget (state->gui, type);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

	gtk_widget_show (state->dialog);

        return;
}
Exemplo n.º 9
0
void
dialog_so_list (WBCGtk *wbcg, GObject *so)
{
	GnmDialogSOList *state;

	g_return_if_fail (wbcg != NULL);

	if (wbc_gtk_get_guru (wbcg) ||
	    gnumeric_dialog_raise_if_exists (wbcg, DIALOG_SO_LIST_KEY))
		return;

	state = g_new0 (GnmDialogSOList, 1);
	if (so_list_init (state, wbcg, SHEET_OBJECT (so))) {
		go_gtk_notice_dialog (wbcg_toplevel (wbcg), GTK_MESSAGE_ERROR,
			_("Could not create the List Property dialog."));
		g_free (state);
	}
}
Exemplo n.º 10
0
void
dialog_data_table (WBCGtk *wbcg)
{
	GnmDialogDataTable *state;
	GnmRange const	*r;
	GnmRange	 input_range;
	SheetView	*sv;
	Sheet		*sheet;

	g_return_if_fail (wbcg != NULL);

	if (wbc_gtk_get_guru (wbcg) ||
	    gnumeric_dialog_raise_if_exists (wbcg, DIALOG_DATA_TABLE_KEY))
		return;

	sv = wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg));
	r = selection_first_range (sv, GO_CMD_CONTEXT (wbcg), _("Create Data Table"));
	if (NULL == r)
		return;
	if (range_width	(r) <= 1 || range_height (r) <= 1) {
		GError *msg = g_error_new (go_error_invalid(), 0,
			_("The selection must have more than 1 column and row to create a Data Table."));
		go_cmd_context_error (GO_CMD_CONTEXT (wbcg), msg);
		g_error_free (msg);
		return;
	}
	input_range = *r;
	input_range.start.col++;
	input_range.start.row++;
	sheet = sv_sheet (sv);
	if (sheet_range_splits_region (sheet, &input_range, NULL,
				       GO_CMD_CONTEXT (wbcg), _("Data Table")))
		return;

	state = g_new0 (GnmDialogDataTable, 1);
	state->wbcg  = wbcg;
	state->sheet = sheet;
	state->input_range = input_range;
	if (data_table_init (state, wbcg)) {
		go_gtk_notice_dialog (wbcg_toplevel (wbcg), GTK_MESSAGE_ERROR,
			_("Could not create the Data Table definition dialog."));
		g_free (state);
	}
}
Exemplo n.º 11
0
/*
 * Main entry point for the Cell Sort dialog box
 */
void
dialog_cell_sort (WBCGtk *wbcg)
{
	SortFlowState *state;
	GtkBuilder *gui;

	g_return_if_fail (wbcg != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, CELL_SORT_KEY))
		return;

	gui = gnm_gtk_builder_new ("cell-sort.ui", NULL, GO_CMD_CONTEXT (wbcg));
    if (gui == NULL)
            return;

	state = g_new (SortFlowState, 1);
	state->wbcg  = wbcg;
	state->wb    = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
	state->sv    = wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg));
	state->sheet = sv_sheet (state->sv);
	state->warning_dialog = NULL;
	state->sel = NULL;
	state->sort_items = 0;
	state->gui = gui;
        state->dialog = go_gtk_builder_get_widget (state->gui, "CellSort");

	state->image_ascending =
		gtk_widget_render_icon_pixbuf (state->dialog,
					GTK_STOCK_SORT_ASCENDING,
					GTK_ICON_SIZE_LARGE_TOOLBAR);
	state->image_descending =
		gtk_widget_render_icon_pixbuf (state->dialog,
					GTK_STOCK_SORT_DESCENDING,
					GTK_ICON_SIZE_LARGE_TOOLBAR);
	dialog_init (state);

	gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
			       CELL_SORT_KEY);

	gtk_widget_show (state->dialog);
}
Exemplo n.º 12
0
void
dialog_so_size (WBCGtk *wbcg, GObject *so)
{
	GtkBuilder *gui;
	SOSizeState *state;
	int width, height;

	g_return_if_fail (wbcg != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, SO_SIZE_DIALOG_KEY))
		return;
	gui = gnm_gtk_builder_load ("sheetobject-size.ui", NULL, GO_CMD_CONTEXT (wbcg));
	if (gui == NULL)
		return;

	state = g_new (SOSizeState, 1);
	state->wbcg  = wbcg;
	state->sv = wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg));
	state->sheet = sv_sheet (state->sv);
	state->scg = wbcg_get_nth_scg (wbcg, state->sheet->index_in_wb);
	state->gui    = gui;
	state->dialog = go_gtk_builder_get_widget (state->gui, "object-size");

	state->so = SHEET_OBJECT (so);
	g_object_ref (so);

	state->nameentry = GTK_ENTRY (go_gtk_builder_get_widget (state->gui, "name-entry"));
	state->old_anchor = NULL;
	state->old_name = NULL;
	g_object_get (so, "name", &state->old_name, NULL);
	if (state->old_name == NULL)
		state->old_name = g_strdup ("");
	gtk_entry_set_text (state->nameentry, state->old_name);
	state->so_name_changed = FALSE;
	g_signal_connect (G_OBJECT (state->nameentry),
			  "focus-out-event",
			  G_CALLBACK (cb_dialog_so_size_name_changed),
			  state);
	state->so_print_check_changed = FALSE;

	state->wpoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "w-pts-label"));
	state->wspin  = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "w-spin"));
	state->hpoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "h-pts-label"));
	state->hspin  = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "h-spin"));
	state->xpoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "x-pts-label"));
	state->xspin  = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "x-spin"));
	state->ypoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "y-pts-label"));
	state->yspin  = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "y-spin"));
	state->print_check = GTK_WIDGET (go_gtk_builder_get_widget (state->gui,
							       "print-check"));
	dialog_so_size_load (state);
	state->active_anchor = sheet_object_anchor_dup (sheet_object_get_anchor
							(state->so));
	width = state->coords[2] - state->coords[0];
	height = state->coords[3] - state->coords[1];

	gtk_spin_button_set_value (state->wspin, (width < 0) ? - width : width);
	gtk_spin_button_set_value (state->hspin, (height < 0) ? - height : height);
	gtk_spin_button_set_value (state->xspin, 0.);
	gtk_spin_button_set_value (state->yspin, 0.);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->print_check),
				      !(state->so->flags & SHEET_OBJECT_PRINT));
	g_signal_connect (G_OBJECT (state->wspin),
			  "value-changed",
			  G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
			  state->wpoints);
	g_signal_connect (G_OBJECT (state->hspin),
			  "value-changed",
			  G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
			  state->hpoints);
	g_signal_connect (G_OBJECT (state->xspin),
			  "value-changed",
			  G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
			  state->xpoints);
	g_signal_connect (G_OBJECT (state->yspin),
			  "value-changed",
			  G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
			  state->ypoints);
	g_signal_connect (G_OBJECT (state->print_check),
			  "toggled",
			  G_CALLBACK (cb_dialog_so_size_print_check_toggled),
			  state);

	cb_dialog_so_size_value_changed_update_points (state->wspin, GTK_LABEL (state->wpoints));
	cb_dialog_so_size_value_changed_update_points (state->hspin, GTK_LABEL (state->hpoints));
	cb_dialog_so_size_value_changed_update_points (state->xspin, GTK_LABEL (state->xpoints));
	cb_dialog_so_size_value_changed_update_points (state->yspin, GTK_LABEL (state->ypoints));


	g_signal_connect (G_OBJECT (state->wspin),
		"value-changed",
		G_CALLBACK (cb_dialog_so_size_value_changed), state);
	g_signal_connect (G_OBJECT (state->hspin),
		"value-changed",
		G_CALLBACK (cb_dialog_so_size_value_changed), state);
	g_signal_connect (G_OBJECT (state->xspin),
		"value-changed",
		G_CALLBACK (cb_dialog_so_size_value_changed), state);
	g_signal_connect (G_OBJECT (state->yspin),
		"value-changed",
		G_CALLBACK (cb_dialog_so_size_value_changed), state);

	state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button");
	g_signal_connect (G_OBJECT (state->ok_button),
		"clicked",
		G_CALLBACK (cb_dialog_so_size_ok_clicked), state);
	state->apply_button = go_gtk_builder_get_widget (state->gui, "apply_button");
	g_signal_connect (G_OBJECT (state->apply_button),
		"clicked",
		G_CALLBACK (cb_dialog_so_size_apply_clicked), state);

	state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button");
	g_signal_connect (G_OBJECT (state->cancel_button),
		"clicked",
		G_CALLBACK (cb_dialog_so_size_cancel_clicked), state);

	gnumeric_init_help_button (
		go_gtk_builder_get_widget (state->gui, "help_button"),
		GNUMERIC_HELP_LINK_SO_SIZE);

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog),
					   state->wbcg,
					   GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);

	wbc_gtk_attach_guru (state->wbcg, state->dialog);
	g_object_set_data_full (G_OBJECT (state->dialog),
		"state", state, (GDestroyNotify) cb_dialog_so_size_destroy);

	gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
			       SO_SIZE_DIALOG_KEY);
	dialog_so_size_button_sensitivity (state);
	gtk_widget_show (state->dialog);
}
Exemplo n.º 13
0
void
dialog_row_height (WBCGtk *wbcg, gboolean use_default)
{
    RowHeightState *state;

    g_return_if_fail (wbcg != NULL);

    if (gnumeric_dialog_raise_if_exists (wbcg, ROW_HEIGHT_DIALOG_KEY))
        return;

    state = g_new (RowHeightState, 1);
    state->wbcg  = wbcg;
    state->sv = wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg));
    state->sheet = sv_sheet (state->sv);
    state->adjusting = FALSE;
    state->gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
                                    "row-height.glade", NULL, NULL);
    g_return_if_fail (state->gui != NULL);

    state->dialog = glade_xml_get_widget (state->gui, "dialog");

    state->description = GTK_WIDGET (glade_xml_get_widget (state->gui, "description"));
    state->points = GTK_WIDGET (glade_xml_get_widget (state->gui, "pts-label"));

    state->spin  = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "spin"));
    gtk_spin_button_get_adjustment (state->spin)->lower =
        GNM_ROW_MARGIN + GNM_ROW_MARGIN;
    g_signal_connect (G_OBJECT (state->spin),
                      "value-changed",
                      G_CALLBACK (cb_dialog_row_height_value_changed), state);

    state->default_check  = GTK_WIDGET (glade_xml_get_widget (state->gui, "default_check"));
    g_signal_connect (G_OBJECT (state->default_check),
                      "clicked",
                      G_CALLBACK (cb_dialog_row_height_default_check_toggled), state);

    state->ok_button = glade_xml_get_widget (state->gui, "ok_button");
    g_signal_connect (G_OBJECT (state->ok_button),
                      "clicked",
                      G_CALLBACK (cb_dialog_row_height_ok_clicked), state);
    state->apply_button = glade_xml_get_widget (state->gui, "apply_button");
    g_signal_connect (G_OBJECT (state->apply_button),
                      "clicked",
                      G_CALLBACK (cb_dialog_row_height_apply_clicked), state);

    state->cancel_button = glade_xml_get_widget (state->gui, "cancel_button");
    g_signal_connect (G_OBJECT (state->cancel_button),
                      "clicked",
                      G_CALLBACK (cb_dialog_row_height_cancel_clicked), state);

    gnumeric_init_help_button (
        glade_xml_get_widget (state->gui, "help_button"),
        GNUMERIC_HELP_LINK_ROW_HEIGHT);
    g_object_set_data_full (G_OBJECT (state->dialog),
                            "state", state, (GDestroyNotify) cb_dialog_row_height_destroy);

    gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog),
                                       state->wbcg,
                                       GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);

    dialog_row_height_set_mode (use_default, state);
    dialog_row_height_load_value (state);

    wbc_gtk_attach_guru (state->wbcg, state->dialog);
    gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
                           ROW_HEIGHT_DIALOG_KEY);
    gtk_widget_show (state->dialog);
}
Exemplo n.º 14
0
void
dialog_recent_used (WBCGtk *wbcg)
{
	GtkBuilder *gui;
	GtkDialog *dialog;

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

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

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

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


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

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

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

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

	populate_recent_model (gui);

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

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

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

	g_object_set_data_full (G_OBJECT (dialog), "gui", gui, g_object_unref);
	go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog));
	gtk_widget_show_all (GTK_WIDGET (dialog));
}
Exemplo n.º 15
0
void
dialog_new_view (WBCGtk *wbcg)
{
	ViewState *state;
	GtkBuilder *gui;

	if (gnumeric_dialog_raise_if_exists (wbcg, VIEW_DIALOG_KEY))
		return;
	gui = gnm_gtk_builder_new ("view.ui", NULL, GO_CMD_CONTEXT (wbcg));
	if (gui == NULL)
		return;

	state = g_new (ViewState, 1);
	state->wbcg = wbcg;
	state->gui = gui;
	state->dialog = go_gtk_builder_get_widget (gui, "View");
	state->location_elsewhere = GTK_RADIO_BUTTON (go_gtk_builder_get_widget (gui, "location_elsewhere"));
	state->location_display_name = GTK_ENTRY (go_gtk_builder_get_widget (gui, "location_display_name"));
	g_return_if_fail (state->dialog != NULL);

	{
		GdkScreen *this_screen = gtk_window_get_screen (wbcg_toplevel (wbcg));
		GdkDisplay *this_display = gdk_screen_get_display (this_screen);
		int n_screens = gdk_display_get_n_screens (this_display);
		GtkBox *box = GTK_BOX (go_gtk_builder_get_widget (gui, "location_screens_vbox"));
		int i;

		for (i = 0; i < n_screens; i++) {
			/* Get this for every screen -- it might change.  */
			GSList *group =
				gtk_radio_button_get_group (state->location_elsewhere);
			GdkScreen *screen = gdk_display_get_screen (this_display, i);
			char *label =
				screen == this_screen
				? (n_screens == 1
				   ? g_strdup (_("This screen"))
				   : g_strdup_printf (_("Screen %d [This screen]"), i))
				: g_strdup_printf (_("Screen %d"), i);
			GtkWidget *button =
				gtk_radio_button_new_with_label (group, label);
			g_free (label);

			if (screen == this_screen)
				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);

			g_object_set_data (G_OBJECT (button),
					   "screen", screen);

			gtk_box_pack_start (box, button, TRUE, TRUE, 0);
		}
	}

	g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "ok_button")),
			  "clicked",
			  G_CALLBACK (cb_view_ok_clicked), state);
	g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "cancel_button")),
			  "clicked",
			  G_CALLBACK (cb_view_cancel_clicked), state);

	gnm_link_button_and_entry (GTK_WIDGET (state->location_elsewhere),
				   GTK_WIDGET (state->location_display_name));

	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_WIDGET (state->location_display_name));

	gnumeric_init_help_button (
		go_gtk_builder_get_widget (gui, "help_button"),
		GNUMERIC_HELP_LINK_VIEW);
	gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
			       VIEW_DIALOG_KEY);

	g_object_set_data_full (G_OBJECT (state->dialog),
				"state", state, (GDestroyNotify) cb_view_destroy);
	gtk_widget_show_all (state->dialog);
}
/**
 * dialog_kaplan_meier_tool:
 * @wbcg:
 * @sheet:
 *
 * Show the dialog (guru).
 *
 **/
int
dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet)
{
        KaplanMeierToolState *state;
	GtkWidget *widget;
	char const * plugins[] = { "Gnumeric_fnstat",
				   "Gnumeric_fnlookup",
				   "Gnumeric_fnmath",
				   "Gnumeric_fninfo",
				   "Gnumeric_fnlogical",
				   NULL};

	if ((wbcg == NULL) ||
	    gnm_check_for_plugins_missing (plugins, wbcg_toplevel (wbcg)))
		return 1;

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

	state = g_new0 (KaplanMeierToolState, 1);

	if (dialog_tool_init (&state->base, wbcg, sheet,
			      GNUMERIC_HELP_LINK_KAPLAN_MEIER,
			      "kaplan-meier.glade", "KaplanMeier",
			      _("Could not create the Kaplan Meier Tool dialog."),
			      KAPLAN_MEIER_KEY,
			      G_CALLBACK (kaplan_meier_tool_ok_clicked_cb), NULL,
			      G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb),
			      0))
		return 0;



	state->censorship_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "censor-button"));
	state->censor_spin_from = GTK_WIDGET (glade_xml_get_widget
					      (state->base.gui,
					       "censored-spinbutton1"));
	gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_from), 0.,G_MAXSHORT);
	state->censor_spin_to = GTK_WIDGET (glade_xml_get_widget
					    (state->base.gui,
					     "censored-spinbutton2"));
	gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_to), 0.,G_MAXSHORT);
	state->graph_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "graph-button"));
	state->tick_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "tick-button"));
	state->add_group_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "add-button"));
	state->remove_group_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "remove-button"));
	state->std_error_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "std-error-button"));
	state->logrank_button = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "logrank-button"));

	state->groups_check = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "groups-check"));
	state->groups_table = GTK_WIDGET (glade_xml_get_widget
						  (state->base.gui,
						   "groups-table"));
	state->groups_input = gnm_expr_entry_new (state->base.wbcg, TRUE);
	gnm_expr_entry_set_flags (state->groups_input, GNM_EE_FORCE_ABS_REF,
				  GNM_EE_MASK);
	gtk_table_attach (GTK_TABLE (state->groups_table), GTK_WIDGET (state->groups_input),
			  1, 3, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);

	dialog_kaplan_meier_tool_setup_treeview (state);

	g_signal_connect_after (G_OBJECT (state->groups_check),
		"toggled",
		G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
	g_signal_connect_after (G_OBJECT (state->censorship_button),
		"toggled",
		G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
	g_signal_connect_after (G_OBJECT (state->graph_button),
		"toggled",
		G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
	g_signal_connect_after (G_OBJECT (state->std_error_button),
		"toggled",
		G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
	g_signal_connect_after (G_OBJECT (state->groups_input),
				"changed",
				G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb),
				state);

	g_signal_connect_after (G_OBJECT (state->groups_check),
		"toggled",
		G_CALLBACK (kaplan_meier_tool_update_groups_sensitivity_cb), state);
	g_signal_connect_after (G_OBJECT (state->tick_button),
		"toggled",
		G_CALLBACK (kaplan_meier_tool_set_graph_cb), state);
	g_signal_connect_after (G_OBJECT (state->add_group_button),
		"clicked",
		G_CALLBACK (kaplan_meier_tool_add_group_cb), state);
	g_signal_connect_after (G_OBJECT (state->remove_group_button),
		"clicked",
		G_CALLBACK (kaplan_meier_tool_remove_group_cb), state);
	g_signal_connect_after (G_OBJECT (state->censor_spin_from),
		"value-changed",
		G_CALLBACK (kaplan_meier_tool_set_censor_from_cb), state);
	g_signal_connect_after (G_OBJECT (state->censor_spin_to),
		"value-changed",
		G_CALLBACK (kaplan_meier_tool_set_censor_cb), state);
	g_signal_connect (G_OBJECT
			  (gnm_expr_entry_get_entry (
				  GNM_EXPR_ENTRY (state->base.input_entry_2))),
			  "focus-in-event",
			  G_CALLBACK (kaplan_meier_tool_set_censorship_cb), state);
	g_signal_connect (G_OBJECT
			  (gnm_expr_entry_get_entry (
				  GNM_EXPR_ENTRY (state->groups_input))),
			  "focus-in-event",
			  G_CALLBACK (kaplan_meier_tool_set_groups_cb), state);

	gnumeric_editable_enters (GTK_WINDOW (state->base.dialog),
					  GTK_WIDGET (state->groups_input));

	widget = glade_xml_get_widget (state->base.gui, "groups-label");
	gtk_label_set_mnemonic_widget (GTK_LABEL (widget),
				       GTK_WIDGET (state->groups_input));
	go_atk_setup_label (widget, GTK_WIDGET (state->groups_input));

	gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE);
	kaplan_meier_tool_update_sensitivity_cb (NULL, state);
	kaplan_meier_tool_update_groups_sensitivity_cb (NULL, state);
	tool_load_selection ((GenericToolState *)state, TRUE);

	gtk_widget_show_all (GTK_WIDGET (state->base.dialog));
	/* And to hide the in-place button again */
	gnm_dao_set_inplace ( GNM_DAO (state->base.gdao), NULL);

        return 0;
}
Exemplo n.º 17
0
void
dialog_merge (WBCGtk *wbcg)
{
	MergeState *state;
	GtkBuilder *gui;
	GtkGrid *grid;
	GtkWidget *scrolled;
	GtkTreeViewColumn *column;
	GtkTreeSelection  *selection;
	GnmRange const *r;

	g_return_if_fail (wbcg != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, MERGE_KEY))
		return;
	gui = gnm_gtk_builder_load ("merge.ui", NULL, GO_CMD_CONTEXT (wbcg));
        if (gui == NULL)
                return;

	state = g_new0 (MergeState, 1);
	state->gui = gui;
	state->wbcg = wbcg;
	state->sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (state->wbcg));
	state->dialog     = go_gtk_builder_get_widget (gui, "Merge");
	state->warning_dialog = NULL;

	state->add_btn   = go_gtk_builder_get_widget (gui, "add_button");
	state->delete_btn   = go_gtk_builder_get_widget (gui, "remove_button");
	state->merge_btn  = go_gtk_builder_get_widget (gui, "merge_button");
	state->change_btn  = go_gtk_builder_get_widget (gui, "change_button");
	state->cancel_btn  = go_gtk_builder_get_widget (gui, "cancel_button");
	gtk_widget_set_size_request (state->delete_btn, 100, -1);

	gtk_button_set_alignment (GTK_BUTTON (state->add_btn),    0., .5);
	gtk_button_set_alignment (GTK_BUTTON (state->delete_btn), 0., .5);
	gtk_button_set_alignment (GTK_BUTTON (state->change_btn), 0., .5);

	grid = GTK_GRID (go_gtk_builder_get_widget (gui, "main-grid"));
	state->zone = gnm_expr_entry_new (wbcg, TRUE);
	gnm_expr_entry_set_flags (state->zone, GNM_EE_SINGLE_RANGE, GNM_EE_MASK);
	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_WIDGET (state->zone));
	gtk_label_set_mnemonic_widget (GTK_LABEL (go_gtk_builder_get_widget (gui, "var1-label")),
				       GTK_WIDGET (state->zone));
	gtk_widget_set_hexpand (GTK_WIDGET (state->zone), TRUE);
	gtk_grid_attach (grid, GTK_WIDGET (state->zone), 1, 0, 2, 1);
	r = selection_first_range (
		wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), NULL, NULL);
	if (r != NULL)
		gnm_expr_entry_load_from_range (state->zone,
			state->sheet, r);

	state->data = gnm_expr_entry_new (wbcg, TRUE);
	gnm_expr_entry_set_flags (state->data, GNM_EE_SINGLE_RANGE, GNM_EE_MASK);
	gtk_widget_set_hexpand (GTK_WIDGET (state->data), TRUE);
	gtk_grid_attach (grid, GTK_WIDGET (state->data), 0, 5, 1, 1);

	state->field = gnm_expr_entry_new (wbcg, TRUE);
	gnm_expr_entry_set_flags (state->field, GNM_EE_SINGLE_RANGE, GNM_EE_MASK);
	gtk_widget_set_hexpand (GTK_WIDGET (state->field), TRUE);
	gtk_grid_attach (grid, GTK_WIDGET (state->field), 1, 5, 1, 1);

	scrolled = go_gtk_builder_get_widget (state->gui, "scrolled");
	state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING);
	state->list = GTK_TREE_VIEW (gtk_tree_view_new_with_model
					   (GTK_TREE_MODEL (state->model)));
	selection = gtk_tree_view_get_selection (state->list);
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);

	column = gtk_tree_view_column_new_with_attributes (_("Input Data"),
							   gtk_cell_renderer_text_new (),
							   "text", DATA_RANGE,
							   NULL);
	gtk_tree_view_column_set_sort_column_id (column, DATA_RANGE);
	gtk_tree_view_column_set_min_width (column, 150);
	gtk_tree_view_append_column (state->list, column);
	column = gtk_tree_view_column_new_with_attributes (_("Merge Field"),
							   gtk_cell_renderer_text_new (),
							   "text", FIELD_LOCATION,
							   NULL);
	gtk_tree_view_column_set_sort_column_id (column, FIELD_LOCATION);
	gtk_tree_view_column_set_min_width (column, 100);
	gtk_tree_view_append_column (state->list, column);

	gtk_tree_view_set_headers_clickable (state->list, TRUE);
	gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->list));

	cb_merge_update_buttons (NULL, state);
	g_signal_connect (selection,
		"changed",
		G_CALLBACK (cb_merge_selection_changed), state);

	g_signal_connect_after (G_OBJECT (state->zone),
		"changed",
		G_CALLBACK (cb_merge_update_buttons), state);
	g_signal_connect_after (G_OBJECT (state->data),
		"changed",
		G_CALLBACK (cb_merge_update_buttons), state);
	g_signal_connect_after (G_OBJECT (state->field),
		"changed",
		G_CALLBACK (cb_merge_update_buttons), state);

	g_signal_connect (G_OBJECT (state->add_btn),
		"clicked",
		G_CALLBACK (cb_merge_add_clicked), state);
	g_signal_connect (G_OBJECT (state->change_btn),
		"clicked",
		G_CALLBACK (cb_merge_change_clicked), state);
	g_signal_connect (G_OBJECT (state->delete_btn),
		"clicked",
		G_CALLBACK (cb_merge_delete_clicked), state);
	g_signal_connect (G_OBJECT (state->merge_btn),
		"clicked",
		G_CALLBACK (cb_merge_merge_clicked), state);
	g_signal_connect (G_OBJECT (state->cancel_btn),
		"clicked",
		G_CALLBACK (cb_merge_cancel_clicked), state);

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog),
					   state->wbcg,
					   GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);

	gnumeric_init_help_button (
		go_gtk_builder_get_widget (state->gui, "help_button"),
		GNUMERIC_HELP_LINK_DATA_MERGE);

	gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
			       MERGE_KEY);

	/* a candidate for merging into attach guru */
	g_object_set_data_full (G_OBJECT (state->dialog),
		"state", state, (GDestroyNotify) cb_merge_destroy);
	go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg),
				   GTK_WINDOW (state->dialog));
	wbc_gtk_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
	gtk_widget_show_all (GTK_WIDGET (state->dialog));
}
void
dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
{
	CommentState	*state;
	GtkWidget	*box, *check, *old_author, *new_author;
	GnmComment	*comment;
	GtkBuilder	*gui;
	char *title, *cell_name;
	char const*real_user;
	GnmCellRef ref;
	GnmParsePos pp;
	GnmConventionsOut out;

	g_return_if_fail (wbcg != NULL);
	g_return_if_fail (sheet != NULL);
	g_return_if_fail (pos != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, COMMENT_DIALOG_KEY))
		return;
	gui = gnm_gtk_builder_new ("cell-comment.ui", NULL, GO_CMD_CONTEXT (wbcg));
	if (gui == NULL)
		return;

	state = g_new (CommentState, 1);
	state->wbcg  = wbcg;
	state->sheet = sheet;
	state->pos   = pos;
	state->gui   = gui;

	state->dialog = go_gtk_builder_get_widget (state->gui, "comment_dialog");
	g_return_if_fail (state->dialog != NULL);

	box = go_gtk_builder_get_widget (state->gui, "dialog-vbox");
	g_return_if_fail (box != NULL);
	state->gtv = gnm_text_view_new ();
	gtk_widget_show_all (GTK_WIDGET (state->gtv));
	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (state->gtv),
			    TRUE, TRUE, TRUE);
	g_object_set (state->gtv, "wrap", GTK_WRAP_WORD, NULL);

	gnm_cellref_init (&ref, sheet, pos->col, pos->row, FALSE);
	out.accum = g_string_new (NULL);
	parse_pos_init_sheet (&pp, sheet);
	out.pp = &pp;
	out.convs = sheet->convs;
	cellref_as_string (&out, &ref, FALSE);
	cell_name = g_string_free (out.accum, FALSE);

	old_author = go_gtk_builder_get_widget (state->gui, "old-author-entry");
	new_author = go_gtk_builder_get_widget (state->gui, "new-author-entry");

	real_user = g_get_real_name ();
	if ((real_user != NULL) && g_utf8_validate (real_user, -1, NULL)) {
		gtk_entry_set_text (GTK_ENTRY (new_author), real_user);
		gtk_editable_select_region (GTK_EDITABLE (new_author), 0, -1);
	}

	comment = sheet_get_comment (sheet, pos);
	if (comment) {
		char const *text;
		PangoAttrList *attr;
		g_object_get (G_OBJECT (comment), "text", &text,
			      "markup", &attr, NULL);
		g_object_set (state->gtv, "text", text,
			      "attributes", attr, NULL);
		if (attr != NULL)
			pango_attr_list_unref (attr);

		text = cell_comment_author_get (comment);
		if (text != NULL)
			gtk_label_set_text (GTK_LABEL (old_author),
					    text);
		title = g_strdup_printf (_("Edit Cell Comment (%s)"),
					 cell_name);
	} else {
		title = g_strdup_printf (_("New Cell Comment (%s)"),
					 cell_name);
		gtk_widget_hide (old_author);
		gtk_widget_hide (go_gtk_builder_get_widget (state->gui,
						       "old-author-label"));
	}
	gtk_window_set_title (GTK_WINDOW (state->dialog), title);
	g_free (title);

	state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button");
	g_signal_connect (G_OBJECT (state->ok_button),
		"clicked",
		G_CALLBACK (cb_cell_comment_ok_clicked), state);

	state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button");
	g_signal_connect (G_OBJECT (state->cancel_button),
		"clicked",
		G_CALLBACK (cb_cell_comment_cancel_clicked), state);

	check = go_gtk_builder_get_widget (state->gui, "wrap-check");
	g_signal_connect (G_OBJECT (check),
			  "toggled",
			  G_CALLBACK (cb_wrap_toggled), state->gtv);
	cb_wrap_toggled (GTK_TOGGLE_BUTTON (check), G_OBJECT (state->gtv));

	gnumeric_init_help_button (
		go_gtk_builder_get_widget (state->gui, "help_button"),
		GNUMERIC_HELP_LINK_CELL_COMMENT);

	wbc_gtk_attach_guru (state->wbcg, state->dialog);
	g_object_set_data_full (G_OBJECT (state->dialog),
		"state", state, (GDestroyNotify) cb_dialog_cell_comment_destroy);

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg,
					   GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);

	gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
			       COMMENT_DIALOG_KEY);
	gtk_widget_show (state->dialog);
}
Exemplo n.º 19
0
void
dialog_zoom (WBCGtk *wbcg, Sheet *sheet)
{
	ZoomState *state;
	GSList *l, *sheets;
	int i, row, cur_row;
	gboolean is_custom = TRUE;
	GtkRadioButton *radio;
	GtkWidget *focus_target;
	GladeXML     *gui;
	GtkTreeViewColumn *column;

	g_return_if_fail (wbcg != NULL);
	g_return_if_fail (sheet != NULL);

	if (gnumeric_dialog_raise_if_exists (wbcg, ZOOM_DIALOG_KEY))
		return;
	gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
		"dialog-zoom.glade", NULL, NULL);
	if (gui == NULL)
		return;

	state = g_new (ZoomState, 1);
	state->wbcg   = wbcg;
	state->gui    = gui;
	state->dialog = glade_xml_get_widget (state->gui, "Zoom");
	g_return_if_fail (state->dialog != NULL);

	/* Get the list of sheets */
	state->sheet_list_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
	state->sheet_list = GTK_TREE_VIEW (glade_xml_get_widget (state->gui, "sheet_list"));
	gtk_tree_view_set_headers_visible (state->sheet_list, FALSE);
	gtk_tree_view_set_model (state->sheet_list, GTK_TREE_MODEL (state->sheet_list_model));
	state->sheet_list_selection = gtk_tree_view_get_selection (state->sheet_list);
	gtk_tree_selection_set_mode (state->sheet_list_selection, GTK_SELECTION_MULTIPLE);

	column = gtk_tree_view_column_new_with_attributes (_("Name"),
			gtk_cell_renderer_text_new (),
			"text", 0,
			NULL);
	gtk_tree_view_column_set_sort_column_id (column, COL_SHEET_NAME);
	gtk_tree_view_append_column (GTK_TREE_VIEW (state->sheet_list), column);

	sheets = workbook_sheets (wb_control_get_workbook (WORKBOOK_CONTROL (wbcg)));
	cur_row = row = 0;
	for (l = sheets; l; l = l->next) {
		GtkTreeIter iter;
		Sheet *this_sheet = l->data;

		gtk_list_store_append (state->sheet_list_model, &iter);
		gtk_list_store_set (state->sheet_list_model,
				    &iter,
				    COL_SHEET_NAME, this_sheet->name_unquoted,
				    COL_SHEET_PTR, this_sheet,
				    -1);

		if (this_sheet == sheet)
			cur_row = row;
		row++;
	}
	g_slist_free (sheets);

	{
		GtkTreePath *path = gtk_tree_path_new_from_indices (cur_row, -1);
		gtk_tree_view_set_cursor (state->sheet_list, path, NULL, FALSE);
		gtk_tree_path_free (path);
	}

	state->zoom  = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "zoom"));
	g_return_if_fail (state->zoom != NULL);
	state->custom = GTK_RADIO_BUTTON (glade_xml_get_widget (state->gui, "radio_custom"));
	g_return_if_fail (state->custom != NULL);
	focus_target = GTK_WIDGET (state->custom);
	g_signal_connect (G_OBJECT (state->custom),
		"clicked",
		G_CALLBACK (focus_to_custom), (gpointer) state);
	g_signal_connect (G_OBJECT (state->zoom),
		"focus_in_event",
		G_CALLBACK (custom_selected), state);

	for (i = 0; buttons[i].name != NULL; i++) {
		radio  = GTK_RADIO_BUTTON (glade_xml_get_widget (state->gui, buttons[i].name));
		g_return_if_fail (radio != NULL);

		g_object_set_data (G_OBJECT (radio), ZOOM_DIALOG_FACTOR_KEY,
				   GINT_TO_POINTER(buttons[i].factor));

		g_signal_connect (G_OBJECT (radio),
			"toggled",
			G_CALLBACK (radio_toggled), state);

		if (((int)(sheet->last_zoom_factor_used * 100. + .5)) == buttons[i].factor) {
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
			is_custom = FALSE;
			focus_target = GTK_WIDGET (radio);
		}
	}

	if (is_custom) {
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->custom), TRUE);
		gtk_spin_button_set_value (state->zoom,
					   (int)(sheet->last_zoom_factor_used * 100. + .5));
	}
	state->ok_button = glade_xml_get_widget (state->gui, "ok_button");
	g_signal_connect (G_OBJECT (state->ok_button),
		"clicked",
		G_CALLBACK (cb_zoom_ok_clicked), state);

	state->cancel_button = glade_xml_get_widget (state->gui, "cancel_button");
	g_signal_connect (G_OBJECT (state->cancel_button),
		"clicked",
		G_CALLBACK (cb_zoom_cancel_clicked), state);

	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_WIDGET (&state->zoom->entry));

	gnumeric_init_help_button (
		glade_xml_get_widget (state->gui, "help_button"),
		GNUMERIC_HELP_LINK_ZOOM);

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), wbcg,
					   GNM_DIALOG_DESTROY_SHEET_REMOVED);

	gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
			       ZOOM_DIALOG_KEY);
	g_object_set_data_full (G_OBJECT (state->dialog),
		"state", state, (GDestroyNotify) cb_zoom_destroy);
	wbc_gtk_attach_guru (state->wbcg, state->dialog);
	gtk_widget_show (state->dialog);

	gtk_widget_grab_focus (focus_target);
}