1 #include "global_dialog.h"
2 #include "urlgfe.h"
3 
global_dialog_new(GtkWindow * parent)4 GlobalDialog* global_dialog_new (GtkWindow* parent)
5 {
6 	GlobalDialog* gd = g_malloc (sizeof (GlobalDialog));
7 	GtkWidget* label;
8 	GtkWidget* hbox;
9 	GtkWidget* vbox;
10 	GtkWidget* vbox_dlg;
11 
12 	gd->self = (GtkDialog*) gtk_dialog_new_with_buttons (_("Global Setting"),
13                                                          parent,
14 	    (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT),
15 	                                                     GTK_STOCK_CANCEL,
16 	                                                     GTK_RESPONSE_CANCEL,
17 	                                                     GTK_STOCK_OK,
18 	                                                     GTK_RESPONSE_OK,
19 	                                                     NULL);
20 	gtk_window_set_default_size (GTK_WINDOW (gd->self), 250, 250);
21 	vbox_dlg = gd->self->vbox;
22 	vbox = gtk_vbox_new (FALSE, 5);
23 	hbox = gtk_hbox_new (FALSE, 5);
24 
25 	label = gtk_label_new (_("Global"));
26 	gd->notebook = gtk_notebook_new ();
27 	gtk_box_pack_start (GTK_BOX (vbox_dlg), gd->notebook, TRUE, TRUE, 0);
28 	gtk_notebook_insert_page (GTK_NOTEBOOK(gd->notebook), vbox, label, 0);
29 	gtk_container_set_border_width (GTK_CONTAINER(vbox), 5);
30 
31 	gd->spin_active_category = gtk_spin_button_new_with_range (1.0, 9.0, 1.0);
32 	label = gtk_label_new_with_mnemonic (_("Active _categories :"));
33 	gtk_label_set_mnemonic_widget (GTK_LABEL(label), gd->spin_active_category);
34 	gd->button_visible = gtk_check_button_new_with_mnemonic (_("Display category header"));
35 
36 	gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
37 	gtk_box_pack_start (GTK_BOX(vbox), gd->button_visible, FALSE, FALSE, 0);
38 	gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
39 	gtk_box_pack_start (GTK_BOX(hbox), gd->spin_active_category, FALSE, FALSE, 0);
40 
41 	label = gtk_label_new_with_mnemonic (_("_Monitor these file types in clipboard:"));
42 	gd->entry_extention = gtk_entry_new ();
43 	gd->button_monitoring = gtk_check_button_new_with_mnemonic (_("Monitoring clipboard"));
44 	gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
45 	gtk_box_pack_start (GTK_BOX(vbox), gd->button_monitoring, FALSE, FALSE, 0);
46 	gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0);
47 	gtk_box_pack_start (GTK_BOX(vbox), gd->entry_extention, FALSE, FALSE, 0);
48 
49 	gtk_widget_show_all (gd->notebook);
50 
51 	return gd;
52 }
53 
global_dialog_destroy(GlobalDialog * gd)54 void global_dialog_destroy (GlobalDialog* gd)
55 {
56 	gtk_widget_destroy (GTK_WIDGET (gd->self));
57 	g_free (gd);
58 }
59 
global_dialog_set(GlobalDialog * gd,GlobalSetting * setting)60 void global_dialog_set (GlobalDialog* gd, GlobalSetting* setting)
61 {
62 	gchar* ext_str;
63 
64 	gtk_spin_button_set_value (GTK_SPIN_BUTTON(gd->spin_active_category),
65 	                           setting->n_active_category);
66 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gd->button_visible),
67 	                              setting->header_category_visible);
68 
69 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gd->button_monitoring),
70 	                              setting->monitoring_clipboard);
71 
72 	ext_str = global_setting_get_extention (setting);
73 	gtk_entry_set_text (GTK_ENTRY (gd->entry_extention), ext_str);
74 	g_free (ext_str);
75 }
76 
global_dialog_get(GlobalDialog * gd,GlobalSetting * setting)77 void global_dialog_get (GlobalDialog* gd, GlobalSetting* setting)
78 {
79 	setting->n_active_category = gtk_spin_button_get_value_as_int (
80 	                                GTK_SPIN_BUTTON(gd->spin_active_category) );
81 	setting->header_category_visible = gtk_toggle_button_get_active (
82 	                                GTK_TOGGLE_BUTTON(gd->button_visible) );
83 
84 	setting->monitoring_clipboard = gtk_toggle_button_get_active (
85 	                                GTK_TOGGLE_BUTTON(gd->button_monitoring) );
86 	global_setting_set_extention (setting,
87 	                     gtk_entry_get_text (GTK_ENTRY (gd->entry_extention)) );
88 }
89 
90