2011-06-02 01:44:22 +00:00
|
|
|
/* Pickers
|
2005-05-25 04:09:20 +00:00
|
|
|
*
|
|
|
|
* These widgets are mainly intended for use in preference dialogs.
|
2011-06-02 01:44:22 +00:00
|
|
|
* They allow to select colors, fonts, files, directories and applications.
|
2005-05-25 04:09:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
do_pickers (GtkWidget *do_widget)
|
|
|
|
{
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
GtkWidget *table, *label, *picker;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_screen (GTK_WINDOW (window),
|
|
|
|
gtk_widget_get_screen (do_widget));
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Pickers");
|
2011-06-02 01:44:22 +00:00
|
|
|
|
2005-05-25 04:09:20 +00:00
|
|
|
g_signal_connect (window, "destroy",
|
2015-06-28 13:23:28 +00:00
|
|
|
G_CALLBACK (gtk_widget_destroyed), &window);
|
2011-06-02 01:44:22 +00:00
|
|
|
|
2011-08-31 15:10:19 +00:00
|
|
|
table = gtk_grid_new ();
|
2016-10-26 19:11:18 +00:00
|
|
|
g_object_set (table, "margin", 20, NULL);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (table), 3);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (table), 10);
|
2005-05-25 04:09:20 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), table);
|
|
|
|
|
|
|
|
label = gtk_label_new ("Color:");
|
2011-06-12 23:39:48 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
2005-05-25 04:09:20 +00:00
|
|
|
picker = gtk_color_button_new ();
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (table), picker, 1, 0, 1, 1);
|
2005-05-25 04:09:20 +00:00
|
|
|
|
|
|
|
label = gtk_label_new ("Font:");
|
2011-06-12 23:39:48 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
2005-05-25 04:09:20 +00:00
|
|
|
picker = gtk_font_button_new ();
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (table), picker, 1, 1, 1, 1);
|
2005-05-25 04:09:20 +00:00
|
|
|
|
|
|
|
label = gtk_label_new ("File:");
|
2011-06-12 23:39:48 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
2011-06-02 01:44:22 +00:00
|
|
|
picker = gtk_file_chooser_button_new ("Pick a File",
|
2005-05-25 04:09:20 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
|
2005-05-25 04:09:20 +00:00
|
|
|
|
|
|
|
label = gtk_label_new ("Folder:");
|
2011-06-12 23:39:48 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
2011-06-02 01:44:22 +00:00
|
|
|
picker = gtk_file_chooser_button_new ("Pick a Folder",
|
2005-05-25 04:09:20 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (table), picker, 1, 3, 1, 1);
|
2011-06-02 01:44:22 +00:00
|
|
|
|
|
|
|
label = gtk_label_new ("Mail:");
|
2011-06-12 23:39:48 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
2011-06-02 01:44:22 +00:00
|
|
|
picker = gtk_app_chooser_button_new ("x-scheme-handler/mailto");
|
|
|
|
gtk_app_chooser_button_set_show_dialog_item (GTK_APP_CHOOSER_BUTTON (picker), TRUE);
|
2011-08-31 15:10:19 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (table), label, 0, 4, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (table), picker, 1, 4, 1, 1);
|
2005-05-25 04:09:20 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (!gtk_widget_get_visible (window))
|
2015-06-28 13:23:28 +00:00
|
|
|
gtk_widget_show_all (window);
|
2005-05-25 04:09:20 +00:00
|
|
|
else
|
2015-06-28 13:23:28 +00:00
|
|
|
gtk_widget_destroy (window);
|
2005-05-25 04:09:20 +00:00
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|