Exemplo n.º 1
0
GtkWidget*
create_windowStats (void)
{
  GtkWidget *windowStats;
  GtkWidget *vboxStats;
  GtkWidget *labelUserValue;
  GtkWidget *hseparator1;
  GtkWidget *hboxHabitData;
  GtkWidget *treeviewHabits;
  GtkWidget *tableData;
  GtkWidget *labelClean;
  GtkWidget *labelSaved;
  GtkWidget *labelDaily;
  GtkWidget *labelUnits;
  GtkWidget *labelCleanValue;
  GtkWidget *labelSavedValue;
  GtkWidget *labelDailyValue;
  GtkWidget *labelUnitsValue;
  GtkWidget *frameTotals;
  GtkWidget *tableTotals;
  GtkWidget *labelCleanTotal;
  GtkWidget *labelSavedTotal;
  GtkWidget *labelSavedValueTotal;
  GtkWidget *labelCleanValueTotal;
  GtkWidget *label20;
  GtkWidget *hbuttonbox2;
  GtkWidget *buttonClose;

  windowStats = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (windowStats, "windowStats");
  gtk_window_set_title (GTK_WINDOW (windowStats), "Stats");
  gtk_window_set_resizable (GTK_WINDOW (windowStats), FALSE);

  vboxStats = gtk_vbox_new (FALSE, 5);
  gtk_widget_set_name (vboxStats, "vboxStats");
  gtk_widget_show (vboxStats);
  gtk_container_add (GTK_CONTAINER (windowStats), vboxStats);
  gtk_container_set_border_width (GTK_CONTAINER (vboxStats), 3);

  labelUserValue = gtk_label_new ("<span size=\"large\">User name</span>");
  gtk_widget_set_name (labelUserValue, "labelUserValue");
  gtk_widget_show (labelUserValue);
  gtk_box_pack_start (GTK_BOX (vboxStats), labelUserValue, TRUE, TRUE, 1);
  gtk_label_set_use_markup (GTK_LABEL (labelUserValue), TRUE);

  hseparator1 = gtk_hseparator_new ();
  gtk_widget_set_name (hseparator1, "hseparator1");
  gtk_widget_show (hseparator1);
  gtk_box_pack_start (GTK_BOX (vboxStats), hseparator1, TRUE, TRUE, 0);

  hboxHabitData = gtk_hbox_new (FALSE, 5);
  gtk_widget_set_name (hboxHabitData, "hboxHabitData");
  gtk_widget_show (hboxHabitData);
  gtk_box_pack_start (GTK_BOX (vboxStats), hboxHabitData, FALSE, FALSE, 0);

  treeviewHabits = gtk_tree_view_new ();
  gtk_widget_set_name (treeviewHabits, "treeviewHabits");
  gtk_widget_show (treeviewHabits);
  gtk_box_pack_start (GTK_BOX (hboxHabitData), treeviewHabits, TRUE, TRUE, 0);

  tableData = gtk_table_new (4, 2, FALSE);
  gtk_widget_set_name (tableData, "tableData");
  gtk_widget_show (tableData);
  gtk_box_pack_start (GTK_BOX (hboxHabitData), tableData, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (tableData), 5);
  gtk_table_set_row_spacings (GTK_TABLE (tableData), 5);
  gtk_table_set_col_spacings (GTK_TABLE (tableData), 10);

  labelClean = gtk_label_new ("Clean time:");
  gtk_widget_set_name (labelClean, "labelClean");
  gtk_widget_show (labelClean);
  gtk_table_attach (GTK_TABLE (tableData), labelClean, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_use_markup (GTK_LABEL (labelClean), TRUE);
  gtk_misc_set_alignment (GTK_MISC (labelClean), 0, 0.5);

  labelSaved = gtk_label_new ("Money saved:");
  gtk_widget_set_name (labelSaved, "labelSaved");
  gtk_widget_show (labelSaved);
  gtk_table_attach (GTK_TABLE (tableData), labelSaved, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_use_markup (GTK_LABEL (labelSaved), TRUE);
  gtk_misc_set_alignment (GTK_MISC (labelSaved), 0, 0.5);

  labelDaily = gtk_label_new ("Daily save:");
  gtk_widget_set_name (labelDaily, "labelDaily");
  gtk_widget_show (labelDaily);
  gtk_table_attach (GTK_TABLE (tableData), labelDaily, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_use_markup (GTK_LABEL (labelDaily), TRUE);
  gtk_misc_set_alignment (GTK_MISC (labelDaily), 0, 0.5);

  labelUnits = gtk_label_new ("Units not used:");
  gtk_widget_set_name (labelUnits, "labelUnits");
  gtk_widget_show (labelUnits);
  gtk_table_attach (GTK_TABLE (tableData), labelUnits, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelUnits), 0, 0.5);

  labelCleanValue = gtk_label_new ("0M 0W 0D 0h 0m");
  gtk_widget_set_name (labelCleanValue, "labelCleanValue");
  gtk_widget_show (labelCleanValue);
  gtk_table_attach (GTK_TABLE (tableData), labelCleanValue, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelCleanValue), 0, 0.5);

  labelSavedValue = gtk_label_new ("0.00");
  gtk_widget_set_name (labelSavedValue, "labelSavedValue");
  gtk_widget_show (labelSavedValue);
  gtk_table_attach (GTK_TABLE (tableData), labelSavedValue, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelSavedValue), 0, 0.5);

  labelDailyValue = gtk_label_new ("0.00");
  gtk_widget_set_name (labelDailyValue, "labelDailyValue");
  gtk_widget_show (labelDailyValue);
  gtk_table_attach (GTK_TABLE (tableData), labelDailyValue, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelDailyValue), 0, 0.5);

  labelUnitsValue = gtk_label_new ("0");
  gtk_widget_set_name (labelUnitsValue, "labelUnitsValue");
  gtk_widget_show (labelUnitsValue);
  gtk_table_attach (GTK_TABLE (tableData), labelUnitsValue, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelUnitsValue), 0, 0.5);

  frameTotals = gtk_frame_new (NULL);
  gtk_widget_set_name (frameTotals, "frameTotals");
  gtk_widget_show (frameTotals);
  gtk_box_pack_start (GTK_BOX (vboxStats), frameTotals, TRUE, TRUE, 0);

  tableTotals = gtk_table_new (2, 2, FALSE);
  gtk_widget_set_name (tableTotals, "tableTotals");
  gtk_widget_show (tableTotals);
  gtk_container_add (GTK_CONTAINER (frameTotals), tableTotals);
  gtk_container_set_border_width (GTK_CONTAINER (tableTotals), 5);
  gtk_table_set_row_spacings (GTK_TABLE (tableTotals), 5);
  gtk_table_set_col_spacings (GTK_TABLE (tableTotals), 10);

  labelCleanTotal = gtk_label_new ("Clean time:");
  gtk_widget_set_name (labelCleanTotal, "labelCleanTotal");
  gtk_widget_show (labelCleanTotal);
  gtk_table_attach (GTK_TABLE (tableTotals), labelCleanTotal, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_use_markup (GTK_LABEL (labelCleanTotal), TRUE);
  gtk_misc_set_alignment (GTK_MISC (labelCleanTotal), 0, 0.5);

  labelSavedTotal = gtk_label_new ("Money saved:");
  gtk_widget_set_name (labelSavedTotal, "labelSavedTotal");
  gtk_widget_show (labelSavedTotal);
  gtk_table_attach (GTK_TABLE (tableTotals), labelSavedTotal, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_use_markup (GTK_LABEL (labelSavedTotal), TRUE);
  gtk_misc_set_alignment (GTK_MISC (labelSavedTotal), 0, 0.5);

  labelSavedValueTotal = gtk_label_new ("0.00");
  gtk_widget_set_name (labelSavedValueTotal, "labelSavedValueTotal");
  gtk_widget_show (labelSavedValueTotal);
  gtk_table_attach (GTK_TABLE (tableTotals), labelSavedValueTotal, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelSavedValueTotal), 0, 0.5);

  labelCleanValueTotal = gtk_label_new ("0M 0W 0D 0h 0m");
  gtk_widget_set_name (labelCleanValueTotal, "labelCleanValueTotal");
  gtk_widget_show (labelCleanValueTotal);
  gtk_table_attach (GTK_TABLE (tableTotals), labelCleanValueTotal, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelCleanValueTotal), 0, 0.5);

  label20 = gtk_label_new (" <b>Totals</b> ");
  gtk_widget_set_name (label20, "label20");
  gtk_widget_show (label20);
  gtk_frame_set_label_widget (GTK_FRAME (frameTotals), label20);
  gtk_label_set_use_markup (GTK_LABEL (label20), TRUE);

  hbuttonbox2 = gtk_hbutton_box_new ();
  gtk_widget_set_name (hbuttonbox2, "hbuttonbox2");
  gtk_widget_show (hbuttonbox2);
  gtk_box_pack_start (GTK_BOX (vboxStats), hbuttonbox2, TRUE, TRUE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox2), GTK_BUTTONBOX_END);
  gtk_box_set_spacing (GTK_BOX (hbuttonbox2), 5);

  buttonClose = gtk_button_new_from_stock ("gtk-close");
  gtk_widget_set_name (buttonClose, "buttonClose");
  gtk_widget_show (buttonClose);
  gtk_container_add (GTK_CONTAINER (hbuttonbox2), buttonClose);
  GTK_WIDGET_SET_FLAGS (buttonClose, GTK_CAN_DEFAULT);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (windowStats, windowStats, "windowStats");
  GLADE_HOOKUP_OBJECT (windowStats, vboxStats, "vboxStats");
  GLADE_HOOKUP_OBJECT (windowStats, labelUserValue, "labelUserValue");
  GLADE_HOOKUP_OBJECT (windowStats, hseparator1, "hseparator1");
  GLADE_HOOKUP_OBJECT (windowStats, hboxHabitData, "hboxHabitData");
  GLADE_HOOKUP_OBJECT (windowStats, treeviewHabits, "treeviewHabits");
  GLADE_HOOKUP_OBJECT (windowStats, tableData, "tableData");
  GLADE_HOOKUP_OBJECT (windowStats, labelClean, "labelClean");
  GLADE_HOOKUP_OBJECT (windowStats, labelSaved, "labelSaved");
  GLADE_HOOKUP_OBJECT (windowStats, labelDaily, "labelDaily");
  GLADE_HOOKUP_OBJECT (windowStats, labelUnits, "labelUnits");
  GLADE_HOOKUP_OBJECT (windowStats, labelCleanValue, "labelCleanValue");
  GLADE_HOOKUP_OBJECT (windowStats, labelSavedValue, "labelSavedValue");
  GLADE_HOOKUP_OBJECT (windowStats, labelDailyValue, "labelDailyValue");
  GLADE_HOOKUP_OBJECT (windowStats, labelUnitsValue, "labelUnitsValue");
  GLADE_HOOKUP_OBJECT (windowStats, frameTotals, "frameTotals");
  GLADE_HOOKUP_OBJECT (windowStats, tableTotals, "tableTotals");
  GLADE_HOOKUP_OBJECT (windowStats, labelCleanTotal, "labelCleanTotal");
  GLADE_HOOKUP_OBJECT (windowStats, labelSavedTotal, "labelSavedTotal");
  GLADE_HOOKUP_OBJECT (windowStats, labelSavedValueTotal, "labelSavedValueTotal");
  GLADE_HOOKUP_OBJECT (windowStats, labelCleanValueTotal, "labelCleanValueTotal");
  GLADE_HOOKUP_OBJECT (windowStats, label20, "label20");
  GLADE_HOOKUP_OBJECT (windowStats, hbuttonbox2, "hbuttonbox2");
  GLADE_HOOKUP_OBJECT (windowStats, buttonClose, "buttonClose");

  return windowStats;
}
static void
mateconf_bookmarks_dialog_init (MateConfBookmarksDialog *dialog)
{
	GtkWidget *scrolled_window, *hbox, *vbox;
	GtkWidget *content_area;
	GtkCellRenderer *cell;
	GtkTreeViewColumn *column;
	MateConfClient *client;
       
	hbox = gtk_hbox_new (FALSE, 6);
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);

	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));

	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
	gtk_box_set_spacing (GTK_BOX (content_area), 2);
	gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
	gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 200);
	
	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
	gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks"));

	dialog->list_store = gtk_list_store_new (1, G_TYPE_STRING);
	g_signal_connect (dialog->list_store, "row_deleted",
			  G_CALLBACK (mateconf_bookmarks_dialog_row_deleted), dialog);
	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0);
	
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	dialog->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list_store));
	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (dialog->tree_view), TRUE);
	
	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view)), "changed",
			  G_CALLBACK (mateconf_bookmarks_dialog_selection_changed), dialog);
	mateconf_bookmarks_dialog_populate_model (dialog);

	column = gtk_tree_view_column_new ();

	cell = gtk_cell_renderer_pixbuf_new ();
	g_object_set (G_OBJECT (cell),
		      "stock-id", STOCK_BOOKMARK,
		      NULL);
	gtk_tree_view_column_pack_start (column, cell, FALSE);
	
	cell = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, cell, TRUE);
	gtk_tree_view_column_set_attributes (column, cell,
					     "text", 0,
					     NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree_view), column);

	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->tree_view), FALSE);
	
	g_object_unref (dialog->list_store);
	gtk_container_add (GTK_CONTAINER (scrolled_window), dialog->tree_view);

	vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
	dialog->delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE);
	gtk_widget_set_sensitive (dialog->delete_button, FALSE);
	g_signal_connect (dialog->delete_button, "clicked",
			  G_CALLBACK (mateconf_bookmarks_dialog_delete_bookmark), dialog);
	
	gtk_box_pack_start (GTK_BOX (vbox), dialog->delete_button, FALSE, FALSE, 0);

	gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
	gtk_widget_show_all (hbox);

	/* Listen for mateconf changes */
	client = mateconf_client_get_default ();
	mateconf_client_add_dir (client, BOOKMARKS_KEY, MATECONF_CLIENT_PRELOAD_NONE, NULL);

	dialog->notify_id = mateconf_client_notify_add (client, BOOKMARKS_KEY,
						     mateconf_bookmarks_dialog_bookmarks_key_changed,
						     dialog,
						     NULL,
						     NULL);

	g_object_unref (client);
}
void
procdialog_create_renice_dialog (ProcData *procdata)
{
    ProcInfo  *info = procdata->selected_process;
    GtkWidget *dialog = NULL;
    GtkWidget *dialog_vbox;
    GtkWidget *vbox;
    GtkWidget *label;
    GtkWidget *priority_label;
    GtkWidget *grid;
    GtkAdjustment *renice_adj;
    GtkWidget *hscale;
    GtkWidget *button;
    GtkWidget *icon;
    gchar     *text;
    gchar     *dialog_title;

    if (renice_dialog)
        return;

    if (!info)
        return;

    dialog_title = g_strdup_printf (_("Change Priority of Process “%s” (PID: %u)"),
                                    info->name, info->pid);
    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
                                          NULL);
    g_free (dialog_title);

    renice_dialog = dialog;
    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);

    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
    gtk_widget_set_can_default (button, TRUE);

    icon = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_image (GTK_BUTTON (button), icon);

    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
    new_nice_value = -100;

    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);

    grid = gtk_grid_new ();
    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);

    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);

    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
    new_nice_value = 0;
    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
    gtk_widget_set_hexpand (hscale, TRUE);
    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
    priority_label = gtk_label_new (text);
    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
    g_free(text);

    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
        "</i></small>", NULL);
    label = gtk_label_new (_(text));
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
    g_free (text);

    g_signal_connect (G_OBJECT (dialog), "response",
                      G_CALLBACK (renice_dialog_button_pressed), procdata);
    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
                      G_CALLBACK (renice_scale_changed), priority_label);

    gtk_widget_show_all (dialog);


}
Exemplo n.º 4
0
void
gkrellm_plugins_config_create(GtkWidget *tab_vbox)
	{
	GtkWidget			*tabs;
	GtkWidget			*vbox;
	GtkWidget			*hbox;
	GtkWidget			*scrolled;
	GtkWidget			*view;
	GtkTreeModel		*model;
	GtkCellRenderer		*renderer;
	GtkTreeSelection	*selection;
	GtkTreeViewColumn	*column;
	GtkTextIter			iter;
	GtkTextBuffer		*buffer;

	row_reference = NULL;
	tabs = gtk_notebook_new();
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs), GTK_POS_TOP);
	gtk_box_pack_start(GTK_BOX(tab_vbox), tabs, TRUE, TRUE, 0);


/* -- Plugins tab */
	vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Plugins"));

	scrolled = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 2);

	model = create_model();
	treeview = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
	g_object_unref(G_OBJECT(model));
	gtk_tree_view_set_rules_hint(treeview, TRUE);

	renderer = gtk_cell_renderer_toggle_new();
	gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Enable"),
				renderer,
				"active", ENABLE_COLUMN, NULL);
	g_signal_connect (G_OBJECT(renderer), "toggled",
				G_CALLBACK(cb_enable_plugin), model);

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes (_("Plugin"),
				renderer,
				"text", NAME_COLUMN, NULL);
	gtk_tree_view_append_column(treeview, column);
	gtk_tree_view_column_set_sort_column_id(column, NAME_COLUMN);
	gtk_tree_view_column_clicked(column);		/* Sort it */
/* gtk_tree_sortable_set_sort_column_id(model,
			NAME_COLUMN, GTK_ORDER_ASCENDING);
*/

	gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(treeview));
	selection = gtk_tree_view_get_selection(treeview);
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
	g_signal_connect(G_OBJECT(selection), "changed",
				G_CALLBACK(cb_tree_selection_changed), NULL);

	hbox = gtk_hbutton_box_new();
	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_START);
	gtk_box_set_spacing(GTK_BOX(hbox), 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);

	place_button = gtk_button_new_with_label(_("Place"));
	gtk_box_pack_start(GTK_BOX(hbox), place_button, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT(GTK_BUTTON(place_button)), "clicked",
			G_CALLBACK(cb_place_button), NULL);
	gtk_widget_set_sensitive(place_button, FALSE);

/* --Plugins detect log tab */
	vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Install Log"));
	view = gkrellm_gtk_scrolled_text_view(vbox, NULL,
				GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
	gtk_text_buffer_get_end_iter(buffer, &iter);
	if (plugin_install_log)
		gtk_text_buffer_insert(buffer, &iter, plugin_install_log, -1);
	else
		gtk_text_buffer_insert(buffer, &iter, _("No plugins found."), -1);
	}
Exemplo n.º 5
0
static void
mate_volume_control_preferences_init (MateVolumeControlPreferences *prefs)
{
  GtkWidget *box, *label, *view;
  GtkListStore *store;
  GtkTreeSelection *sel;
  GtkTreeViewColumn *col;
  GtkCellRenderer *render;

  prefs->settings = NULL;
  prefs->mixer = NULL;

  /* make window look cute */
  gtk_window_set_title (GTK_WINDOW (prefs), _("Volume Control Preferences"));
#if !GTK_CHECK_VERSION (3, 0, 0)
  gtk_dialog_set_has_separator (GTK_DIALOG (prefs), FALSE);
#endif
  gtk_container_set_border_width (GTK_CONTAINER (prefs), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefs))), 2);
  gtk_dialog_add_buttons (GTK_DIALOG (prefs),
			  GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
			  /* help goes here (future) */
			  NULL);

  /* add a treeview for all the properties */
  box = gtk_vbox_new (FALSE, 6);
  gtk_container_set_border_width (GTK_CONTAINER (box), 5);

  label = gtk_label_new_with_mnemonic (_("_Select mixers to be visible:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  store = gtk_list_store_new (NUM_COLS, G_TYPE_BOOLEAN,
			      G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING,
			      G_TYPE_INT);
  gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), sort_by_page_num, NULL, NULL);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
  prefs->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (prefs->treeview), FALSE);
  gtk_label_set_mnemonic_widget (GTK_LABEL(label), GTK_WIDGET (prefs->treeview));

  /* viewport for lots of tracks */
  view = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
				  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view),
				       GTK_SHADOW_IN);
  gtk_widget_set_size_request (view, -1, 250);

  gtk_container_add (GTK_CONTAINER (view), prefs->treeview);
  gtk_box_pack_start (GTK_BOX (box), view, TRUE, TRUE, 0);

  gtk_widget_show (prefs->treeview);
  gtk_widget_show (view);

  /* treeview internals */
  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->treeview));
  gtk_tree_selection_set_mode (sel, GTK_SELECTION_SINGLE);

  render = gtk_cell_renderer_toggle_new ();
  g_signal_connect (render, "toggled",
		    G_CALLBACK (cb_toggle), prefs);
  g_signal_connect (prefs->treeview, "row-activated",
		    G_CALLBACK (cb_activated), prefs);
  col = gtk_tree_view_column_new_with_attributes ("Active", render,
						  "active", COL_ACTIVE,
						  NULL);
  gtk_tree_view_column_set_clickable (col, TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (prefs->treeview), col);

  render = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new_with_attributes ("Track name", render,
						  "text", COL_LABEL,
						  NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (prefs->treeview), col);

  render = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new_with_attributes ("Type", render,
                          "text", COL_TYPE,
						  NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (prefs->treeview), col);

  gtk_tree_view_set_search_column (GTK_TREE_VIEW (prefs->treeview), COL_LABEL);

  /* and show */
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefs))), box,
		      TRUE, TRUE, 0);
  gtk_widget_show (box);
}
Exemplo n.º 6
0
static void
show_auth_dialog(LuakitAuthData *auth_data, const char *login, const char *password)
{
    GtkWidget *widget = gtk_dialog_new();
    GtkWindow *window = GTK_WINDOW(widget);
    GtkDialog *dialog = GTK_DIALOG(widget);

    gtk_dialog_add_buttons(dialog,
       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
       GTK_STOCK_OK, GTK_RESPONSE_OK,
       NULL);

    /* set dialog properties */
    gtk_dialog_set_has_separator(dialog, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
    gtk_box_set_spacing(GTK_BOX(dialog->vbox), 2);
    gtk_container_set_border_width(GTK_CONTAINER(dialog->action_area), 5);
    gtk_box_set_spacing(GTK_BOX(dialog->action_area), 6);
    gtk_window_set_resizable(window, FALSE);
    gtk_window_set_title(window, "");
    gtk_window_set_icon_name(window, GTK_STOCK_DIALOG_AUTHENTICATION);

    gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK);

    /* build contents */
    GtkWidget *hbox = gtk_hbox_new(FALSE, 12);
    gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
    gtk_box_pack_start(GTK_BOX(dialog->vbox), hbox, TRUE, TRUE, 0);

    GtkWidget *icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);

    gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
    gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);

    GtkWidget *main_vbox = gtk_vbox_new(FALSE, 18);
    gtk_box_pack_start(GTK_BOX(hbox), main_vbox, TRUE, TRUE, 0);

    SoupURI *uri = soup_message_get_uri(auth_data->msg);
    gchar *msg = g_strdup_printf("A username and password are being requested by the site %s", uri->host);
    GtkWidget *msg_label = gtk_label_new(msg);
    g_free(msg);
    gtk_misc_set_alignment(GTK_MISC(msg_label), 0.0, 0.5);
    gtk_label_set_line_wrap(GTK_LABEL(msg_label), TRUE);
    gtk_box_pack_start(GTK_BOX(main_vbox), GTK_WIDGET(msg_label), FALSE, FALSE, 0);

    GtkWidget *vbox = gtk_vbox_new(FALSE, 6);
    gtk_box_pack_start(GTK_BOX(main_vbox), vbox, FALSE, FALSE, 0);

    /* the table that holds the entries */
    GtkWidget *entry_container = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);

    gtk_alignment_set_padding(GTK_ALIGNMENT(entry_container), 0, 0, 0, 0);

    gtk_box_pack_start(GTK_BOX(vbox), entry_container, FALSE, FALSE, 0);

    GtkWidget *table = gtk_table_new(2, 2, FALSE);
    gtk_table_set_col_spacings(GTK_TABLE(table), 12);
    gtk_table_set_row_spacings(GTK_TABLE(table), 6);
    gtk_container_add(GTK_CONTAINER(entry_container), table);

    auth_data->login_entry = table_add_entry(table, 0, "Username:", login, NULL);
    auth_data->password_entry = table_add_entry(table, 1, "Password:", password, NULL);

    gtk_entry_set_visibility(GTK_ENTRY(auth_data->password_entry), FALSE);

    GtkWidget *remember_box = gtk_vbox_new(FALSE, 6);
    gtk_box_pack_start(GTK_BOX(vbox), remember_box,
                        FALSE, FALSE, 0);

    GtkWidget *checkbutton = gtk_check_button_new_with_label("Store password");
    gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkbutton))), TRUE);
    gtk_box_pack_start(GTK_BOX(remember_box), checkbutton, FALSE, FALSE, 0);
    auth_data->checkbutton = checkbutton;

    g_signal_connect(dialog, "response", G_CALLBACK(response_callback), auth_data);
    gtk_widget_show_all(widget);
}
Exemplo n.º 7
0
static void
gimp_page_selector_init (GimpPageSelector *selector)
{
    GimpPageSelectorPrivate *priv;
    GtkWidget               *vbox;
    GtkWidget               *sw;
    GtkWidget               *hbox;
    GtkWidget               *hbbox;
    GtkWidget               *button;
    GtkWidget               *label;
    GtkWidget               *combo;

    selector->priv = G_TYPE_INSTANCE_GET_PRIVATE (selector,
                     GIMP_TYPE_PAGE_SELECTOR,
                     GimpPageSelectorPrivate);

    priv = GIMP_PAGE_SELECTOR_GET_PRIVATE (selector);

    priv->n_pages = 0;
    priv->target  = GIMP_PAGE_SELECTOR_TARGET_LAYERS;

    gtk_orientable_set_orientation (GTK_ORIENTABLE (selector),
                                    GTK_ORIENTATION_VERTICAL);

    gtk_box_set_spacing (GTK_BOX (selector), 12);

    /*  Pages  */

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
    gtk_box_pack_start (GTK_BOX (selector), vbox, TRUE, TRUE, 0);
    gtk_widget_show (vbox);

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

    priv->store = gtk_list_store_new (4,
                                      G_TYPE_INT,
                                      GDK_TYPE_PIXBUF,
                                      G_TYPE_STRING,
                                      G_TYPE_BOOLEAN);

    priv->view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (priv->store));
    gtk_icon_view_set_text_column (GTK_ICON_VIEW (priv->view),
                                   COLUMN_LABEL);
    gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->view),
                                     COLUMN_THUMBNAIL);
    gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (priv->view),
                                      GTK_SELECTION_MULTIPLE);
    gtk_container_add (GTK_CONTAINER (sw), priv->view);
    gtk_widget_show (priv->view);

    g_signal_connect (priv->view, "selection-changed",
                      G_CALLBACK (gimp_page_selector_selection_changed),
                      selector);
    g_signal_connect (priv->view, "item-activated",
                      G_CALLBACK (gimp_page_selector_item_activated),
                      selector);

    /*  Count label  */

    priv->count_label = gtk_label_new (_("Nothing selected"));
    gtk_misc_set_alignment (GTK_MISC (priv->count_label), 0.0, 0.5);
    gimp_label_set_attributes (GTK_LABEL (priv->count_label),
                               PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
                               -1);
    gtk_box_pack_start (GTK_BOX (vbox), priv->count_label, FALSE, FALSE, 0);
    gtk_widget_show (priv->count_label);

    /*  Select all button & range entry  */

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    hbbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
    gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
    gtk_widget_show (hbbox);

    button = gtk_button_new_with_mnemonic (_("Select _All"));
    gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
    gtk_widget_show (button);

    g_signal_connect_swapped (button, "clicked",
                              G_CALLBACK (gimp_page_selector_select_all),
                              selector);

    priv->range_entry = gtk_entry_new ();
    gtk_widget_set_size_request (priv->range_entry, 80, -1);
    gtk_box_pack_end (GTK_BOX (hbox), priv->range_entry, TRUE, TRUE, 0);
    gtk_widget_show (priv->range_entry);

    g_signal_connect (priv->range_entry, "focus-out-event",
                      G_CALLBACK (gimp_page_selector_range_focus_out),
                      selector);
    g_signal_connect (priv->range_entry, "activate",
                      G_CALLBACK (gimp_page_selector_range_activate),
                      selector);

    label = gtk_label_new_with_mnemonic (_("Select _range:"));
    gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->range_entry);

    /*  Target combo  */

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    label = gtk_label_new_with_mnemonic (_("Open _pages as"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    combo = gimp_prop_enum_combo_box_new (G_OBJECT (selector), "target", -1, -1);
    gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
    gtk_widget_show (combo);

    gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);

    priv->default_thumbnail =
        gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                  "text-x-generic", 32, 0, NULL);
}
Exemplo n.º 8
0
void
show_hide_advanced (GtkWidget *button, gpointer data)
{
  GtkWidget *parent, *tmp;

  GtkWidget *dialog;
  GtkWidget *vbox;
  GtkWidget *label;
  GtkWidget *check_login;
  GtkWidget *check_presenv;

  GksuContext *context = (GksuContext*)data;
  gint response;

  parent = gtk_widget_get_parent (button);
  while ((tmp = gtk_widget_get_parent (parent)) != NULL)
    parent = tmp;

  dialog = gtk_dialog_new_with_buttons (_("Advanced options"),
					GTK_WINDOW(parent),
					GTK_DIALOG_MODAL,
					GTK_STOCK_CLOSE,
					GTK_RESPONSE_CLOSE,
					NULL);
  gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
  gtk_container_set_border_width (GTK_CONTAINER(dialog), 4);

  /* vbox points to the dialog's vbox */
  vbox = GTK_DIALOG(dialog)->vbox;
  gtk_box_set_spacing (GTK_BOX(vbox), 3);

  /* label */
  label = gtk_label_new ("");
  gtk_label_set_markup (GTK_LABEL(label),
			_("<b>Options to use when changing user</b>"));
  gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 5);
  gtk_widget_show (label);

  /* login shell? (--login) */
  check_login = gtk_check_button_new_with_mnemonic (_("_login shell"));
  if (gksu_context_get_login_shell (context) == TRUE) /* window may have been opened before */
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check_login), TRUE);
  gtk_box_pack_start (GTK_BOX(vbox), check_login, TRUE, TRUE, 0);
  gtk_widget_show (check_login);

  /* preserve environment (--preserve-env) */
  check_presenv =
    gtk_check_button_new_with_mnemonic (_("_preserve environment"));
  if (gksu_context_get_keep_env (context) == TRUE)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check_presenv), TRUE);
  gtk_box_pack_start (GTK_BOX(vbox), check_presenv, TRUE, TRUE, 0);
  gtk_widget_show (check_presenv);

  response = gtk_dialog_run (GTK_DIALOG(dialog));

  if (response == GTK_RESPONSE_NONE)
    return;

  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check_login)))
    gksu_context_set_login_shell (context, TRUE);
  else
    gksu_context_set_login_shell (context, FALSE);

  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check_presenv)))
    gksu_context_set_keep_env (context, TRUE);
  else
    gksu_context_set_keep_env (context, FALSE);

  gtk_widget_destroy (dialog);
}
Exemplo n.º 9
0
static void
on_game_scores (GtkMenuItem * m, gpointer data)
{
  GtkWidget *grid, *grid2, *icon;

  if (scorebox != NULL) {
    gtk_window_present (GTK_WINDOW (scorebox));
    return;
  }

  scorebox = gtk_dialog_new_with_buttons (_("Scores"),
					  GTK_WINDOW (app),
					  GTK_DIALOG_DESTROY_WITH_PARENT,
					  GTK_STOCK_CLOSE,
					  GTK_RESPONSE_CLOSE, NULL);

  gtk_window_set_resizable (GTK_WINDOW (scorebox), FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (scorebox), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (scorebox))), 2);

  g_signal_connect (scorebox, "destroy",
		    G_CALLBACK (gtk_widget_destroyed), &scorebox);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
  gtk_container_set_border_width (GTK_CONTAINER (grid), 5);

  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (scorebox))),
		      grid, TRUE, TRUE, 0);

  icon = gtk_image_new_from_icon_name ("gnect", 48);
  gtk_container_add (GTK_CONTAINER (grid), icon);

  grid2 = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (grid), grid2);
  gtk_grid_set_column_spacing (GTK_GRID (grid2), 6);

  label_name[PLAYER1] = gtk_label_new (NULL);
  gtk_grid_attach (GTK_GRID (grid2), label_name[PLAYER1], 0, 0, 1, 1);
  gtk_misc_set_alignment (GTK_MISC (label_name[PLAYER1]), 0, 0.5);

  label_score[PLAYER1] = gtk_label_new (NULL);
  gtk_grid_attach (GTK_GRID (grid2), label_score[PLAYER1], 1, 0, 1, 1);
  gtk_misc_set_alignment (GTK_MISC (label_score[PLAYER1]), 1, 0.5);

  label_name[PLAYER2] = gtk_label_new (NULL);
  gtk_grid_attach (GTK_GRID (grid2), label_name[PLAYER2], 0, 1, 1, 1);
  gtk_misc_set_alignment (GTK_MISC (label_name[PLAYER2]), 0, 0.5);

  label_score[PLAYER2] = gtk_label_new (NULL);
  gtk_grid_attach (GTK_GRID (grid2), label_score[PLAYER2], 1, 1, 1, 1);
  gtk_misc_set_alignment (GTK_MISC (label_score[PLAYER2]), 1, 0.5);

  label_name[NOBODY] = gtk_label_new (_("Drawn:"));
  gtk_grid_attach (GTK_GRID (grid2), label_name[NOBODY], 0, 2, 1, 1);
  gtk_misc_set_alignment (GTK_MISC (label_name[NOBODY]), 0, 0.5);

  label_score[NOBODY] = gtk_label_new (NULL);
  gtk_grid_attach (GTK_GRID (grid2), label_score[NOBODY], 1, 2, 1, 1);
  gtk_misc_set_alignment (GTK_MISC (label_score[NOBODY]), 1, 0.5);

  g_signal_connect (GTK_DIALOG (scorebox), "response",
		    G_CALLBACK (on_dialog_close), NULL);

  gtk_widget_show_all (scorebox);

  scorebox_update ();
}
Exemplo n.º 10
0
static void games_scores_dialog_init (GamesScoresDialog *self) 
{
  GtkWidget *vbox;
  GtkWidget *scroll;
  GtkWidget *listview;
  GtkTreeViewColumn *column;
  GtkTreeViewColumn *timecolumn;
  GtkCellRenderer *renderer;
  GtkCellRenderer *timerenderer;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GAMES_TYPE_SCORES_DIALOG,
                                            GamesScoresDialogPrivate);

  self->priv->style = GAMES_SCORES_STYLE_PLAIN_DESCENDING;
  /* These two hashes are the reverse of each other. As an optimisation 
   * they share the same set of strings (as keys in the first case and
   * as data in the second). The first hash is responsible for 
   * deallocating the memory for the strings. These two are only
   * valid as a pair. */
  self->priv->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
						     g_free, NULL);
  self->priv->catindices = g_hash_table_new (g_direct_hash, g_direct_equal);
  self->priv->catcounter = 0;
  self->priv->hilight = 0;
  gtk_container_set_border_width (GTK_CONTAINER (self), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2);

  g_signal_connect (G_OBJECT (self), "show", 
		      G_CALLBACK (games_scores_dialog_show), NULL);
  g_signal_connect (G_OBJECT (self), "hide", 
		      G_CALLBACK (games_scores_dialog_hide), NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
  gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))),
                    vbox, TRUE, TRUE, 0);

  scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
				    GTK_POLICY_AUTOMATIC,
				    GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request (scroll, 200, 265);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
					 GTK_SHADOW_ETCHED_IN);
  gtk_box_pack_end (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
  
  self->priv->message = gtk_label_new ("");
  gtk_label_set_use_markup (GTK_LABEL (self->priv->message), TRUE);
  gtk_label_set_justify (GTK_LABEL (self->priv->message), 
	                   GTK_JUSTIFY_CENTER);    
  gtk_box_pack_start (GTK_BOX (vbox), self->priv->message, FALSE, FALSE, 0);

  self->priv->hdiv = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (GTK_BOX (vbox), self->priv->hdiv, FALSE, FALSE, 0);

  self->priv->catbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_box_pack_start (GTK_BOX (vbox), self->priv->catbar, FALSE, FALSE, 0);

  self->priv->label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (self->priv->label), TRUE);
  gtk_box_pack_start (GTK_BOX (self->priv->catbar), self->priv->label,
			FALSE, FALSE, 0);	
 
  self->priv->combo = gtk_combo_box_text_new ();
  gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (self->priv->combo), FALSE);
  gtk_box_pack_start (GTK_BOX (self->priv->catbar), 
			self->priv->combo, TRUE, TRUE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (self->priv->label), self->priv->combo);

  g_signal_connect (G_OBJECT (self->priv->combo), "changed", 
		      G_CALLBACK (games_scores_dialog_change_category), self);

  self->priv->list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);

  listview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (self->priv->list));
  self->priv->treeview = GTK_TREE_VIEW (listview);

  timerenderer = gtk_cell_renderer_text_new ();
  timecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the date the score was recorded */
                                                         _("Date"),
                                                         timerenderer,
                                                         "text", 0,
                                                         NULL);
  g_object_set (G_OBJECT (timerenderer), "xalign", 1.0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
                               GTK_TREE_VIEW_COLUMN (timecolumn));
  self->priv->timecolumn = timecolumn;

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", 1, NULL);
  g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
				 GTK_TREE_VIEW_COLUMN (column));
  self->priv->column = column;
 
  gtk_container_add (GTK_CONTAINER (scroll), listview);
  
  games_scores_dialog_set_buttons (self, GAMES_SCORES_CLOSE_BUTTON);

  gtk_window_set_destroy_with_parent (GTK_WINDOW (self), TRUE);

  gtk_widget_grab_focus (self->priv->combo);

  gtk_widget_show_all (vbox);
  gtk_widget_hide (self->priv->hdiv);
  gtk_widget_hide (self->priv->message);
}
Exemplo n.º 11
0
void
properties_cb (GtkAction  *action,
	       EyesApplet *eyes_applet)
{
	GtkWidget *pbox, *hbox;
	GtkWidget *vbox, *indent;
	GtkWidget *categories_vbox;
	GtkWidget *category_vbox, *control_vbox;
        GtkWidget *tree;
	GtkWidget *scrolled;
        GtkWidget *label;
        GtkListStore *model;
        GtkTreeViewColumn *column;
        GtkCellRenderer *cell;
        GtkTreeSelection *selection;
        GtkTreeIter iter;
        DIR *dfd;
        struct dirent *dp;
        int i;
#ifdef PATH_MAX
        gchar filename [PATH_MAX];
#else
	gchar *filename;
#endif
        gchar *title;

	if (eyes_applet->prop_box.pbox) {
		gtk_window_set_screen (
			GTK_WINDOW (eyes_applet->prop_box.pbox),
			gtk_widget_get_screen (GTK_WIDGET (eyes_applet->applet)));
		gtk_window_present (GTK_WINDOW (eyes_applet->prop_box.pbox));
		return;
	}

        pbox = gtk_dialog_new_with_buttons (_("Geyes Preferences"), NULL,
        				     GTK_DIALOG_DESTROY_WITH_PARENT,
					     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
					     GTK_STOCK_HELP, GTK_RESPONSE_HELP,
					     NULL);

	gtk_window_set_screen (GTK_WINDOW (pbox),
			       gtk_widget_get_screen (GTK_WIDGET (eyes_applet->applet)));

	gtk_widget_set_size_request (GTK_WIDGET (pbox), 300, 200);
        gtk_dialog_set_default_response(GTK_DIALOG (pbox), GTK_RESPONSE_CLOSE);
        gtk_dialog_set_has_separator (GTK_DIALOG (pbox), FALSE);
        gtk_container_set_border_width (GTK_CONTAINER (pbox), 5);
	gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pbox))), 2);

        g_signal_connect (pbox, "response",
			  G_CALLBACK (presponse_cb),
			  eyes_applet);

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

	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pbox))), vbox,
			    TRUE, TRUE, 0);

	categories_vbox = gtk_vbox_new (FALSE, 18);
	gtk_box_pack_start (GTK_BOX (vbox), categories_vbox, TRUE, TRUE, 0);
	gtk_widget_show (categories_vbox);

	category_vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
	gtk_widget_show (category_vbox);

	title = g_strconcat ("<span weight=\"bold\">", _("Themes"), "</span>", NULL);
	label = gtk_label_new (_(title));
	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
	gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
	g_free (title);

	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
	gtk_widget_show (hbox);

	indent = gtk_label_new (HIG_IDENTATION);
	gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
	gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
	gtk_widget_show (indent);

	control_vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
	gtk_widget_show (control_vbox);

	label = gtk_label_new_with_mnemonic (_("_Select a theme:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
	gtk_box_pack_start (GTK_BOX (control_vbox), label, FALSE, FALSE, 0);

	scrolled = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);

	model = gtk_list_store_new (TOTAL_COLS, G_TYPE_STRING, G_TYPE_STRING);
	tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree), FALSE);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree);
	g_object_unref (model);

	gtk_container_add (GTK_CONTAINER (scrolled), tree);

	cell = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("not used", cell,
                                                           "text", COL_THEME_NAME, NULL);
        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);

        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
	g_signal_connect (selection, "changed",
			  G_CALLBACK (theme_selected_cb),
			  eyes_applet);

	if ( ! key_writable (eyes_applet->applet, "theme_path")) {
		gtk_widget_set_sensitive (tree, FALSE);
		gtk_widget_set_sensitive (label, FALSE);
	}

        for (i = 0; i < NUM_THEME_DIRECTORIES; i++) {
                if ((dfd = opendir (theme_directories[i])) != NULL) {
                        while ((dp = readdir (dfd)) != NULL) {
                                if (dp->d_name[0] != '.') {
                                        gchar *theme_dir;
					gchar *theme_name;
#ifdef PATH_MAX
                                        strcpy (filename,
                                                theme_directories[i]);
                                        strcat (filename, dp->d_name);
#else
					asprintf (&filename, theme_directories[i], dp->d_name);
#endif
					theme_dir = g_strdup_printf ("%s/", filename);
					theme_name = g_path_get_basename (filename);

                                        gtk_list_store_append (model, &iter);
                                        gtk_list_store_set (model, &iter,
							    COL_THEME_DIR, &filename,
							    COL_THEME_NAME, theme_name,
							    -1);

					if (!g_ascii_strncasecmp (eyes_applet->theme_dir, theme_dir, strlen (theme_dir))) {
                                        	GtkTreePath *path;
                                        	path = gtk_tree_model_get_path (GTK_TREE_MODEL (model),
                                                        			&iter);
                                                gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree),
                                                			  path,
                                                			  NULL,
                                                			  FALSE);
                                                gtk_tree_path_free (path);
                                        }
					g_free (theme_name);
                                        g_free (theme_dir);
                                }
                        }
                        closedir (dfd);
                }
        }
#ifndef PATH_MAX
	g_free (filename);
#endif

        gtk_box_pack_start (GTK_BOX (control_vbox), scrolled, TRUE, TRUE, 0);

        gtk_widget_show_all (pbox);

        eyes_applet->prop_box.pbox = pbox;

	return;
}
Exemplo n.º 12
0
static TBEditorWidget *tb_editor_create_dialog(MidoriBrowser *parent)
{
	GtkWidget *dialog, *vbox, *hbox, *vbox_buttons, *button_add, *button_remove;
	GtkWidget *swin_available, *swin_used, *tree_available, *tree_used, *label;
	GtkCellRenderer *text_renderer, *icon_renderer;
	GtkTreeViewColumn *column;
	TBEditorWidget *tbw = g_new(TBEditorWidget, 1);

	dialog = gtk_dialog_new_with_buttons(_("Customize Toolbar"),
				GTK_WINDOW(parent),
				GTK_DIALOG_DESTROY_WITH_PARENT,
				GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
	vbox = (GTK_DIALOG(dialog))->vbox;
	gtk_box_set_spacing(GTK_BOX(vbox), 6);
	gtk_widget_set_name(dialog, "GeanyDialog");
	gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 400);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);

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

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

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

	icon_renderer = gtk_cell_renderer_pixbuf_new();
	column = gtk_tree_view_column_new_with_attributes(
		NULL, icon_renderer, "stock-id", TB_EDITOR_COL_ICON, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);

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

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

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

	icon_renderer = gtk_cell_renderer_pixbuf_new();
	column = gtk_tree_view_column_new_with_attributes(
		NULL, icon_renderer, "stock-id", TB_EDITOR_COL_ICON, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);

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

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

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

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


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

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

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

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

	gtk_widget_show_all(vbox);

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

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

	tbw->last_drag_path = NULL;

	return tbw;
}
Exemplo n.º 13
0
unsigned char leverage_data_dialog (void)
{
    struct flag_info *finfo;
    GtkWidget *dialog, *tmp, *button, *vbox, *hbox;
    GtkWidget *internal_vbox;
    unsigned char flag = SAVE_LEVERAGE | SAVE_INFLUENCE | SAVE_DFFITS;

    finfo = malloc(sizeof *finfo);
    if (finfo == NULL) return 0;

    dialog = gtk_dialog_new();

    finfo->dialog = dialog;
    finfo->flag = &flag;

    vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    hbox = gtk_dialog_get_action_area(GTK_DIALOG(dialog));
    
    gtk_window_set_title(GTK_WINDOW(dialog), _("gretl: save data")); 
    gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
    gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
    gtk_box_set_spacing(GTK_BOX(vbox), 5);

    gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);

    g_signal_connect(G_OBJECT(dialog), "destroy", 
		     G_CALLBACK(destroy_save_dialog), finfo);

    internal_vbox = gtk_vbox_new(FALSE, 5);

    hbox = gtk_hbox_new(FALSE, 5);
    tmp = gtk_label_new(_("Variables to save:"));
    gtk_box_pack_start(GTK_BOX(hbox), tmp, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(internal_vbox), hbox, TRUE, TRUE, 5);

    /* Leverage */
    button = gtk_check_button_new_with_label(_("leverage"));
    gtk_box_pack_start(GTK_BOX(internal_vbox), button, TRUE, TRUE, 0);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
    g_signal_connect(G_OBJECT(button), "clicked",
		     G_CALLBACK(update_save_flag), finfo);
    finfo->levcheck = button;

    /* Influence */
    button = gtk_check_button_new_with_label(_("influence"));
    gtk_box_pack_start(GTK_BOX(internal_vbox), button, TRUE, TRUE, 0);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
    g_signal_connect(G_OBJECT(button), "clicked",
		     G_CALLBACK(update_save_flag), finfo);
    finfo->infcheck = button;

    /* DFFITS */
    button = gtk_check_button_new_with_label(_("DFFITS"));
    gtk_box_pack_start(GTK_BOX(internal_vbox), button, TRUE, TRUE, 0);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
    g_signal_connect(G_OBJECT(button), "clicked",
		     G_CALLBACK(update_save_flag), finfo);
    finfo->dffcheck = button;

    hbox = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX(hbox), internal_vbox, TRUE, TRUE, 5);

    gtk_widget_show(internal_vbox);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);

    hbox = gtk_dialog_get_action_area(GTK_DIALOG(dialog));
    gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
    gtk_box_set_spacing(GTK_BOX(hbox), 10);

    /* Cancel button */
    tmp = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_container_add(GTK_CONTAINER(hbox), tmp);
    g_signal_connect(G_OBJECT(tmp), "clicked",
		     G_CALLBACK(cancel_set_flag), finfo);

    /* "OK" button */
    tmp = gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_container_add(GTK_CONTAINER(hbox), tmp);
    g_signal_connect(G_OBJECT(tmp), "clicked",
		     G_CALLBACK(save_dialog_finalize), finfo);
    gtk_widget_set_can_default(tmp, TRUE);
    gtk_widget_grab_default(tmp);

    gtk_widget_show_all(dialog);

    gtk_main();

    return flag;
}
Exemplo n.º 14
0
GtkWidget*
create_windowEditHabit (void)
{
  GtkWidget *windowEditHabit;
  GtkWidget *vboxHabit;
  GtkWidget *vbox6;
  GtkWidget *hbox4;
  GtkWidget *label12;
  GtkWidget *entryHabitName;
  GtkWidget *frameDate;
  GtkWidget *vboxQuittime;
  GtkWidget *hboxQuitDatePart;
  GtkWidget *labelDay;
  GtkWidget *entryDay;
  GtkWidget *labelMonth;
  GtkWidget *entryMonth;
  GtkWidget *labelYear;
  GtkWidget *entryYear;
  GtkWidget *vseparator1;
  GtkWidget *labelHour;
  GtkWidget *entryHour;
  GtkWidget *labelMinute;
  GtkWidget *entryMinute;
  GtkWidget *labelDate;
  GtkWidget *frameHabit;
  GtkWidget *tableHabitDetails;
  GtkWidget *labelUnitsPerPack;
  GtkWidget *labelPricePerPack;
  GtkWidget *entryUnitsPerPack;
  GtkWidget *entryPricePerPack;
  GtkWidget *entryUnitsPerDay;
  GtkWidget *labelUnitsPerDay;
  GtkWidget *labelDetails;
  GtkWidget *hbuttonbox4;
  GtkWidget *buttonCancel;
  GtkWidget *buttonApply;

  windowEditHabit = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (windowEditHabit, "windowEditHabit");
  gtk_window_set_title (GTK_WINDOW (windowEditHabit), "Habit");
  gtk_window_set_modal (GTK_WINDOW (windowEditHabit), TRUE);
  gtk_window_set_resizable (GTK_WINDOW (windowEditHabit), FALSE);

  vboxHabit = gtk_vbox_new (FALSE, 5);
  gtk_widget_set_name (vboxHabit, "vboxHabit");
  gtk_widget_show (vboxHabit);
  gtk_container_add (GTK_CONTAINER (windowEditHabit), vboxHabit);
  gtk_container_set_border_width (GTK_CONTAINER (vboxHabit), 3);

  vbox6 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox6, "vbox6");
  gtk_widget_show (vbox6);
  gtk_box_pack_start (GTK_BOX (vboxHabit), vbox6, TRUE, TRUE, 0);

  hbox4 = gtk_hbox_new (FALSE, 5);
  gtk_widget_set_name (hbox4, "hbox4");
  gtk_widget_show (hbox4);
  gtk_box_pack_start (GTK_BOX (vbox6), hbox4, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox4), 3);

  label12 = gtk_label_new ("Name of this nasty habit");
  gtk_widget_set_name (label12, "label12");
  gtk_widget_show (label12);
  gtk_box_pack_start (GTK_BOX (hbox4), label12, FALSE, FALSE, 0);

  entryHabitName = gtk_entry_new ();
  gtk_widget_set_name (entryHabitName, "entryHabitName");
  gtk_widget_show (entryHabitName);
  gtk_box_pack_start (GTK_BOX (hbox4), entryHabitName, FALSE, FALSE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryHabitName), 20);
  gtk_entry_set_width_chars (GTK_ENTRY (entryHabitName), 21);

  frameDate = gtk_frame_new (NULL);
  gtk_widget_set_name (frameDate, "frameDate");
  gtk_widget_show (frameDate);
  gtk_box_pack_start (GTK_BOX (vbox6), frameDate, TRUE, TRUE, 0);

  vboxQuittime = gtk_vbox_new (FALSE, 3);
  gtk_widget_set_name (vboxQuittime, "vboxQuittime");
  gtk_widget_show (vboxQuittime);
  gtk_container_add (GTK_CONTAINER (frameDate), vboxQuittime);
  gtk_container_set_border_width (GTK_CONTAINER (vboxQuittime), 5);

  hboxQuitDatePart = gtk_hbox_new (FALSE, 5);
  gtk_widget_set_name (hboxQuitDatePart, "hboxQuitDatePart");
  gtk_widget_show (hboxQuitDatePart);
  gtk_box_pack_start (GTK_BOX (vboxQuittime), hboxQuitDatePart, TRUE, TRUE, 0);

  labelDay = gtk_label_new ("Day");
  gtk_widget_set_name (labelDay, "labelDay");
  gtk_widget_show (labelDay);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), labelDay, FALSE, FALSE, 0);

  entryDay = gtk_entry_new ();
  gtk_widget_set_name (entryDay, "entryDay");
  gtk_widget_show (entryDay);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), entryDay, FALSE, FALSE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryDay), 2);
  gtk_entry_set_width_chars (GTK_ENTRY (entryDay), 3);

  labelMonth = gtk_label_new ("Month");
  gtk_widget_set_name (labelMonth, "labelMonth");
  gtk_widget_show (labelMonth);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), labelMonth, FALSE, FALSE, 0);

  entryMonth = gtk_entry_new ();
  gtk_widget_set_name (entryMonth, "entryMonth");
  gtk_widget_show (entryMonth);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), entryMonth, FALSE, FALSE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryMonth), 2);
  gtk_entry_set_width_chars (GTK_ENTRY (entryMonth), 3);

  labelYear = gtk_label_new ("Year");
  gtk_widget_set_name (labelYear, "labelYear");
  gtk_widget_show (labelYear);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), labelYear, FALSE, FALSE, 0);

  entryYear = gtk_entry_new ();
  gtk_widget_set_name (entryYear, "entryYear");
  gtk_widget_show (entryYear);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), entryYear, FALSE, FALSE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryYear), 4);
  gtk_entry_set_width_chars (GTK_ENTRY (entryYear), 5);

  vseparator1 = gtk_vseparator_new ();
  gtk_widget_set_name (vseparator1, "vseparator1");
  gtk_widget_show (vseparator1);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), vseparator1, TRUE, TRUE, 0);

  labelHour = gtk_label_new ("Hour");
  gtk_widget_set_name (labelHour, "labelHour");
  gtk_widget_show (labelHour);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), labelHour, FALSE, FALSE, 0);

  entryHour = gtk_entry_new ();
  gtk_widget_set_name (entryHour, "entryHour");
  gtk_widget_show (entryHour);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), entryHour, TRUE, TRUE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryHour), 2);
  gtk_entry_set_width_chars (GTK_ENTRY (entryHour), 3);

  labelMinute = gtk_label_new ("Minute");
  gtk_widget_set_name (labelMinute, "labelMinute");
  gtk_widget_show (labelMinute);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), labelMinute, FALSE, FALSE, 0);

  entryMinute = gtk_entry_new ();
  gtk_widget_set_name (entryMinute, "entryMinute");
  gtk_widget_show (entryMinute);
  gtk_box_pack_start (GTK_BOX (hboxQuitDatePart), entryMinute, TRUE, TRUE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryMinute), 2);
  gtk_entry_set_width_chars (GTK_ENTRY (entryMinute), 3);

  labelDate = gtk_label_new ("<b> Quit date </b>");
  gtk_widget_set_name (labelDate, "labelDate");
  gtk_widget_show (labelDate);
  gtk_frame_set_label_widget (GTK_FRAME (frameDate), labelDate);
  gtk_label_set_use_markup (GTK_LABEL (labelDate), TRUE);

  frameHabit = gtk_frame_new (NULL);
  gtk_widget_set_name (frameHabit, "frameHabit");
  gtk_widget_show (frameHabit);
  gtk_box_pack_start (GTK_BOX (vbox6), frameHabit, TRUE, TRUE, 0);

  tableHabitDetails = gtk_table_new (3, 2, FALSE);
  gtk_widget_set_name (tableHabitDetails, "tableHabitDetails");
  gtk_widget_show (tableHabitDetails);
  gtk_container_add (GTK_CONTAINER (frameHabit), tableHabitDetails);
  gtk_container_set_border_width (GTK_CONTAINER (tableHabitDetails), 5);
  gtk_table_set_row_spacings (GTK_TABLE (tableHabitDetails), 2);
  gtk_table_set_col_spacings (GTK_TABLE (tableHabitDetails), 3);

  labelUnitsPerPack = gtk_label_new ("Units per pack");
  gtk_widget_set_name (labelUnitsPerPack, "labelUnitsPerPack");
  gtk_widget_show (labelUnitsPerPack);
  gtk_table_attach (GTK_TABLE (tableHabitDetails), labelUnitsPerPack, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelUnitsPerPack), 0, 0.5);

  labelPricePerPack = gtk_label_new ("Price per pack");
  gtk_widget_set_name (labelPricePerPack, "labelPricePerPack");
  gtk_widget_show (labelPricePerPack);
  gtk_table_attach (GTK_TABLE (tableHabitDetails), labelPricePerPack, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelPricePerPack), 0, 0.5);

  entryUnitsPerPack = gtk_entry_new ();
  gtk_widget_set_name (entryUnitsPerPack, "entryUnitsPerPack");
  gtk_widget_show (entryUnitsPerPack);
  gtk_table_attach (GTK_TABLE (tableHabitDetails), entryUnitsPerPack, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryUnitsPerPack), 5);
  gtk_entry_set_width_chars (GTK_ENTRY (entryUnitsPerPack), 6);

  entryPricePerPack = gtk_entry_new ();
  gtk_widget_set_name (entryPricePerPack, "entryPricePerPack");
  gtk_widget_show (entryPricePerPack);
  gtk_table_attach (GTK_TABLE (tableHabitDetails), entryPricePerPack, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryPricePerPack), 5);
  gtk_entry_set_width_chars (GTK_ENTRY (entryPricePerPack), 6);

  entryUnitsPerDay = gtk_entry_new ();
  gtk_widget_set_name (entryUnitsPerDay, "entryUnitsPerDay");
  gtk_widget_show (entryUnitsPerDay);
  gtk_table_attach (GTK_TABLE (tableHabitDetails), entryUnitsPerDay, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryUnitsPerDay), 5);
  gtk_entry_set_width_chars (GTK_ENTRY (entryUnitsPerDay), 6);

  labelUnitsPerDay = gtk_label_new ("Units used per day");
  gtk_widget_set_name (labelUnitsPerDay, "labelUnitsPerDay");
  gtk_widget_show (labelUnitsPerDay);
  gtk_table_attach (GTK_TABLE (tableHabitDetails), labelUnitsPerDay, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (labelUnitsPerDay), 0, 0.5);

  labelDetails = gtk_label_new ("<b> Habit details </b>");
  gtk_widget_set_name (labelDetails, "labelDetails");
  gtk_widget_show (labelDetails);
  gtk_frame_set_label_widget (GTK_FRAME (frameHabit), labelDetails);
  gtk_label_set_use_markup (GTK_LABEL (labelDetails), TRUE);

  hbuttonbox4 = gtk_hbutton_box_new ();
  gtk_widget_set_name (hbuttonbox4, "hbuttonbox4");
  gtk_widget_show (hbuttonbox4);
  gtk_box_pack_start (GTK_BOX (vboxHabit), hbuttonbox4, FALSE, TRUE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox4), GTK_BUTTONBOX_END);
  gtk_box_set_spacing (GTK_BOX (hbuttonbox4), 5);

  buttonCancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_set_name (buttonCancel, "buttonCancel");
  gtk_widget_show (buttonCancel);
  gtk_container_add (GTK_CONTAINER (hbuttonbox4), buttonCancel);
  GTK_WIDGET_SET_FLAGS (buttonCancel, GTK_CAN_DEFAULT);

  buttonApply = gtk_button_new_from_stock ("gtk-apply");
  gtk_widget_set_name (buttonApply, "buttonApply");
  gtk_widget_show (buttonApply);
  gtk_container_add (GTK_CONTAINER (hbuttonbox4), buttonApply);
  GTK_WIDGET_SET_FLAGS (buttonApply, GTK_CAN_DEFAULT);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (windowEditHabit, windowEditHabit, "windowEditHabit");
  GLADE_HOOKUP_OBJECT (windowEditHabit, vboxHabit, "vboxHabit");
  GLADE_HOOKUP_OBJECT (windowEditHabit, vbox6, "vbox6");
  GLADE_HOOKUP_OBJECT (windowEditHabit, hbox4, "hbox4");
  GLADE_HOOKUP_OBJECT (windowEditHabit, label12, "label12");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryHabitName, "entryHabitName");
  GLADE_HOOKUP_OBJECT (windowEditHabit, frameDate, "frameDate");
  GLADE_HOOKUP_OBJECT (windowEditHabit, vboxQuittime, "vboxQuittime");
  GLADE_HOOKUP_OBJECT (windowEditHabit, hboxQuitDatePart, "hboxQuitDatePart");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelDay, "labelDay");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryDay, "entryDay");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelMonth, "labelMonth");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryMonth, "entryMonth");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelYear, "labelYear");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryYear, "entryYear");
  GLADE_HOOKUP_OBJECT (windowEditHabit, vseparator1, "vseparator1");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelHour, "labelHour");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryHour, "entryHour");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelMinute, "labelMinute");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryMinute, "entryMinute");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelDate, "labelDate");
  GLADE_HOOKUP_OBJECT (windowEditHabit, frameHabit, "frameHabit");
  GLADE_HOOKUP_OBJECT (windowEditHabit, tableHabitDetails, "tableHabitDetails");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelUnitsPerPack, "labelUnitsPerPack");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelPricePerPack, "labelPricePerPack");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryUnitsPerPack, "entryUnitsPerPack");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryPricePerPack, "entryPricePerPack");
  GLADE_HOOKUP_OBJECT (windowEditHabit, entryUnitsPerDay, "entryUnitsPerDay");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelUnitsPerDay, "labelUnitsPerDay");
  GLADE_HOOKUP_OBJECT (windowEditHabit, labelDetails, "labelDetails");
  GLADE_HOOKUP_OBJECT (windowEditHabit, hbuttonbox4, "hbuttonbox4");
  GLADE_HOOKUP_OBJECT (windowEditHabit, buttonCancel, "buttonCancel");
  GLADE_HOOKUP_OBJECT (windowEditHabit, buttonApply, "buttonApply");

  return windowEditHabit;
}
Exemplo n.º 15
0
static void create_window (void)
{
    jump_to_track_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_type_hint(GTK_WINDOW(jump_to_track_win),
                             GDK_WINDOW_TYPE_HINT_DIALOG);

    gtk_window_set_title(GTK_WINDOW(jump_to_track_win), _("Jump to Song"));

    g_signal_connect (jump_to_track_win, "key_press_event", (GCallback) keypress_cb, NULL);
    g_signal_connect (jump_to_track_win, "delete-event", (GCallback) delete_cb, NULL);

    gtk_container_set_border_width(GTK_CONTAINER(jump_to_track_win), 10);
    gtk_window_set_default_size(GTK_WINDOW(jump_to_track_win), 600, 500);

    GtkWidget * vbox = gtk_vbox_new (FALSE, 5);
    gtk_container_add(GTK_CONTAINER(jump_to_track_win), vbox);

    treeview = mlpgui_list_new (& callbacks, NULL, 0);
    gtk_tree_view_set_headers_visible ((GtkTreeView *) treeview, FALSE);

    mlpgui_list_add_column (treeview, NULL, 0, G_TYPE_INT, 7);
    mlpgui_list_add_column (treeview, NULL, 1, G_TYPE_STRING, -1);

    g_signal_connect (gtk_tree_view_get_selection ((GtkTreeView *) treeview),
     "changed", (GCallback) selection_changed, NULL);
    g_signal_connect (treeview, "row-activated", (GCallback) do_jump, NULL);

    GtkWidget * hbox = gtk_hbox_new (FALSE, 3);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);

    /* filter box */
    GtkWidget * search_label = gtk_label_new (_("Filter: "));
    gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), _("_Filter:"));
    gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0);

    filter_entry = gtk_entry_new ();
    gtk_label_set_mnemonic_widget ((GtkLabel *) search_label, filter_entry);
    g_signal_connect (filter_entry, "changed", (GCallback) fill_list, NULL);
    gtk_entry_set_activates_default ((GtkEntry *) filter_entry, TRUE);
    gtk_box_pack_start ((GtkBox *) hbox, filter_entry, TRUE, TRUE, 3);

    /* remember text entry */
    GtkWidget * toggle2 = gtk_check_button_new_with_label (_("Remember"));
    gtk_toggle_button_set_active ((GtkToggleButton *) toggle2, mlp_get_bool
     ("mlpgui", "remember_jtf_entry"));
    gtk_box_pack_start(GTK_BOX(hbox), toggle2, FALSE, FALSE, 0);
    g_signal_connect (toggle2, "clicked", (GCallback) toggle_button_cb, "remember_jtf_entry");

    /* clear button */
    GtkWidget * rescan = gtk_button_new_with_mnemonic (_("Clea_r"));
    gtk_button_set_image ((GtkButton *) rescan, gtk_image_new_from_stock
     (GTK_STOCK_CLEAR, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start(GTK_BOX(hbox), rescan, FALSE, FALSE, 0);
    g_signal_connect (rescan, "clicked", (GCallback) clear_cb, NULL);

    GtkWidget * scrollwin = gtk_scrolled_window_new (NULL, NULL);
    gtk_container_add(GTK_CONTAINER(scrollwin), treeview);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin),
                                        GTK_SHADOW_IN);
    gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0);

    GtkWidget * bbox = gtk_hbutton_box_new ();
    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
    gtk_box_set_spacing(GTK_BOX(bbox), 4);
    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);

    /* close dialog toggle */
    GtkWidget * toggle = gtk_check_button_new_with_label(_("Close on Jump"));
    gtk_toggle_button_set_active ((GtkToggleButton *) toggle, mlp_get_bool
     ("mlpgui", "close_jtf_dialog"));
    gtk_box_pack_start(GTK_BOX(bbox), toggle, FALSE, FALSE, 0);
    g_signal_connect (toggle, "clicked", (GCallback) toggle_button_cb, "close_jtf_dialog");

    /* queue button */
    queue_button = gtk_button_new_with_mnemonic(_("_Queue"));
    gtk_button_set_image ((GtkButton *) queue_button, gtk_image_new_from_stock
     (AUD_STOCK_QUEUETOGGLE, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start ((GtkBox *) bbox, queue_button, FALSE, FALSE, 0);

    g_signal_connect (queue_button, "clicked", (GCallback) do_queue, NULL);

    /* jump button */
    GtkWidget * jump = gtk_button_new_from_stock (GTK_STOCK_JUMP_TO);
    gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0);

    g_signal_connect (jump, "clicked", (GCallback) do_jump, NULL);

    gtk_widget_set_can_default(jump, TRUE);
    gtk_widget_grab_default(jump);

    /* close button */
    GtkWidget * close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
    gtk_box_pack_start(GTK_BOX(bbox), close, FALSE, FALSE, 0);
    g_signal_connect (close, "clicked", (GCallback) mlpgui_jump_to_track_hide,
     NULL);
    gtk_widget_set_can_default(close, TRUE);
}
Exemplo n.º 16
0
static gboolean
confirm_delete_immediately (GtkWidget *parent_view,
                            gint num_files,
                            gboolean all)
{
  GdkScreen *screen;
  GtkWidget *dialog, *hbox, *vbox, *image, *label;
  gchar *str, *prompt, *detail;
  int response;

  screen = gtk_widget_get_screen (parent_view);

  dialog = gtk_dialog_new ();
  gtk_window_set_screen (GTK_WINDOW (dialog), screen);
  atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
  gtk_window_set_title (GTK_WINDOW (dialog), _("Delete Immediately?"));
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

  gtk_widget_realize (dialog);
  gdk_window_set_transient_for (gtk_widget_get_window (GTK_WIDGET (dialog)),
                                gdk_screen_get_root_window (screen));
  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14);

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
  gtk_widget_show (hbox);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox,
                      FALSE, FALSE, 0);

  image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION,
                                    GTK_ICON_SIZE_DIALOG);
  gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
  gtk_widget_show (image);
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);

  vbox = gtk_vbox_new (FALSE, 12);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  if (all)
    {
      prompt = _("Cannot move items to trash, do you want to delete them immediately?");
      detail = g_strdup_printf ("None of the %d selected items can be moved to the Trash", num_files);
    }
  else
    {
      prompt = _("Cannot move some items to trash, do you want to delete these immediately?");
      detail = g_strdup_printf ("%d of the selected items cannot be moved to the Trash", num_files);
    }

  str = g_strconcat ("<span weight=\"bold\" size=\"larger\">",
                     prompt, "</span>", NULL);
  label = gtk_label_new (str);
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);
  g_free (str);

  label = gtk_label_new (detail);
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);
  g_free (detail);

  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
                         GTK_RESPONSE_CANCEL);
  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_DELETE,
                         GTK_RESPONSE_YES);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
                                   GTK_RESPONSE_YES);

  response = gtk_dialog_run (GTK_DIALOG (dialog));

  gtk_widget_destroy (GTK_WIDGET (dialog));

  return response == GTK_RESPONSE_YES;
}
Exemplo n.º 17
0
GtkWidget* ctk_xvideo_new(NvCtrlAttributeHandle *handle,
                          CtkConfig *ctk_config,
                          CtkEvent *ctk_event)
{
    GObject *object;
    CtkXVideo *ctk_xvideo;
    GtkWidget *banner;
    GtkWidget *frame;
    GtkWidget *alignment;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *vbox;
    GtkWidget *button;
    int sync_mask;
    int xv_overlay_present, xv_texture_present, xv_blitter_present;
    ReturnStatus ret;

    /*
     * before we do anything else, determine if any of the Xv adapters
     * are present
     */
    
    ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_XV_OVERLAY_PRESENT,
                             &xv_overlay_present);
    
    if (ret != NvCtrlSuccess) xv_overlay_present = FALSE;
    
    ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_XV_TEXTURE_PRESENT,
                             &xv_texture_present);

    if (ret != NvCtrlSuccess) xv_texture_present = FALSE;
    
    ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_XV_BLITTER_PRESENT,
                             &xv_blitter_present);
    
    if (ret != NvCtrlSuccess) xv_blitter_present = FALSE;
    
    if (!xv_overlay_present && !xv_texture_present && !xv_blitter_present) {
        return NULL;
    }
    
    
    /* create the XVideo widget */
    
    object = g_object_new(CTK_TYPE_XVIDEO, NULL);
    ctk_xvideo = CTK_XVIDEO(object);
    
    ctk_xvideo->handle = handle;
    ctk_xvideo->ctk_config = ctk_config;
    ctk_xvideo->active_attributes = 0;
    
    gtk_box_set_spacing(GTK_BOX(ctk_xvideo), 10);
    
    
    /* Create button, but don't pack it, yet */

    label = gtk_label_new("Reset Hardware Defaults");
    hbox = gtk_hbox_new(FALSE, 0);
    button = gtk_button_new();

    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
    gtk_container_add(GTK_CONTAINER(button), hbox);
    
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(reset_defaults), (gpointer) ctk_xvideo);
    
    ctk_config_set_tooltip(ctk_config, button, __reset_button_help);
    
    /* Video film banner */
    
    banner = ctk_banner_image_new(BANNER_ARTWORK_XVIDEO);
    gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0);

    
    /* XVideo Overlay sliders */
    
    if (xv_overlay_present) {
        
        frame = gtk_frame_new("Video Overlay Adaptor");
        gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0);
        
        vbox = gtk_vbox_new(FALSE, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
        
        ctk_xvideo->overlay_saturation =
            create_slider(ctk_xvideo, vbox, button, "Saturation",
                          __xv_overlay_saturation_help,
                          NV_CTRL_ATTR_XV_OVERLAY_SATURATION,
                          __XV_OVERLAY_SATURATION);
        
        ctk_xvideo->overlay_contrast =
            create_slider(ctk_xvideo, vbox, button, "Contrast",
                          __xv_overlay_contrast_help,
                          NV_CTRL_ATTR_XV_OVERLAY_CONTRAST,
                          __XV_OVERLAY_CONTRAST);
        
        ctk_xvideo->overlay_brightness =
            create_slider(ctk_xvideo, vbox, button, "Brightness",
                          __xv_overlay_brightness_help,
                          NV_CTRL_ATTR_XV_OVERLAY_BRIGHTNESS,
                          __XV_OVERLAY_BRIGHTNESS);
        
        ctk_xvideo->overlay_hue =
            create_slider(ctk_xvideo, vbox, button, "Hue",
                          __xv_overlay_hue_help,
                          NV_CTRL_ATTR_XV_OVERLAY_HUE,
                          __XV_OVERLAY_HUE);
    }

    /* XVideo Texture */

    if (xv_texture_present) {
        
        frame = gtk_frame_new("Video Texture Adaptor");
        gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0);
        
        vbox = gtk_vbox_new(FALSE, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
        
        ctk_xvideo->texture_sync_to_blank =
            create_check_button(ctk_xvideo, vbox, button, "Sync to VBlank",
                                __xv_texture_sync_to_vblank_help,
                                NV_CTRL_ATTR_XV_TEXTURE_SYNC_TO_VBLANK,
                                __XV_TEXTURE_SYNC_TO_VBLANK);
        
        ctk_xvideo->texture_brightness =
            create_slider(ctk_xvideo, vbox, button, "Brightness",
                          __xv_texture_brightness_help,
                          NV_CTRL_ATTR_XV_TEXTURE_BRIGHTNESS,
                          __XV_TEXTURE_BRIGHTNESS);
        
        ctk_xvideo->texture_contrast =
            create_slider(ctk_xvideo, vbox, button, "Contrast",
                          __xv_texture_contrast_help,
                          NV_CTRL_ATTR_XV_TEXTURE_CONTRAST,
                          __XV_TEXTURE_CONTRAST);

        ctk_xvideo->texture_hue =
            create_slider(ctk_xvideo, vbox, button, "Hue",
                          __xv_texture_hue_help,
                          NV_CTRL_ATTR_XV_TEXTURE_HUE,
                          __XV_TEXTURE_HUE);
        
        ctk_xvideo->texture_saturation =
            create_slider(ctk_xvideo, vbox, button, "Saturation",
                          __xv_texture_saturation_help,
                          NV_CTRL_ATTR_XV_TEXTURE_SATURATION,
                          __XV_TEXTURE_SATURATION);
    
    }
    
    /* XVideo Blitter */

    if (xv_blitter_present) {

        frame = gtk_frame_new("Video Blitter Adaptor Settings");
        gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0);
        
        vbox = gtk_vbox_new(FALSE, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
        
        ctk_xvideo->blitter_sync_to_blank =
            create_check_button(ctk_xvideo,
                                vbox,
                                button,
                                "Sync to VBlank",
                                __xv_blitter_sync_to_vblank_help,
                                NV_CTRL_ATTR_XV_BLITTER_SYNC_TO_VBLANK,
                                __XV_BLITTER_SYNC_TO_VBLANK);

    }

    /* Sync to display selection */
    if (xv_texture_present || xv_blitter_present) {
        ret = NvCtrlGetAttribute(handle,
                                 NV_CTRL_XV_SYNC_TO_DISPLAY,
                                 &sync_mask);
        if (ret == NvCtrlSuccess) {
            int enabled;
            ret = NvCtrlGetAttribute(handle, 
                                     NV_CTRL_ENABLED_DISPLAYS,
                                     &enabled);
            if (ret == NvCtrlSuccess) {

                GtkWidget *radio[24], *prev_radio;
                int i, n, current = -1, mask;
                char *name, *type;
                gchar *name_str;
                frame = gtk_frame_new("Sync to this display device");
                gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0);

                vbox = gtk_vbox_new(FALSE, 5);
                gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
                gtk_container_add(GTK_CONTAINER(frame), vbox);
                ctk_xvideo->xv_sync_to_display_button_box = vbox;

                for (n=0, i = 0; i < 24; i++) {

                    mask = 1 << i;
                    if (!(enabled & mask)) continue;

                    /* get the name of the display device */

                    ret = NvCtrlGetStringDisplayAttribute(handle, mask,
                                              NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
                                              &name);

                    if ((ret != NvCtrlSuccess) || (!name)) {
                        name = g_strdup("Unknown");
                    }

                    /* get the display device type */

                    type = display_device_mask_to_display_device_name(mask);

                    name_str = g_strdup_printf("%s (%s)", name, type);
                    XFree(name);
                    free(type);

                    if (n==0) {
                        prev_radio = NULL;
                    } else {
                        prev_radio = radio[n-1];
                    } 
                    radio[n] = xv_sync_to_display_radio_button_add(ctk_xvideo, 
                                                                   prev_radio,
                                                                   name_str,
                                                                   mask, n);
                    g_free(name_str);
                    ctk_config_set_tooltip(ctk_config, radio[n],
                                           __xv_sync_to_display_help);    

                    if (mask == sync_mask) {
                        current = n;
                    }

                    n++;
                    ctk_xvideo->active_attributes |= __XV_SYNC_TO_DISPLAY;
                }

                g_signal_connect(G_OBJECT(ctk_event),
                                 CTK_EVENT_NAME(NV_CTRL_XV_SYNC_TO_DISPLAY),
                                 G_CALLBACK(xv_sync_to_display_update_received),
                                 (gpointer) ctk_xvideo);
                g_signal_connect(G_OBJECT(ctk_event),
                                 CTK_EVENT_NAME(NV_CTRL_ENABLED_DISPLAYS),
                                 G_CALLBACK(nv_ctrl_enabled_displays),
                                 (gpointer) ctk_xvideo);
                sensitize_radio_buttons(ctk_xvideo);

                if (current != -1)
                    xv_sync_to_display_update_radio_buttons(ctk_xvideo, current);

            }
        }
    }
    
    /* Reset button */

    sensitize_radio_buttons(ctk_xvideo);
    alignment = gtk_alignment_new(1, 1, 0, 0);
    gtk_container_add(GTK_CONTAINER(alignment), button);
    gtk_box_pack_start(GTK_BOX(object), alignment, TRUE, TRUE, 0);
    
    /* finally, show the widget */

    gtk_widget_show_all(GTK_WIDGET(ctk_xvideo));

    return GTK_WIDGET(ctk_xvideo);
    
} /* ctk_xvideo_new() */
static void
nautilus_mime_application_chooser_build_ui (NautilusMimeApplicationChooser *chooser)
{
	GtkWidget *box, *button;
	GAppInfo *info;

	gtk_container_set_border_width (GTK_CONTAINER (chooser), 8);
	gtk_box_set_spacing (GTK_BOX (chooser), 0);
	gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE);

	chooser->details->label = gtk_label_new ("");
        gtk_label_set_xalign (GTK_LABEL (chooser->details->label), 0);
	gtk_label_set_line_wrap (GTK_LABEL (chooser->details->label), TRUE);
	gtk_label_set_line_wrap_mode (GTK_LABEL (chooser->details->label),
				      PANGO_WRAP_WORD_CHAR);
	gtk_box_pack_start (GTK_BOX (chooser), chooser->details->label, 
			    FALSE, FALSE, 0);

	gtk_widget_show (chooser->details->label);

	chooser->details->open_with_widget = gtk_app_chooser_widget_new (chooser->details->content_type);
	gtk_app_chooser_widget_set_show_default (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
						 TRUE);
	gtk_app_chooser_widget_set_show_fallback (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
						  TRUE);
	gtk_app_chooser_widget_set_show_other (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
					       TRUE);
	gtk_box_pack_start (GTK_BOX (chooser), chooser->details->open_with_widget,
			    TRUE, TRUE, 6);
	gtk_widget_show (chooser->details->open_with_widget);

	box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_set_spacing (GTK_BOX (box), 6);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_END);
	gtk_box_pack_start (GTK_BOX (chooser), box, FALSE, FALSE, 6);
	gtk_widget_show (box);

	button = gtk_button_new_with_label (_("Reset"));
	g_signal_connect (button, "clicked", 
			  G_CALLBACK (reset_clicked_cb),
			  chooser);
	gtk_widget_show (button);
	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
	gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (box), button, TRUE);

	button = gtk_button_new_with_mnemonic (_("_Add"));
	g_signal_connect (button, "clicked", 
			  G_CALLBACK (add_clicked_cb),
			  chooser);
	gtk_widget_show (button);
	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
	chooser->details->add_button = button;

	button = gtk_button_new_with_label (_("Set as default"));
	g_signal_connect (button, "clicked",
			  G_CALLBACK (set_as_default_clicked_cb),
			  chooser);
	gtk_widget_show (button);
	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);

	chooser->details->set_as_default_button = button;

	/* initialize sensitivity */
	info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));
	if (info != NULL) {
		application_selected_cb (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
					 info, chooser);
		g_object_unref (info);
	}

	g_signal_connect (chooser->details->open_with_widget,
			  "application-selected",
			  G_CALLBACK (application_selected_cb),
			  chooser);
	g_signal_connect (chooser->details->open_with_widget,
			  "populate-popup",
			  G_CALLBACK (populate_popup_cb),
			  chooser);
}
Exemplo n.º 19
0
void
chanlist_opengui (server *serv, int do_refresh)
{
	GtkWidget *vbox, *hbox, *table, *wid, *view;
	char tbuf[256];
	GtkListStore *store;

	if (serv->gui->chanlist_window)
	{
		mg_bring_tofront (serv->gui->chanlist_window);
		return;
	}

	snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Channel List (%s)"),
				 server_get_network (serv, TRUE));

	serv->gui->chanlist_pending_rows = NULL;
	serv->gui->chanlist_tag = 0;
	serv->gui->chanlist_flash_tag = 0;
	serv->gui->chanlist_data_stored_rows = NULL;

	if (!serv->gui->chanlist_minusers)
	{
		if (prefs.hex_gui_chanlist_minusers < 1 || prefs.hex_gui_chanlist_minusers > 999999)
		{
			prefs.hex_gui_chanlist_minusers = 5;
			save_config();
		}

		serv->gui->chanlist_minusers = prefs.hex_gui_chanlist_minusers;
	}

	if (!serv->gui->chanlist_maxusers)
	{
		if (prefs.hex_gui_chanlist_maxusers < 1 || prefs.hex_gui_chanlist_maxusers > 999999)
		{
			prefs.hex_gui_chanlist_maxusers = 9999;
			save_config();
		}

		serv->gui->chanlist_maxusers = prefs.hex_gui_chanlist_maxusers;
	}

	serv->gui->chanlist_window =
		mg_create_generic_tab ("ChanList", tbuf, FALSE, TRUE, chanlist_closegui,
								serv, 640, 480, &vbox, serv);

	gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
	gtk_box_set_spacing (GTK_BOX (vbox), 12);

	/* make a label to store the user/channel info */
	wid = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (vbox), wid, 0, 0, 0);
	gtk_widget_show (wid);
	serv->gui->chanlist_label = wid;

	/* ============================================================= */

	store = (GtkListStore *) custom_list_new();
	view = gtkutil_treeview_new (vbox, GTK_TREE_MODEL (store), NULL, -1);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->parent),
													 GTK_SHADOW_IN);
	serv->gui->chanlist_list = view;

	g_signal_connect (G_OBJECT (view), "row_activated",
							G_CALLBACK (chanlist_dclick_cb), serv);
	g_signal_connect (G_OBJECT (view), "button-press-event",
							G_CALLBACK (chanlist_button_cb), serv);

	chanlist_add_column (view, COL_CHANNEL, 96, _("Channel"), FALSE);
	chanlist_add_column (view, COL_USERS,   50, _("Users"),   TRUE);
	chanlist_add_column (view, COL_TOPIC,   50, _("Topic"),   FALSE);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
	/* this is a speed up, but no horizontal scrollbar :( */
	/*gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (view), TRUE);*/
	gtk_widget_show (view);

	/* ============================================================= */

	table = gtk_table_new (4, 4, FALSE);
	gtk_table_set_col_spacings (GTK_TABLE (table), 12);
	gtk_table_set_row_spacings (GTK_TABLE (table), 3);
	gtk_box_pack_start (GTK_BOX (vbox), table, 0, 1, 0);
	gtk_widget_show (table);

	wid = gtkutil_button (NULL, GTK_STOCK_FIND, 0, chanlist_search_pressed, serv,
								 _("_Search"));
	serv->gui->chanlist_search = wid;
	gtk_table_attach (GTK_TABLE (table), wid, 3, 4, 3, 4,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);

	wid = gtkutil_button (NULL, GTK_STOCK_REFRESH, 0, chanlist_refresh, serv,
								 _("_Download List"));
	serv->gui->chanlist_refresh = wid;
	gtk_table_attach (GTK_TABLE (table), wid, 3, 4, 2, 3,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);

	wid = gtkutil_button (NULL, GTK_STOCK_SAVE_AS, 0, chanlist_save, serv,
								 _("Save _List..."));
	serv->gui->chanlist_savelist = wid;
	gtk_table_attach (GTK_TABLE (table), wid, 3, 4, 1, 2,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);

	wid = gtkutil_button (NULL, GTK_STOCK_JUMP_TO, 0, chanlist_join, serv,
						 _("_Join Channel"));
	serv->gui->chanlist_join = wid;
	gtk_table_attach (GTK_TABLE (table), wid, 3, 4, 0, 1,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);

	/* ============================================================= */

	wid = gtk_label_new (_("Show only:"));
	gtk_misc_set_alignment (GTK_MISC (wid), 0, 0.5);
	gtk_table_attach (GTK_TABLE (table), wid, 0, 1, 3, 4,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	gtk_widget_show (wid);

	hbox = gtk_hbox_new (0, 0);
	gtk_box_set_spacing (GTK_BOX (hbox), 9);
	gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 3, 4,
							GTK_FILL, GTK_FILL, 0, 0);
	gtk_widget_show (hbox);

	wid = gtk_label_new (_("channels with"));
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);

	wid = gtk_spin_button_new_with_range (1, 999999, 1);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
										serv->gui->chanlist_minusers);
	g_signal_connect (G_OBJECT (wid), "value_changed",
							G_CALLBACK (chanlist_minusers), serv);
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);
	serv->gui->chanlist_min_spin = wid;

	wid = gtk_label_new (_("to"));
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);

	wid = gtk_spin_button_new_with_range (1, 999999, 1);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
										serv->gui->chanlist_maxusers);
	g_signal_connect (G_OBJECT (wid), "value_changed",
							G_CALLBACK (chanlist_maxusers), serv);
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);

	wid = gtk_label_new (_("users."));
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);

	/* ============================================================= */

	wid = gtk_label_new (_("Look in:"));
	gtk_misc_set_alignment (GTK_MISC (wid), 0, 0.5);
	gtk_table_attach (GTK_TABLE (table), wid, 0, 1, 2, 3,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	gtk_widget_show (wid);

	hbox = gtk_hbox_new (0, 0);
	gtk_box_set_spacing (GTK_BOX (hbox), 12);
	gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 2, 3,
							GTK_FILL, GTK_FILL, 0, 0);
	gtk_widget_show (hbox);

	wid = gtk_check_button_new_with_label (_("Channel name"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wid), TRUE);
	gtk_signal_connect (GTK_OBJECT (wid), "toggled",
							  GTK_SIGNAL_FUNC
							  (chanlist_match_channel_button_toggled), serv);
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);

	wid = gtk_check_button_new_with_label (_("Topic"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wid), TRUE);
	gtk_signal_connect (GTK_OBJECT (wid), "toggled",
							  GTK_SIGNAL_FUNC (chanlist_match_topic_button_toggled),
							  serv);
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_show (wid);

	serv->gui->chanlist_match_wants_channel = 1;
	serv->gui->chanlist_match_wants_topic = 1;

	/* ============================================================= */

	wid = gtk_label_new (_("Search type:"));
	gtk_misc_set_alignment (GTK_MISC (wid), 0, 0.5);
	gtk_table_attach (GTK_TABLE (table), wid, 0, 1, 1, 2,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	gtk_widget_show (wid);

	wid = gtk_combo_box_new_text ();
	gtk_combo_box_append_text (GTK_COMBO_BOX (wid), _("Simple Search"));
	gtk_combo_box_append_text (GTK_COMBO_BOX (wid), _("Pattern Match (Wildcards)"));
#ifndef WIN32
	gtk_combo_box_append_text (GTK_COMBO_BOX (wid), _("Regular Expression"));
#endif
	gtk_combo_box_set_active (GTK_COMBO_BOX (wid), serv->gui->chanlist_search_type);
	gtk_table_attach (GTK_TABLE (table), wid, 1, 2, 1, 2,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	g_signal_connect (G_OBJECT (wid), "changed",
							G_CALLBACK (chanlist_combo_cb), serv);
	gtk_widget_show (wid);

	/* ============================================================= */

	wid = gtk_label_new (_("Find:"));
	gtk_misc_set_alignment (GTK_MISC (wid), 0, 0.5);
	gtk_table_attach (GTK_TABLE (table), wid, 0, 1, 0, 1,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	gtk_widget_show (wid);

	wid = gtk_entry_new_with_max_length (255);
	gtk_signal_connect (GTK_OBJECT (wid), "changed",
							  GTK_SIGNAL_FUNC (chanlist_find_cb), serv);
	gtk_signal_connect (GTK_OBJECT (wid), "activate",
							  GTK_SIGNAL_FUNC (chanlist_search_pressed),
							  (gpointer) serv);
	gtk_table_attach (GTK_TABLE (table), wid, 1, 2, 0, 1,
							GTK_EXPAND | GTK_FILL, 0, 0, 0);
	gtk_widget_show (wid);
	serv->gui->chanlist_wild = wid;

	chanlist_find_cb (wid, serv);

	/* ============================================================= */

	wid = gtk_vseparator_new ();
	gtk_table_attach (GTK_TABLE (table), wid, 2, 3, 0, 5,
							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	gtk_widget_show (wid);

	g_signal_connect (G_OBJECT (serv->gui->chanlist_window), "destroy",
							G_CALLBACK (chanlist_destroy_widget), serv);

	/* reset the counters. */
	chanlist_reset_counters (serv);

	serv->gui->chanlist_tag = g_timeout_add (250, (GSourceFunc)chanlist_timeout, serv);

	if (do_refresh)
		chanlist_do_refresh (serv);

	chanlist_update_buttons (serv);
	gtk_widget_show (serv->gui->chanlist_window);
	gtk_widget_grab_focus (serv->gui->chanlist_refresh);
}
Exemplo n.º 20
0
static void
execute_action_mitem_cb (GtkMenuItem *menuitem, UiFormGrid *formgrid)
{
	TFavoritesAction *act;
	GtkWidget *dlg;
	gchar *tmp;
	gint response;
	GtkWidget *toplevel;

	act = (TFavoritesAction*) g_object_get_data (G_OBJECT (menuitem), "action");
	toplevel = gtk_widget_get_toplevel ((GtkWidget*) formgrid);
	tmp = g_strdup_printf (_("Set or confirm the parameters to execute\n"
				 "action '%s'"), act->name);
	dlg = gdaui_basic_form_new_in_dialog (act->params,
					      (GtkWindow*) toplevel,
					      _("Execution of action"), tmp);
	g_free (tmp);
	response = gtk_dialog_run (GTK_DIALOG (dlg));
	gtk_widget_destroy (dlg);
	if (response == GTK_RESPONSE_ACCEPT) {
                GError *lerror = NULL;
		TConnection *tcnc;
		
		tcnc = get_t_connection (formgrid);
		g_assert (tcnc);

		GObject *result;
		result = t_connection_execute_statement (tcnc, act->stmt, act->params,
                                                               GDA_STATEMENT_MODEL_RANDOM_ACCESS, NULL,
							       &lerror);
		if (result && GDA_IS_DATA_MODEL (result)) {
			GtkWidget *dialog, *label, *fg;
			GtkWidget *dcontents;
			gchar *tmp;
			dialog = gtk_dialog_new_with_buttons (act->name, NULL, 0,
							      _("_Close"), GTK_RESPONSE_CLOSE, NULL);
			dcontents = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
			gtk_box_set_spacing (GTK_BOX (dcontents), 5);
			gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE, TRUE);

			tmp = g_markup_printf_escaped ("<b>%s:</b>", act->name);
			label = gtk_label_new ("");
			gtk_label_set_markup (GTK_LABEL (label), tmp);
			g_free (tmp);
			gtk_widget_set_halign (label, GTK_ALIGN_START);
			gtk_box_pack_start (GTK_BOX (dcontents), label, FALSE, FALSE, 5);

			fg = ui_formgrid_new (GDA_DATA_MODEL (result), TRUE,
					      GDAUI_DATA_PROXY_INFO_CURRENT_ROW);
			ui_formgrid_set_connection (UI_FORMGRID (fg), tcnc);

			ActionExecutedData *aed;
			aed = g_new0 (ActionExecutedData, 1);
			aed->formgrid = g_object_ref (formgrid);
			aed->tcnc = g_object_ref (tcnc);
			if (act->name)
				aed->name = g_strdup (act->name);
			aed->stmt = g_object_ref (act->stmt);
			aed->params = g_object_ref (act->params);

			if (GDA_IS_DATA_SELECT (result)) {
				GdaStatement *stmt;
				g_object_get (G_OBJECT (result), "select-stmt", &stmt, NULL);
				if (stmt) {
					ui_formgrid_handle_user_prefs (UI_FORMGRID (fg), NULL, stmt);
					g_object_unref (stmt);
				}
				aed->model = g_object_ref (result);
				g_signal_connect (aed->params, "holder-changed",
						  G_CALLBACK (action_executed_holder_changed_cb), aed);

				aed->formgrid = g_object_ref (fg);
				aed->formgrid->priv->autoupdate_possible = TRUE;
				gtk_widget_show (aed->formgrid->priv->autoupdate_toggle);
			}
			gtk_box_pack_start (GTK_BOX (dcontents), fg, TRUE, TRUE, 0);

			gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 600);
			gtk_widget_show_all (dialog);

			g_signal_connect (dialog, "response",
					  G_CALLBACK (gtk_widget_destroy), NULL);
			g_signal_connect (dialog, "close",
					  G_CALLBACK (gtk_widget_destroy), NULL);
			g_object_set_data_full (G_OBJECT (dialog), "aed", aed,
						(GDestroyNotify) action_executed_data_free);
		}
		else if (result) {
			if (BROWSER_IS_WINDOW (toplevel)) {
				browser_window_show_notice_printf (BROWSER_WINDOW (toplevel),
								   GTK_MESSAGE_INFO,
								   "ActionExecution",
								   "%s", _("Action successfully executed"));
			}
			else
				ui_show_message (GTK_WINDOW (toplevel),
						 "%s", _("Action successfully executed"));
			g_object_unref (result);
		}
		else {
                        ui_show_error (GTK_WINDOW (toplevel),
				       _("Error executing query: %s"),
				       lerror && lerror->message ? lerror->message : _("No detail"));
                        g_clear_error (&lerror);
                }
	}
}
Exemplo n.º 21
0
static void
cb_place_button(GtkWidget *widget, gpointer data)
	{
	GtkWidget		*main_vbox, *vbox, *vbox1, *vbox2, *vbox3, *hbox;
	GtkWidget		*button;
	GtkTreeModel	*model;
	GtkTreePath		*path;
	GtkTreeIter		iter;
	GSList			*group;
	GList			*list;
	GkrellmMonitor	*mon;
	GkrellmMonprivate *mp;
	gint			i;

	if (gkrellm_demo_mode())
		return;
	if (!place_plugin_window)
		{
		place_plugin_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		g_signal_connect(G_OBJECT(place_plugin_window), "delete_event",
				G_CALLBACK(place_plugin_window_delete_event), NULL);
		gtk_window_set_title(GTK_WINDOW(place_plugin_window),
				_("GKrellM Place Plugin"));
		gtk_window_set_wmclass(GTK_WINDOW(place_plugin_window),
				"Gkrellm_conf", "Gkrellm");

		main_vbox = gtk_vbox_new(FALSE, 0);
		gtk_container_add(GTK_CONTAINER(place_plugin_window), main_vbox);
		place_plugin_vbox = main_vbox;
		vbox = gkrellm_gtk_framed_vbox(main_vbox, NULL, 3, FALSE, 4, 3);
		hbox = gtk_hbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

		vbox1 = gkrellm_gtk_framed_vbox(hbox, _("Builtin Monitors"),
				3, FALSE, 4, 3);
		group = NULL;
		for (i = 0, list = gkrellm_monitor_list; list; list = list->next)
			{
			mon = (GkrellmMonitor *) list->data;
			mp  = mon->privat;
			mon->privat->button_id = -1;
			if (MONITOR_ID(mon) != MON_PLUGIN)
				{
				if (   !mon->name || !mon->create_monitor
					|| mon == gkrellm_mon_host()
				   )
					continue;
				button = gtk_radio_button_new_with_label(group, mon->name);
				g_signal_connect(G_OBJECT(button), "clicked",
						G_CALLBACK(cb_place), NULL);
				gtk_box_pack_start(GTK_BOX(vbox1), button, FALSE, FALSE, 0);
				if (i < N_BUILTIN_MONITORS)
					{
					builtin_button[i] = button;
					mon->privat->button_id = i++;
					}
				group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
				}
			}
		vbox1 = gtk_vbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(hbox), vbox1, FALSE, FALSE, 0);
		place_label = gtk_label_new("");
		gtk_box_pack_start(GTK_BOX(vbox1), place_label, FALSE, FALSE, 10);
		vbox2 = gkrellm_gtk_framed_vbox(vbox1, _("Place Plugin"),
				3, FALSE, 4, 3);

		group = NULL;
		vbox3 = gkrellm_gtk_framed_vbox(vbox2, NULL, 3, FALSE, 4, 3);
		before_button = gtk_radio_button_new_with_label(group,
				_("Before selected builtin monitor"));
		g_signal_connect(G_OBJECT(before_button), "clicked",
				G_CALLBACK(cb_place), NULL);
		gtk_box_pack_start(GTK_BOX(vbox3), before_button, FALSE, FALSE, 0);
		gkrellm_gtk_spin_button(vbox3, &gravity_spin_button, 8,
				0.0, 15.0, 1, 1, 0, 50,
				cb_place_spin, NULL, FALSE,
				_("With gravity"));

		vbox3 = gkrellm_gtk_framed_vbox(vbox2, NULL, 3, FALSE, 4, 3);
		group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(before_button));
		after_button = gtk_radio_button_new_with_label(group,
				_("After selected builtin monitor"));
		g_signal_connect(G_OBJECT(after_button), "clicked",
				G_CALLBACK(cb_place), NULL);
		gtk_box_pack_start(GTK_BOX(vbox3), after_button, FALSE, FALSE, 0);

		hbox = gtk_hbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0);
		gkrellm_gtk_button_connected(hbox, NULL, TRUE, FALSE, 0,
				cb_place_default, NULL, _("Plugin Defaults"));

		hbox = gtk_hbutton_box_new();
		gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
		gtk_box_set_spacing(GTK_BOX(hbox), 5);
		gtk_box_pack_end(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0);

		button = gtk_button_new_from_stock(GTK_STOCK_OK);
		GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
		g_signal_connect(G_OBJECT(button), "clicked",
				G_CALLBACK(cb_close_place), NULL);
		gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);

		gtk_widget_show_all(place_plugin_window);
		}
	else
		gtk_window_present(GTK_WINDOW(place_plugin_window));
//		gdk_window_raise(place_plugin_window->window);

	if (row_reference)
		{
		model = gtk_tree_view_get_model(treeview);
		path = gtk_tree_row_reference_get_path(row_reference);
		gtk_tree_model_get_iter(model, &iter, path);
		gtk_tree_model_get(model, &iter, MON_COLUMN, &mon, -1);
		place_button_sensitivity(mon, mon->privat->enabled);
		}
	}
Exemplo n.º 22
0
static void
gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
{
  GtrPreferencesDialogPrivate *priv;
  GtkWidget *action_area;
  GtkWidget *profiles_toolbar;
  GtkWidget *profiles_scrolled_window;
  GtkBuilder *builder;
  GtkBox *content_area;
  GtkStyleContext *context;
  gchar *root_objects[] = {
    "notebook",
    "adjustment1",
    "adjustment2",
    "adjustment3",
    "model1",
    NULL
  };

  dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
  priv = dlg->priv;

  priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
  priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
  priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");

  gtk_dialog_add_buttons (GTK_DIALOG (dlg),
                          GTK_STOCK_CLOSE,
                          GTK_RESPONSE_CLOSE,
                          GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);

  gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Preferences"));
  gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);

  action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
  content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));

  /* HIG defaults */
  gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
  gtk_box_set_spacing (content_area, 2);    /* 2 * 5 + 2 = 12 */
  gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
  gtk_box_set_spacing (GTK_BOX (action_area), 4);

  g_signal_connect (dlg,
                    "response", G_CALLBACK (dialog_response_handler), NULL);

  builder = gtk_builder_new ();
  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-preferences-dialog.ui",
                                         root_objects, NULL);
  priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
  g_object_ref (priv->notebook);
  priv->warn_if_contains_fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "warn_if_fuzzy_checkbutton"));
  priv->autosave_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_checkbutton"));
  priv->autosave_interval_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_interval_spinbutton"));
  priv->autosave_grid = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_grid"));
  priv->create_backup_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "create_backup_checkbutton"));
  priv->highlight_syntax_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "highlight_checkbutton"));
  priv->visible_whitespace_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "visible_whitespace_checkbutton"));
  priv->use_custom_font_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "use_custom_font_checkbutton"));
  priv->editor_font_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_fontbutton"));
  priv->editor_font_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_hbox"));
  priv->unmark_fuzzy_when_changed_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "unmark_fuzzy_checkbutton"));
  priv->spellcheck_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "spellcheck_checkbutton"));
  priv->profile_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "profile_treeview"));
  priv->add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add-button"));
  priv->edit_button = GTK_WIDGET (gtk_builder_get_object (builder, "edit-button"));
  priv->delete_button = GTK_WIDGET (gtk_builder_get_object (builder, "delete-button"));
  profiles_toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-toolbar"));
  profiles_scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-scrolledwindow"));
  g_object_unref (builder);

  gtk_box_pack_start (content_area, priv->notebook, FALSE, FALSE, 0);

  gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 5);

  context = gtk_widget_get_style_context (profiles_scrolled_window);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);

  context = gtk_widget_get_style_context (profiles_toolbar);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);

  setup_files_pages (dlg);
  setup_editor_pages (dlg);
  setup_profile_pages (dlg);
}
static gboolean
refresh_account (GoaProvider    *provider,
                 GoaClient      *client,
                 GoaObject      *object,
                 GtkWindow      *parent,
                 GError        **error)
{
  AddAccountData data;
  GVariantBuilder builder;
  GoaAccount *account;
  GoaEwsClient *ews_client;
  GoaExchange *exchange;
  GtkWidget *dialog;
  GtkWidget *vbox;
  gboolean accept_ssl_errors;
  gboolean ret;
  const gchar *email_address;
  const gchar *server;
  const gchar *password;
  const gchar *username;
  gint response;

  g_return_val_if_fail (GOA_IS_EXCHANGE_PROVIDER (provider), FALSE);
  g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
  g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
  g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  ews_client = NULL;
  ret = FALSE;

  dialog = gtk_dialog_new_with_buttons (NULL,
                                        parent,
                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                        NULL);
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

  vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_box_set_spacing (GTK_BOX (vbox), 12);

  memset (&data, 0, sizeof (AddAccountData));
  data.loop = g_main_loop_new (NULL, FALSE);
  data.dialog = GTK_DIALOG (dialog);
  data.error = NULL;

  create_account_details_ui (provider, GTK_DIALOG (dialog), GTK_BOX (vbox), FALSE, &data);

  account = goa_object_peek_account (object);
  email_address = goa_account_get_presentation_identity (account);
  gtk_entry_set_text (GTK_ENTRY (data.email_address), email_address);
  gtk_editable_set_editable (GTK_EDITABLE (data.email_address), FALSE);

  gtk_widget_show_all (dialog);

  ews_client = goa_ews_client_new ();

 ews_again:
  response = gtk_dialog_run (GTK_DIALOG (dialog));
  if (response != GTK_RESPONSE_OK)
    {
      g_set_error (error,
                   GOA_ERROR,
                   GOA_ERROR_DIALOG_DISMISSED,
                   _("Dialog was dismissed"));
      goto out;
    }

  password = gtk_entry_get_text (GTK_ENTRY (data.password));
  username = goa_account_get_identity (account);

  exchange = goa_object_peek_exchange (object);
  accept_ssl_errors = goa_util_lookup_keyfile_boolean (object, "AcceptSslErrors");
  server = goa_exchange_get_host (exchange);

  goa_ews_client_autodiscover (ews_client,
                               email_address,
                               password,
                               username,
                               server,
                               accept_ssl_errors,
                               NULL,
                               autodiscover_cb,
                               &data);
  goa_spinner_button_start (GOA_SPINNER_BUTTON (data.spinner_button));
  g_main_loop_run (data.loop);

  if (data.error != NULL)
    {
      GtkWidget *button;
      gchar *markup;

      markup = g_strdup_printf ("<b>%s:</b> %s",
                                _("Error connecting to Microsoft Exchange server"),
                                data.error->message);
      g_clear_error (&data.error);

      gtk_label_set_markup (GTK_LABEL (data.cluebar_label), markup);
      g_free (markup);

      button = gtk_dialog_get_widget_for_response (data.dialog, GTK_RESPONSE_OK);
      gtk_button_set_label (GTK_BUTTON (button), _("_Try Again"));
      gtk_widget_set_no_show_all (data.cluebar, FALSE);
      gtk_widget_show_all (data.cluebar);
      goto ews_again;
    }

  /* TODO: run in worker thread */
  g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
  g_variant_builder_add (&builder, "{sv}", "password", g_variant_new_string (password));

  if (!goa_utils_store_credentials_for_object_sync (provider,
                                                    object,
                                                    g_variant_builder_end (&builder),
                                                    NULL, /* GCancellable */
                                                    error))
    goto out;

  goa_account_call_ensure_credentials (account,
                                       NULL, /* GCancellable */
                                       NULL, NULL); /* callback, user_data */

  ret = TRUE;

 out:
  gtk_widget_destroy (dialog);
  if (data.loop != NULL)
    g_main_loop_unref (data.loop);
  if (ews_client != NULL)
    g_object_unref (ews_client);
  return ret;
}
Exemplo n.º 24
0
GtkWidget*
create_Config (void)
{
  GtkWidget *Config;
  GtkWidget *vbox4;
  GtkWidget *frame7;
  GtkWidget *alignment4;
  GtkWidget *hbox8;
  GtkWidget *radionointerlace;
  GSList *radionointerlace_group = NULL;
  GtkWidget *radiointerlace0;
  GtkWidget *radiointerlace1;
  GtkWidget *label13;
  GtkWidget *checkBilinear;
  GtkWidget *frame4;
  GtkWidget *alignment1;
  GtkWidget *hbox6;
  GtkWidget *radioAANone;
  GSList *radioAANone_group = NULL;
  GtkWidget *radioAA2X;
  GtkWidget *radioAA4X;
  GtkWidget *radioAA8X;
  GtkWidget *radioAA16X;
  GtkWidget *label9;
  GtkWidget *checkWireframe;
  GtkWidget *checkAVI;
  GtkWidget *checkTGA;
  GtkWidget *checkfullscreen;
  GtkWidget *frame5;
  GtkWidget *alignment2;
  GtkWidget *hbox7;
  GtkWidget *radioSize640;
  GSList *radioSize640_group = NULL;
  GtkWidget *radioSize800;
  GtkWidget *radioSize1024;
  GtkWidget *radioSize1280;
  GtkWidget *label10;
  GtkWidget *frame6;
  GtkWidget *alignment3;
  GtkWidget *scrolledwindow1;
  GtkWidget *treeview1;
  GtkWidget *label12;
  GtkWidget *label11;
  GtkWidget *hbuttonbox1;
  GtkWidget *button1;
  GtkWidget *button2;

  Config = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (Config), 5);
  gtk_window_set_title (GTK_WINDOW (Config), _("ZeroOGS Configuration"));

  vbox4 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox4);
  gtk_container_add (GTK_CONTAINER (Config), vbox4);

  frame7 = gtk_frame_new (NULL);
  gtk_widget_show (frame7);
  gtk_box_pack_start (GTK_BOX (vbox4), frame7, FALSE, FALSE, 0);

  alignment4 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_show (alignment4);
  gtk_container_add (GTK_CONTAINER (frame7), alignment4);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment4), 0, 0, 12, 0);

  hbox8 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox8);
  gtk_container_add (GTK_CONTAINER (alignment4), hbox8);

  radionointerlace = gtk_radio_button_new_with_mnemonic (NULL, _("Interlace Off"));
  gtk_widget_show (radionointerlace);
  gtk_box_pack_start (GTK_BOX (hbox8), radionointerlace, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radionointerlace), radionointerlace_group);
  radionointerlace_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radionointerlace));

  radiointerlace0 = gtk_radio_button_new_with_mnemonic (NULL, _("Interlace 0"));
  gtk_widget_show (radiointerlace0);
  gtk_box_pack_start (GTK_BOX (hbox8), radiointerlace0, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiointerlace0), radionointerlace_group);
  radionointerlace_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiointerlace0));

  radiointerlace1 = gtk_radio_button_new_with_mnemonic (NULL, _("Interlace 1"));
  gtk_widget_show (radiointerlace1);
  gtk_box_pack_start (GTK_BOX (hbox8), radiointerlace1, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiointerlace1), radionointerlace_group);
  radionointerlace_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiointerlace1));

  label13 = gtk_label_new (_("<b>Interlacing (F5 to toggle)</b>"));
  gtk_widget_show (label13);
  gtk_frame_set_label_widget (GTK_FRAME (frame7), label13);
  gtk_label_set_use_markup (GTK_LABEL (label13), TRUE);

  checkBilinear = gtk_check_button_new_with_mnemonic (_("Bilinear Filtering (Shift+F5)\n   Best quality is on, turn off for speed"));
  gtk_widget_show (checkBilinear);
  gtk_box_pack_start (GTK_BOX (vbox4), checkBilinear, FALSE, FALSE, 0);

  frame4 = gtk_frame_new (NULL);
  gtk_widget_show (frame4);
  gtk_box_pack_start (GTK_BOX (vbox4), frame4, FALSE, FALSE, 0);

  alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (frame4), alignment1);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0);

  hbox6 = gtk_hbox_new (TRUE, 0);
  gtk_widget_show (hbox6);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox6);

  radioAANone = gtk_radio_button_new_with_mnemonic (NULL, _("None"));
  gtk_widget_show (radioAANone);
  gtk_box_pack_start (GTK_BOX (hbox6), radioAANone, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioAANone), radioAANone_group);
  radioAANone_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioAANone));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radioAANone), TRUE);

  radioAA2X = gtk_radio_button_new_with_mnemonic (NULL, _("2X"));
  gtk_widget_show (radioAA2X);
  gtk_box_pack_start (GTK_BOX (hbox6), radioAA2X, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioAA2X), radioAANone_group);
  radioAANone_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioAA2X));

  radioAA4X = gtk_radio_button_new_with_mnemonic (NULL, _("4X"));
  gtk_widget_show (radioAA4X);
  gtk_box_pack_start (GTK_BOX (hbox6), radioAA4X, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioAA4X), radioAANone_group);
  radioAANone_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioAA4X));

  radioAA8X = gtk_radio_button_new_with_mnemonic (NULL, _("8X"));
  gtk_widget_show (radioAA8X);
  gtk_box_pack_start (GTK_BOX (hbox6), radioAA8X, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioAA8X), radioAANone_group);
  radioAANone_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioAA8X));

  radioAA16X = gtk_radio_button_new_with_mnemonic (NULL, _("16X"));
  gtk_widget_show (radioAA16X);
  gtk_box_pack_start (GTK_BOX (hbox6), radioAA16X, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioAA16X), radioAANone_group);
  radioAANone_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioAA16X));

  label9 = gtk_label_new (_("<b>Anti-aliasing for higher quality (F6)</b>"));
  gtk_widget_show (label9);
  gtk_frame_set_label_widget (GTK_FRAME (frame4), label9);
  gtk_label_set_use_markup (GTK_LABEL (label9), TRUE);

  checkWireframe = gtk_check_button_new_with_mnemonic (_("Wireframe rendering (Shift+F6)"));
  gtk_widget_show (checkWireframe);
  gtk_box_pack_start (GTK_BOX (vbox4), checkWireframe, FALSE, FALSE, 0);

  checkAVI = gtk_check_button_new_with_mnemonic (_("Capture Avi (zerogs.avi)(F7)"));
  gtk_widget_show (checkAVI);
  gtk_box_pack_start (GTK_BOX (vbox4), checkAVI, FALSE, FALSE, 0);

  checkTGA = gtk_check_button_new_with_mnemonic (_("Save Snapshots as TGAs (default is JPG)"));
  gtk_widget_show (checkTGA);
  gtk_box_pack_start (GTK_BOX (vbox4), checkTGA, FALSE, FALSE, 0);

  checkfullscreen = gtk_check_button_new_with_mnemonic (_("Fullscreen (Alt+Enter)\n   to get out press Alt+Enter again (or ESC)"));
  gtk_widget_show (checkfullscreen);
  gtk_box_pack_start (GTK_BOX (vbox4), checkfullscreen, FALSE, FALSE, 0);

  frame5 = gtk_frame_new (NULL);
  gtk_widget_show (frame5);
  gtk_box_pack_start (GTK_BOX (vbox4), frame5, FALSE, FALSE, 0);

  alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_show (alignment2);
  gtk_container_add (GTK_CONTAINER (frame5), alignment2);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0);

  hbox7 = gtk_hbox_new (TRUE, 0);
  gtk_widget_show (hbox7);
  gtk_container_add (GTK_CONTAINER (alignment2), hbox7);

  radioSize640 = gtk_radio_button_new_with_mnemonic (NULL, _("640x480"));
  gtk_widget_show (radioSize640);
  gtk_box_pack_start (GTK_BOX (hbox7), radioSize640, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioSize640), radioSize640_group);
  radioSize640_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioSize640));

  radioSize800 = gtk_radio_button_new_with_mnemonic (NULL, _("800x600"));
  gtk_widget_show (radioSize800);
  gtk_box_pack_start (GTK_BOX (hbox7), radioSize800, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioSize800), radioSize640_group);
  radioSize640_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioSize800));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radioSize800), TRUE);

  radioSize1024 = gtk_radio_button_new_with_mnemonic (NULL, _("1024x768"));
  gtk_widget_show (radioSize1024);
  gtk_box_pack_start (GTK_BOX (hbox7), radioSize1024, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioSize1024), radioSize640_group);
  radioSize640_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioSize1024));

  radioSize1280 = gtk_radio_button_new_with_mnemonic (NULL, _("1280x960"));
  gtk_widget_show (radioSize1280);
  gtk_box_pack_start (GTK_BOX (hbox7), radioSize1280, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioSize1280), radioSize640_group);
  radioSize640_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioSize1280));

  label10 = gtk_label_new (_("<b>Default Window Size (no speed impact)</b>"));
  gtk_widget_show (label10);
  gtk_frame_set_label_widget (GTK_FRAME (frame5), label10);
  gtk_label_set_use_markup (GTK_LABEL (label10), TRUE);

  frame6 = gtk_frame_new (NULL);
  gtk_widget_show (frame6);
  gtk_box_pack_start (GTK_BOX (vbox4), frame6, TRUE, TRUE, 0);

  alignment3 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_show (alignment3);
  gtk_container_add (GTK_CONTAINER (frame6), alignment3);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment3), 0, 0, 12, 0);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow1);
  gtk_container_add (GTK_CONTAINER (alignment3), scrolledwindow1);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);

  treeview1 = gtk_tree_view_new ();
  gtk_widget_show (treeview1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview1);

  label12 = gtk_label_new (_("<b>Advanced Options</b>"));
  gtk_widget_show (label12);
  gtk_frame_set_label_widget (GTK_FRAME (frame6), label12);
  gtk_label_set_use_markup (GTK_LABEL (label12), TRUE);

  label11 = gtk_label_new (_("Show Frames Per Second (Shift+F7)\n   (value is the average over 4-16 PS2 frames)"));
  gtk_widget_show (label11);
  gtk_box_pack_start (GTK_BOX (vbox4), label11, FALSE, FALSE, 0);

  hbuttonbox1 = gtk_hbutton_box_new ();
  gtk_widget_show (hbuttonbox1);
  gtk_box_pack_start (GTK_BOX (vbox4), hbuttonbox1, FALSE, FALSE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_SPREAD);
  gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 30);

  button1 = gtk_button_new_with_mnemonic (_("Ok"));
  gtk_widget_show (button1);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), button1);
  GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);

  button2 = gtk_button_new_with_mnemonic (_("Cancel"));
  gtk_widget_show (button2);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), button2);
  GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT);

  g_signal_connect ((gpointer) button1, "clicked",
                    G_CALLBACK (OnConf_Ok),
                    NULL);
  g_signal_connect ((gpointer) button2, "clicked",
                    G_CALLBACK (OnConf_Cancel),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (Config, Config, "Config");
  GLADE_HOOKUP_OBJECT (Config, vbox4, "vbox4");
  GLADE_HOOKUP_OBJECT (Config, frame7, "frame7");
  GLADE_HOOKUP_OBJECT (Config, alignment4, "alignment4");
  GLADE_HOOKUP_OBJECT (Config, hbox8, "hbox8");
  GLADE_HOOKUP_OBJECT (Config, radionointerlace, "radionointerlace");
  GLADE_HOOKUP_OBJECT (Config, radiointerlace0, "radiointerlace0");
  GLADE_HOOKUP_OBJECT (Config, radiointerlace1, "radiointerlace1");
  GLADE_HOOKUP_OBJECT (Config, label13, "label13");
  GLADE_HOOKUP_OBJECT (Config, checkBilinear, "checkBilinear");
  GLADE_HOOKUP_OBJECT (Config, frame4, "frame4");
  GLADE_HOOKUP_OBJECT (Config, alignment1, "alignment1");
  GLADE_HOOKUP_OBJECT (Config, hbox6, "hbox6");
  GLADE_HOOKUP_OBJECT (Config, radioAANone, "radioAANone");
  GLADE_HOOKUP_OBJECT (Config, radioAA2X, "radioAA2X");
  GLADE_HOOKUP_OBJECT (Config, radioAA4X, "radioAA4X");
  GLADE_HOOKUP_OBJECT (Config, radioAA8X, "radioAA8X");
  GLADE_HOOKUP_OBJECT (Config, radioAA16X, "radioAA16X");
  GLADE_HOOKUP_OBJECT (Config, label9, "label9");
  GLADE_HOOKUP_OBJECT (Config, checkWireframe, "checkWireframe");
  GLADE_HOOKUP_OBJECT (Config, checkAVI, "checkAVI");
  GLADE_HOOKUP_OBJECT (Config, checkTGA, "checkTGA");
  GLADE_HOOKUP_OBJECT (Config, checkfullscreen, "checkfullscreen");
  GLADE_HOOKUP_OBJECT (Config, frame5, "frame5");
  GLADE_HOOKUP_OBJECT (Config, alignment2, "alignment2");
  GLADE_HOOKUP_OBJECT (Config, hbox7, "hbox7");
  GLADE_HOOKUP_OBJECT (Config, radioSize640, "radioSize640");
  GLADE_HOOKUP_OBJECT (Config, radioSize800, "radioSize800");
  GLADE_HOOKUP_OBJECT (Config, radioSize1024, "radioSize1024");
  GLADE_HOOKUP_OBJECT (Config, radioSize1280, "radioSize1280");
  GLADE_HOOKUP_OBJECT (Config, label10, "label10");
  GLADE_HOOKUP_OBJECT (Config, frame6, "frame6");
  GLADE_HOOKUP_OBJECT (Config, alignment3, "alignment3");
  GLADE_HOOKUP_OBJECT (Config, scrolledwindow1, "scrolledwindow1");
  GLADE_HOOKUP_OBJECT (Config, treeview1, "treeview1");
  GLADE_HOOKUP_OBJECT (Config, label12, "label12");
  GLADE_HOOKUP_OBJECT (Config, label11, "label11");
  GLADE_HOOKUP_OBJECT (Config, hbuttonbox1, "hbuttonbox1");
  GLADE_HOOKUP_OBJECT (Config, button1, "button1");
  GLADE_HOOKUP_OBJECT (Config, button2, "button2");

  return Config;
}
Exemplo n.º 25
0
static void
caja_file_conflict_dialog_init (CajaFileConflictDialog *fcd)
{
#if GTK_CHECK_VERSION (3, 0, 0)
    GtkWidget *hbox, *vbox, *vbox2;
#else
    GtkWidget *hbox, *vbox, *vbox2, *alignment;
#endif
    GtkWidget *widget, *dialog_area;
    CajaFileConflictDialogDetails *details;
    GtkDialog *dialog;

    details = fcd->details = CAJA_FILE_CONFLICT_DIALOG_GET_PRIVATE (fcd);
    dialog = GTK_DIALOG (fcd);

    /* Setup the main hbox */
    hbox = gtk_hbox_new (FALSE, 12);
    dialog_area = gtk_dialog_get_content_area (dialog);
    gtk_box_pack_start (GTK_BOX (dialog_area), hbox, FALSE, FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);

    /* Setup the dialog image */
    widget = gtk_image_new_from_icon_name ("dialog-warning",
                                       GTK_ICON_SIZE_DIALOG);
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION (3, 0, 0)
    gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
    gtk_widget_set_valign (widget, GTK_ALIGN_START);
#else
    gtk_misc_set_alignment (GTK_MISC (widget), 0.5, 0.0);
#endif

    /* Setup the vbox containing the dialog body */
    vbox = gtk_vbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

    /* Setup the vbox for the dialog labels */
    widget = gtk_vbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
    details->titles_vbox = widget;

    /* Setup the hboxes to pack file infos into */
#if GTK_CHECK_VERSION (3, 0, 0)
    vbox2 = gtk_vbox_new (FALSE, 12);
    gtk_widget_set_halign (vbox2, GTK_ALIGN_START);
    gtk_widget_set_valign (vbox2, GTK_ALIGN_START);
    gtk_widget_set_margin_start (vbox2, 12);
    gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
#else
    alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
    g_object_set (alignment, "left-padding", 12, NULL);
    vbox2 = gtk_vbox_new (FALSE, 12);
    gtk_container_add (GTK_CONTAINER (alignment), vbox2);
    gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
#endif

    hbox = gtk_hbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
    details->first_hbox = hbox;

    hbox = gtk_hbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
    details->second_hbox = hbox;

    /* Setup the expander for the rename action */
    details->expander = gtk_expander_new_with_mnemonic (_("Select a new name for the _destination"));
    gtk_box_pack_start (GTK_BOX (vbox2), details->expander, FALSE, FALSE, 0);
    g_signal_connect (details->expander, "activate",
                      G_CALLBACK (expander_activated_cb), dialog);

    hbox = gtk_hbox_new (FALSE, 6);
    gtk_container_add (GTK_CONTAINER (details->expander), hbox);

    widget = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 6);
    details->entry = widget;
    g_signal_connect (widget, "changed",
                      G_CALLBACK (entry_text_changed_cb), dialog);

    widget = gtk_button_new_with_label (_("Reset"));
    gtk_button_set_image (GTK_BUTTON (widget),
                          gtk_image_new_from_stock (GTK_STOCK_UNDO,
                                  GTK_ICON_SIZE_MENU));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    g_signal_connect (widget, "clicked",
                      G_CALLBACK (reset_button_clicked_cb), dialog);

#if GTK_CHECK_VERSION (3, 0, 0)
    gtk_widget_show_all (vbox2);
#else
    gtk_widget_show_all (alignment);
#endif

    /* Setup the diff button for text files */
    details->diff_button = gtk_button_new_with_label (_("Differences..."));
    gtk_button_set_image (GTK_BUTTON (details->diff_button),
                          gtk_image_new_from_stock (GTK_STOCK_FIND,
                                  GTK_ICON_SIZE_MENU));
    gtk_box_pack_start (GTK_BOX (vbox), details->diff_button, FALSE, FALSE, 6);
    g_signal_connect (details->diff_button, "clicked",
                      G_CALLBACK (diff_button_clicked_cb), dialog);
    gtk_widget_hide (details->diff_button);

    /* Setup the checkbox to apply the action to all files */
    widget = gtk_check_button_new_with_mnemonic (_("Apply this action to all files"));
    gtk_box_pack_start (GTK_BOX (vbox),
                        widget, FALSE, FALSE, 0);
    details->checkbox = widget;
    g_signal_connect (widget, "toggled",
                      G_CALLBACK (checkbox_toggled_cb), dialog);

    /* Add buttons */
    gtk_dialog_add_buttons (dialog,
                            GTK_STOCK_CANCEL,
                            GTK_RESPONSE_CANCEL,
                            _("_Skip"),
                            CONFLICT_RESPONSE_SKIP,
                            NULL);
    details->rename_button =
        gtk_dialog_add_button (dialog,
                               _("Re_name"),
                               CONFLICT_RESPONSE_RENAME);
    gtk_widget_hide (details->rename_button);

    details->replace_button =
        gtk_dialog_add_button (dialog,
                               _("Replace"),
                               CONFLICT_RESPONSE_REPLACE);
    gtk_widget_grab_focus (details->replace_button);

    /* Setup HIG properties */
    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
    gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (dialog)), 14);
    gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

    gtk_widget_show_all (dialog_area);
}
Exemplo n.º 26
0
gint
setup_game (GtkAction * action, gpointer data)
{
  GtkWidget *box, *box2, *label, *button, *frame;
  GtkWidget *grid;
  GtkWidget *combo;
  gchar *ts;
  int i;

  if (setupdialog) {
    gtk_window_present (GTK_WINDOW (setupdialog));
    return FALSE;
  }

  setupdialog = gtk_dialog_new_with_buttons (_("Tali Preferences"),
					     GTK_WINDOW (window),
					     GTK_DIALOG_DESTROY_WITH_PARENT,
					     GTK_STOCK_CLOSE,
					     GTK_RESPONSE_CLOSE, NULL);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (setupdialog))), 2);
  gtk_window_set_resizable (GTK_WINDOW (setupdialog), FALSE);
  g_signal_connect (G_OBJECT (setupdialog), "delete_event",
		    G_CALLBACK (setupdialog_destroy), NULL);
  button = gtk_button_new_from_stock (GTK_STOCK_OK);
  g_signal_connect (G_OBJECT (setupdialog), "response",
		    G_CALLBACK (do_setup), NULL);

  grid = gtk_grid_new ();
  gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
  gtk_grid_set_row_spacing (GTK_GRID (grid), 18);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 18);

  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (setupdialog))), 
                      grid, FALSE, FALSE, 0);

  frame = games_frame_new (_("Human Players"));
  gtk_grid_attach (GTK_GRID (grid), frame, 0, 0, 1, 1);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (frame), box);

	/*--- Spinner (number of humans) ---*/
  OriginalNumberOfHumans = NumberOfHumans;
  box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_box_pack_start (GTK_BOX (box), box2, FALSE, FALSE, 0);
  label = gtk_label_new_with_mnemonic (_("_Number of players:"));

  gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
  HumanAdj = gtk_adjustment_new ((gfloat) NumberOfHumans, 1.0,
				 6.0, 1.0, 6.0, 0.0);
  HumanSpinner = gtk_spin_button_new (GTK_ADJUSTMENT (HumanAdj), 10, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), HumanSpinner);

  g_signal_connect (G_OBJECT (HumanAdj), "value_changed",
		    G_CALLBACK (MaxPlayersCheck), HumanAdj);

  gtk_box_pack_start (GTK_BOX (box2), HumanSpinner, TRUE, TRUE, 0);


  frame = games_frame_new (_("Computer Opponents"));
  gtk_grid_attach (GTK_GRID (grid), frame, 0, 1, 1, 1);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (frame), box);

	/*--- Button ---*/
  button = gtk_check_button_new_with_mnemonic (_("_Delay between rolls"));
  gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), DoDelay);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (set_as_int), &tmpDoDelay);

	/*--- Spinner (number of computers) ---*/
  OriginalNumberOfComputers = NumberOfComputers;
  box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_box_pack_start (GTK_BOX (box), box2, FALSE, FALSE, 0);
  label = gtk_label_new_with_mnemonic (_("N_umber of opponents:"));
  gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);

  ComputerAdj = gtk_adjustment_new ((gfloat) NumberOfComputers,
				    0.0, 5.0, 1.0, 5.0, 0.0);
  ComputerSpinner = gtk_spin_button_new (GTK_ADJUSTMENT (ComputerAdj), 10, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), ComputerSpinner);

  g_signal_connect (G_OBJECT (ComputerAdj), "value_changed",
		    G_CALLBACK (MaxPlayersCheck), ComputerAdj);
  gtk_box_pack_start (GTK_BOX (box2), ComputerSpinner, TRUE, TRUE, 0);

  box2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_pack_start(GTK_BOX(box), box2, FALSE, FALSE, 0);
  label = gtk_label_new_with_mnemonic (_("_Difficulty:"));
  gtk_box_pack_start(GTK_BOX(box2), label, FALSE, FALSE, 0);
  combo = gtk_combo_box_text_new();
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("difficulty", "Easy"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("difficulty", "Medium"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("difficulty", "Hard"));
  skill_level = 0;
  while (NUM_TRIALS > skill_level_table[skill_level].trials &&
         skill_level < (SKILL_LEVEL_TABLE_SIZE - 1)) skill_level++;
  gtk_combo_box_set_active(GTK_COMBO_BOX(combo), skill_level);
  g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (SetSkillLevel),
                    combo);
  gtk_box_pack_start(GTK_BOX(box2), combo, FALSE, FALSE, 0);

    /*--- Combo (yahtzee or kismet style ----*/

  frame = games_frame_new (_("Game Type"));
  gtk_grid_attach (GTK_GRID (grid), frame, 0, 2, 1, 1);
  combo = gtk_combo_box_text_new();
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("game type", "Regular"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("game type", "Colors"));
  gtk_combo_box_set_active(GTK_COMBO_BOX(combo), game_type);
  NewGameType = game_type;
  g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (SetGameType),
                    combo);
  gtk_container_add (GTK_CONTAINER (frame), combo);

	/*--- PLAYER NAMES FRAME ----*/
  frame = games_frame_new (_("Player Names"));
  gtk_grid_attach (GTK_GRID (grid), frame, 1, 0, 1, 3);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (frame), box);

  for (i = 0; i < MAX_NUMBER_OF_PLAYERS; i++) {
    box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);

    gtk_box_pack_start (GTK_BOX (box), box2, FALSE, FALSE, 0);
    ts = g_strdup_printf ("_%1d:", i + 1);
    label = gtk_label_new_with_mnemonic (ts);
    g_free (ts);
    gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);

    PlayerNames[i] = gtk_entry_new ();
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), PlayerNames[i]);
    ts = g_strdup_printf ("PlayerName%1d", i + 1);
    gtk_widget_set_name (PlayerNames[i], ts);
    g_free (ts);
    gtk_entry_set_text (GTK_ENTRY (PlayerNames[i]), players[i].name);
    gtk_box_pack_start (GTK_BOX (box2), PlayerNames[i], FALSE, FALSE, 0);
  }

  gtk_widget_show_all (setupdialog);

  return FALSE;
}
Exemplo n.º 27
0
/*! \brief Creates the hotkeys dialog
 *  \par Function Description
 *  This function creates the hotkey dialog and puts the list of hotkeys
 *  into it.
 */
void x_dialog_hotkeys (GschemToplevel *w_current)
{
  GtkWidget *vbox, *scrolled_win;
  GtkTreeModel *store;
  GtkWidget *treeview;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  if (!w_current->hkwindow) {
    w_current->hkwindow = gschem_dialog_new_with_buttons(_("Hotkeys"),
                                                         GTK_WINDOW(w_current->main_window),
                                                         0, /* not modal */
                                                         "hotkeys", w_current,
                                                         GTK_STOCK_CLOSE,
                                                         GTK_RESPONSE_REJECT,
                                                         NULL);

    gtk_window_set_position (GTK_WINDOW (w_current->hkwindow), GTK_WIN_POS_NONE);

    g_signal_connect (G_OBJECT (w_current->hkwindow), "response",
                      G_CALLBACK (x_dialog_hotkeys_response),
                      w_current);

    gtk_dialog_set_default_response(GTK_DIALOG(w_current->hkwindow),
                                    GTK_RESPONSE_ACCEPT);

    gtk_container_set_border_width (GTK_CONTAINER (w_current->hkwindow),
                                    DIALOG_BORDER_SPACING);
    gtk_widget_set_size_request (w_current->hkwindow, 300, 300);

    vbox = GTK_DIALOG(w_current->hkwindow)->vbox;
    gtk_box_set_spacing(GTK_BOX(vbox), DIALOG_V_SPACING);

    scrolled_win = gtk_scrolled_window_new (NULL, NULL);
    gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);

    /* the model */
    store = GTK_TREE_MODEL (gschem_hotkey_store_new ());

    /* the tree view */
    treeview = gtk_tree_view_new_with_model (store);
    gtk_container_add(GTK_CONTAINER(scrolled_win), treeview);

    /* the columns */
    /* The first column contains the action's icon (if one was set)
     * and its label. */
    renderer = gtk_cell_renderer_pixbuf_new ();
    column = gtk_tree_view_column_new_with_attributes (_("Action"),
                                                       renderer,
                                                       "stock-id",
                                                       GSCHEM_HOTKEY_STORE_COLUMN_ICON,
                                                       NULL);
    /* Fix things up to show stock icons *and* theme icons. */
    g_signal_connect (renderer, "notify::stock-id",
                      G_CALLBACK (x_dialog_hotkeys_cell_stock_id_notify),
                      NULL);

    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer, FALSE);
    gtk_tree_view_column_set_attributes (column, renderer,
                                         "text", GSCHEM_HOTKEY_STORE_COLUMN_LABEL,
                                         NULL);

    /* The second column contains the action's keybinding */
    gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
    column = gtk_tree_view_column_new_with_attributes (_("Keystroke(s)"),
                                                       renderer,
                                                       "text",
                                                       GSCHEM_HOTKEY_STORE_COLUMN_KEYS,
                                                       NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

    /* show all recursively */
    gtk_widget_show_all(w_current->hkwindow);
  }

  else { /* dialog already created */
    gtk_window_present(GTK_WINDOW(w_current->hkwindow));
  }
}
Exemplo n.º 28
0
static GtkWidget * equalizerwin_create_list_window (Index * preset_list,
                                const gchar *title,
                                GtkWidget **window,
                                GtkSelectionMode sel_mode,
                                GtkWidget **entry,
                                const gchar *action_name,
                                GCallback action_func,
                                GCallback select_row_func)
{
    GtkWidget *vbox, *scrolled_window, *bbox, *view;
    GtkWidget *button_cancel, *button_action;

    GtkListStore *store;
    GtkTreeIter iter;
    GtkTreeModel *model;
    GtkCellRenderer *renderer;
    GtkTreeSelection *selection;
    GtkTreeSortable *sortable;



    *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(*window), title);
    gtk_window_set_type_hint(GTK_WINDOW(*window), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300);
    gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(*window), 10);
    gtk_window_set_transient_for(GTK_WINDOW(*window),
                                 GTK_WINDOW(equalizerwin));
    g_signal_connect(*window, "destroy",
                     G_CALLBACK(gtk_widget_destroyed), window);

    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
    gtk_container_add(GTK_CONTAINER(*window), vbox);

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


    /* fill the store with the names of all available presets */
    store = gtk_list_store_new(1, G_TYPE_STRING);
    for (int p = 0; p < index_count (preset_list); p ++)
    {
        EqualizerPreset * preset = index_get (preset_list, p);
        gtk_list_store_append(store, &iter);
        gtk_list_store_set (store, & iter, 0, preset->name, -1);
    }
    model = GTK_TREE_MODEL(store);


    sortable = GTK_TREE_SORTABLE(store);
    gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING);


    view = gtk_tree_view_new();
    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1,
                                                _("Presets"), renderer,
                                                "text", 0, NULL);
    gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
    g_object_unref(model);

    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    gtk_tree_selection_set_mode(selection, sel_mode);




    gtk_container_add(GTK_CONTAINER(scrolled_window), view);
    gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);

    if (entry) {
        *entry = gtk_entry_new();
        g_signal_connect(*entry, "activate", action_func, NULL);
        gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0);
    }

    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), 5);
    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);

    button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    g_signal_connect_swapped (button_cancel, "clicked", (GCallback)
     gtk_widget_destroy, * window);
    gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0);

    button_action = gtk_button_new_from_stock(action_name);
    g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view);
    gtk_widget_set_can_default (button_action, TRUE);

    if (select_row_func)
        g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL);


    gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0);

    gtk_widget_grab_default(button_action);


    gtk_widget_show_all(*window);

    return *window;
}
void
procdialog_create_preferences_dialog (ProcData *procdata)
{
    static GtkWidget *dialog = NULL;

    typedef SpinButtonUpdater SBU;

    static SBU interval_updater("update-interval");
    static SBU graph_interval_updater("graph-update-interval");
    static SBU disks_interval_updater("disks-interval");

    GtkWidget *notebook;
    GtkWidget *proc_box;
    GtkWidget *sys_box;
    GtkWidget *main_vbox;
    GtkWidget *vbox, *vbox2, *vbox3;
    GtkWidget *hbox, *hbox2, *hbox3;
    GtkWidget *label;
    GtkAdjustment *adjustment;
    GtkWidget *spin_button;
    GtkWidget *check_button;
    GtkWidget *tab_label;
    GtkWidget *smooth_button;
    GtkSizeGroup *size;
    gfloat update;
    gchar *tmp;

    if (prefs_dialog)
        return;

    size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

    dialog = gtk_dialog_new_with_buttons (_("System Monitor Preferences"),
                                          GTK_WINDOW (procdata->app),
                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                          "gtk-help", GTK_RESPONSE_HELP,
                                          "gtk-close", GTK_RESPONSE_CLOSE,
                                          NULL);
    /* FIXME: we should not declare the window size, but let it's   */
    /* driven by window childs. The problem is that the fields list */
    /* have to show at least 4 items to respect HIG. I don't know   */
    /* any function to set list height by contents/items inside it. */
    gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 500);
    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
    prefs_dialog = dialog;

    main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
    gtk_box_set_spacing (GTK_BOX (main_vbox), 2);

    notebook = gtk_notebook_new ();
    gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
    gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0);

    proc_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
    gtk_container_set_border_width (GTK_CONTAINER (proc_box), 12);
    tab_label = gtk_label_new (_("Processes"));
    gtk_widget_show (tab_label);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), proc_box, tab_label);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (proc_box), vbox, FALSE, FALSE, 0);

    tmp = g_strdup_printf ("<b>%s</b>", _("Behavior"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

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

    label = gtk_label_new ("    ");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

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

    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);

    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);

    update = (gfloat) procdata->config.update_interval;
    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
                                   MIN_UPDATE_INTERVAL / 1000,
                                   MAX_UPDATE_INTERVAL / 1000,
                                   0.25,
                                   1.0,
                                   0);

    spin_button = gtk_spin_button_new (adjustment, 1.0, 2);
    gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
                      G_CALLBACK (SBU::callback), &interval_updater);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);


    hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0);

    smooth_button = gtk_check_button_new_with_mnemonic(_("Enable _smooth refresh"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(smooth_button),
                                 g_settings_get_boolean(procdata->settings,
                                                        SmoothRefresh::KEY.c_str()));
    g_signal_connect(G_OBJECT(smooth_button), "toggled",
                     G_CALLBACK(smooth_refresh_toggled), procdata);
    gtk_box_pack_start(GTK_BOX(hbox2), smooth_button, TRUE, TRUE, 0);



    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    check_button = gtk_check_button_new_with_mnemonic (_("Alert before ending or _killing processes"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
                                  procdata->config.show_kill_warning);
    g_signal_connect (G_OBJECT (check_button), "toggled",
                                G_CALLBACK (show_kill_dialog_toggled), procdata);
    gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0);




    hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0);

    GtkWidget *solaris_button = gtk_check_button_new_with_mnemonic(_("Divide CPU usage by CPU count"));
    gtk_widget_set_tooltip_text(solaris_button, _("Solaris mode"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(solaris_button),
                                 g_settings_get_boolean(procdata->settings,
                                                        procman::settings::solaris_mode.c_str()));
    g_signal_connect(G_OBJECT(solaris_button), "toggled",
                     G_CALLBACK(solaris_mode_toggled), procdata);
    gtk_box_pack_start(GTK_BOX(hbox2), solaris_button, TRUE, TRUE, 0);




    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

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

    tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

    label = gtk_label_new ("    ");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

    vbox2 = create_field_page (procdata->tree, "proctree", _("Process i_nformation shown in list:"));
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);

    sys_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
    gtk_container_set_border_width (GTK_CONTAINER (sys_box), 12);
    tab_label = gtk_label_new (_("Resources"));
    gtk_widget_show (tab_label);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sys_box, tab_label);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (sys_box), vbox, FALSE, FALSE, 0);

    tmp = g_strdup_printf ("<b>%s</b>", _("Graphs"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0);

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

    label = gtk_label_new ("    ");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

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

    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    label = gtk_label_new_with_mnemonic (_("_Update interval in 1/10 sec:"));
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
    gtk_size_group_add_widget (size, label);

    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);

    update = (gfloat) procdata->config.graph_update_interval;
    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
                                                      100.0, 0.25, 1.0, 0);
    spin_button = gtk_spin_button_new (adjustment, 1.0, 2);
    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
                      G_CALLBACK(SBU::callback),
                      &graph_interval_updater);
    gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);


    GtkWidget *bits_button;
    bits_button = gtk_check_button_new_with_mnemonic(_("Show network speed in bits"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bits_button),
                                 g_settings_get_boolean(procdata->settings,
                                                        procman::settings::network_in_bits.c_str()));

    g_signal_connect(G_OBJECT(bits_button), "toggled",
                     G_CALLBACK(network_in_bits_toggled), procdata);
    gtk_box_pack_start(GTK_BOX(vbox2), bits_button, TRUE, TRUE, 0);



    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0);

    /*
     * Devices
     */
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
    tab_label = gtk_label_new (_("File Systems"));
    gtk_widget_show (tab_label);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, tab_label);

    tmp = g_strdup_printf ("<b>%s</b>", _("File Systems"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

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

    label = gtk_label_new ("    ");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

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

    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);

    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);

    update = (gfloat) procdata->config.disks_update_interval;
    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
                                                       100.0, 1.0, 1.0, 0);
    spin_button = gtk_spin_button_new (adjustment, 1.0, 0);
    gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
                      G_CALLBACK(SBU::callback),
                      &disks_interval_updater);


    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
    check_button = gtk_check_button_new_with_mnemonic (_("Show _all file systems"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
                                  procdata->config.show_all_fs);
    g_signal_connect (G_OBJECT (check_button), "toggled",
                      G_CALLBACK (show_all_fs_toggled), procdata);
    gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0);


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

    label = gtk_label_new ("    ");
    gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);

    tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

    label = gtk_label_new ("    ");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

    vbox3 = create_field_page (procdata->disk_list, "disktreenew", _("File system i_nformation shown in list:"));
    gtk_box_pack_start (GTK_BOX (hbox), vbox3, TRUE, TRUE, 0);

    gtk_widget_show_all (dialog);
    g_signal_connect (G_OBJECT (dialog), "response",
                      G_CALLBACK (prefs_dialog_button_pressed), procdata);

    switch (procdata->config.current_tab) {
    case PROCMAN_TAB_SYSINFO:
    case PROCMAN_TAB_PROCESSES:
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
        break;
    case PROCMAN_TAB_RESOURCES:
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
        break;
    case PROCMAN_TAB_DISKS:
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
        break;

    }
}
Exemplo n.º 30
0
GtkWidget*
create_windowPreferences (void)
{
  GtkWidget *windowPreferences;
  GtkWidget *vboxPrefs;
  GtkWidget *hboxUserName;
  GtkWidget *labelUserName;
  GtkWidget *entryUserName;
  GtkWidget *hbuttonboxBtns;
  GtkWidget *buttonCancel;
  GtkWidget *buttonApply;
  GtkWidget *hbox1;
  GtkWidget *vbox2;
  GtkWidget *frameHabits;
  GtkWidget *hbox3;
  GtkWidget *vbox3;
  GtkWidget *treeviewHabits;
  GtkWidget *vbuttonboxHabits;
  GtkWidget *buttonAddHabit;
  GtkWidget *buttonRemoveHabit;
  GtkWidget *buttonEditHabit;
  GtkWidget *label11;

  windowPreferences = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (windowPreferences, "windowPreferences");
  gtk_window_set_title (GTK_WINDOW (windowPreferences), "Preferences");
  gtk_window_set_resizable (GTK_WINDOW (windowPreferences), FALSE);

  vboxPrefs = gtk_vbox_new (FALSE, 5);
  gtk_widget_set_name (vboxPrefs, "vboxPrefs");
  gtk_widget_show (vboxPrefs);
  gtk_container_add (GTK_CONTAINER (windowPreferences), vboxPrefs);
  gtk_container_set_border_width (GTK_CONTAINER (vboxPrefs), 3);

  hboxUserName = gtk_hbox_new (FALSE, 5);
  gtk_widget_set_name (hboxUserName, "hboxUserName");
  gtk_widget_show (hboxUserName);
  gtk_box_pack_start (GTK_BOX (vboxPrefs), hboxUserName, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hboxUserName), 3);

  labelUserName = gtk_label_new ("User name");
  gtk_widget_set_name (labelUserName, "labelUserName");
  gtk_widget_show (labelUserName);
  gtk_box_pack_start (GTK_BOX (hboxUserName), labelUserName, FALSE, FALSE, 0);

  entryUserName = gtk_entry_new ();
  gtk_widget_set_name (entryUserName, "entryUserName");
  gtk_widget_show (entryUserName);
  gtk_box_pack_start (GTK_BOX (hboxUserName), entryUserName, FALSE, FALSE, 0);
  gtk_entry_set_max_length (GTK_ENTRY (entryUserName), 20);
  gtk_entry_set_width_chars (GTK_ENTRY (entryUserName), 21);

  hbuttonboxBtns = gtk_hbutton_box_new ();
  gtk_widget_set_name (hbuttonboxBtns, "hbuttonboxBtns");
  gtk_widget_show (hbuttonboxBtns);
  gtk_box_pack_end (GTK_BOX (vboxPrefs), hbuttonboxBtns, FALSE, FALSE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonboxBtns), GTK_BUTTONBOX_END);
  gtk_box_set_spacing (GTK_BOX (hbuttonboxBtns), 5);

  buttonCancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_set_name (buttonCancel, "buttonCancel");
  gtk_widget_show (buttonCancel);
  gtk_container_add (GTK_CONTAINER (hbuttonboxBtns), buttonCancel);
  GTK_WIDGET_SET_FLAGS (buttonCancel, GTK_CAN_DEFAULT);

  buttonApply = gtk_button_new_from_stock ("gtk-apply");
  gtk_widget_set_name (buttonApply, "buttonApply");
  gtk_widget_show (buttonApply);
  gtk_container_add (GTK_CONTAINER (hbuttonboxBtns), buttonApply);
  GTK_WIDGET_SET_FLAGS (buttonApply, GTK_CAN_DEFAULT);

  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox1, "hbox1");
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vboxPrefs), hbox1, TRUE, TRUE, 0);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox2, "vbox2");
  gtk_widget_show (vbox2);
  gtk_box_pack_start (GTK_BOX (hbox1), vbox2, TRUE, TRUE, 0);

  frameHabits = gtk_frame_new (NULL);
  gtk_widget_set_name (frameHabits, "frameHabits");
  gtk_widget_show (frameHabits);
  gtk_box_pack_start (GTK_BOX (vbox2), frameHabits, TRUE, TRUE, 0);

  hbox3 = gtk_hbox_new (FALSE, 5);
  gtk_widget_set_name (hbox3, "hbox3");
  gtk_widget_show (hbox3);
  gtk_container_add (GTK_CONTAINER (frameHabits), hbox3);
  gtk_container_set_border_width (GTK_CONTAINER (hbox3), 5);

  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox3, "vbox3");
  gtk_widget_show (vbox3);
  gtk_box_pack_start (GTK_BOX (hbox3), vbox3, TRUE, TRUE, 0);

  treeviewHabits = gtk_tree_view_new ();
  gtk_widget_set_name (treeviewHabits, "treeviewHabits");
  gtk_widget_show (treeviewHabits);
  gtk_box_pack_start (GTK_BOX (vbox3), treeviewHabits, TRUE, TRUE, 0);

  vbuttonboxHabits = gtk_vbutton_box_new ();
  gtk_widget_set_name (vbuttonboxHabits, "vbuttonboxHabits");
  gtk_widget_show (vbuttonboxHabits);
  gtk_box_pack_start (GTK_BOX (hbox3), vbuttonboxHabits, FALSE, TRUE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (vbuttonboxHabits), GTK_BUTTONBOX_START);

  buttonAddHabit = gtk_button_new_from_stock ("gtk-add");
  gtk_widget_set_name (buttonAddHabit, "buttonAddHabit");
  gtk_widget_show (buttonAddHabit);
  gtk_container_add (GTK_CONTAINER (vbuttonboxHabits), buttonAddHabit);
  GTK_WIDGET_SET_FLAGS (buttonAddHabit, GTK_CAN_DEFAULT);

  buttonRemoveHabit = gtk_button_new_from_stock ("gtk-remove");
  gtk_widget_set_name (buttonRemoveHabit, "buttonRemoveHabit");
  gtk_widget_show (buttonRemoveHabit);
  gtk_container_add (GTK_CONTAINER (vbuttonboxHabits), buttonRemoveHabit);
  gtk_widget_set_sensitive (buttonRemoveHabit, FALSE);
  GTK_WIDGET_SET_FLAGS (buttonRemoveHabit, GTK_CAN_DEFAULT);

  buttonEditHabit = gtk_button_new_from_stock ("gtk-properties");
  gtk_widget_set_name (buttonEditHabit, "buttonEditHabit");
  gtk_widget_show (buttonEditHabit);
  gtk_container_add (GTK_CONTAINER (vbuttonboxHabits), buttonEditHabit);
  gtk_widget_set_sensitive (buttonEditHabit, FALSE);
  GTK_WIDGET_SET_FLAGS (buttonEditHabit, GTK_CAN_DEFAULT);

  label11 = gtk_label_new ("Habits");
  gtk_widget_set_name (label11, "label11");
  gtk_widget_show (label11);
  gtk_frame_set_label_widget (GTK_FRAME (frameHabits), label11);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (windowPreferences, windowPreferences, "windowPreferences");
  GLADE_HOOKUP_OBJECT (windowPreferences, vboxPrefs, "vboxPrefs");
  GLADE_HOOKUP_OBJECT (windowPreferences, hboxUserName, "hboxUserName");
  GLADE_HOOKUP_OBJECT (windowPreferences, labelUserName, "labelUserName");
  GLADE_HOOKUP_OBJECT (windowPreferences, entryUserName, "entryUserName");
  GLADE_HOOKUP_OBJECT (windowPreferences, hbuttonboxBtns, "hbuttonboxBtns");
  GLADE_HOOKUP_OBJECT (windowPreferences, buttonCancel, "buttonCancel");
  GLADE_HOOKUP_OBJECT (windowPreferences, buttonApply, "buttonApply");
  GLADE_HOOKUP_OBJECT (windowPreferences, hbox1, "hbox1");
  GLADE_HOOKUP_OBJECT (windowPreferences, vbox2, "vbox2");
  GLADE_HOOKUP_OBJECT (windowPreferences, frameHabits, "frameHabits");
  GLADE_HOOKUP_OBJECT (windowPreferences, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (windowPreferences, vbox3, "vbox3");
  GLADE_HOOKUP_OBJECT (windowPreferences, treeviewHabits, "treeviewHabits");
  GLADE_HOOKUP_OBJECT (windowPreferences, vbuttonboxHabits, "vbuttonboxHabits");
  GLADE_HOOKUP_OBJECT (windowPreferences, buttonAddHabit, "buttonAddHabit");
  GLADE_HOOKUP_OBJECT (windowPreferences, buttonRemoveHabit, "buttonRemoveHabit");
  GLADE_HOOKUP_OBJECT (windowPreferences, buttonEditHabit, "buttonEditHabit");
  GLADE_HOOKUP_OBJECT (windowPreferences, label11, "label11");

  return windowPreferences;
}