From 31375efa710b751f4a64fab47309d6e35560befb Mon Sep 17 00:00:00 2001 From: rbuj Date: Wed, 27 May 2020 12:06:02 +0200 Subject: geyes: Add themes.ui --- geyes/Makefile.am | 45 +++++++--- geyes/geyes-resources.gresource.xml | 6 ++ geyes/themes.c | 108 ++++------------------- geyes/themes.ui | 171 ++++++++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+), 101 deletions(-) create mode 100644 geyes/geyes-resources.gresource.xml create mode 100644 geyes/themes.ui (limited to 'geyes') diff --git a/geyes/Makefile.am b/geyes/Makefile.am index e3c43bcd..514eee30 100644 --- a/geyes/Makefile.am +++ b/geyes/Makefile.am @@ -1,3 +1,5 @@ +NULL = + SUBDIRS = themes docs AM_CPPFLAGS = \ @@ -11,15 +13,24 @@ AM_CPPFLAGS = \ libexec_PROGRAMS = mate-geyes-applet +BUILT_SOURCES = geyes-resources.c geyes-resources.h +nodist_mate_geyes_applet_SOURCES = $(BUILT_SOURCES) mate_geyes_applet_SOURCES = \ - geyes.c \ - themes.c \ - geyes.h + geyes.c \ + geyes.h \ + themes.c \ + $(NULL) -mate_geyes_applet_LDADD = \ - $(MATE_APPLETS4_LIBS) \ +mate_geyes_applet_LDADD = \ + $(MATE_APPLETS4_LIBS) \ -lm +geyes-resources.c: geyes-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/geyes-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name eyes $< + +geyes-resources.h: geyes-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/geyes-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name eyes $< + appletdir = $(datadir)/mate-panel/applets applet_in_files = org.mate.applets.GeyesApplet.mate-panel-applet.desktop.in applet_DATA = $(applet_in_files:.mate-panel-applet.desktop.in=.mate-panel-applet) @@ -60,15 +71,25 @@ icons = \ mate-eyes-applet.22.png \ mate-eyes-applet.16.png -CLEANFILES = $(applet_DATA) $(applet_in_files) $(service_DATA) $(gsettings_SCHEMAS) *.gschema.valid +CLEANFILES = \ + $(BUILT_SOURCES) \ + $(applet_DATA) \ + $(applet_in_files) \ + $(service_DATA) \ + $(gsettings_SCHEMAS) \ + *.gschema.valid \ + $(NULL) EXTRA_DIST = \ - README.themes \ - $(applet_in_files).in \ - $(service_in_files) \ - $(geyes_gschema_in_files) \ - $(ui_DATA) \ - $(icons) + geyes-resources.gresource.xml \ + themes.ui \ + README.themes \ + $(applet_in_files).in \ + $(service_in_files) \ + $(geyes_gschema_in_files) \ + $(ui_DATA) \ + $(icons) \ + $(NULL) gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor diff --git a/geyes/geyes-resources.gresource.xml b/geyes/geyes-resources.gresource.xml new file mode 100644 index 00000000..35ba69aa --- /dev/null +++ b/geyes/geyes-resources.gresource.xml @@ -0,0 +1,6 @@ + + + + themes.ui + + diff --git a/geyes/themes.c b/geyes/themes.c index 74878315..8a3dee59 100644 --- a/geyes/themes.c +++ b/geyes/themes.c @@ -26,8 +26,9 @@ #include #include "geyes.h" +#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x)))) + #define NUM_THEME_DIRECTORIES 2 -#define HIG_IDENTATION " " static char *theme_directories[NUM_THEME_DIRECTORIES]; @@ -249,17 +250,12 @@ void properties_cb (GtkAction *action, EyesApplet *eyes_applet) { - GtkWidget *pbox, *hbox; - GtkWidget *vbox, *indent; - GtkWidget *categories_vbox; - GtkWidget *category_vbox, *control_vbox; + GtkBuilder *builder; GtkWidget *tree; - GtkWidget *scrolled; GtkWidget *label; GtkListStore *model; GtkTreeViewColumn *column; GtkCellRenderer *cell; - GtkTreeSelection *selection; GtkTreeIter iter; DIR *dfd; struct dirent *dp; @@ -267,9 +263,8 @@ properties_cb (GtkAction *action, #ifdef PATH_MAX gchar filename [PATH_MAX]; #else - gchar *filename; + gchar *filename; #endif - gchar *title; if (eyes_applet->prop_box.pbox) { gtk_window_set_screen ( @@ -279,88 +274,19 @@ properties_cb (GtkAction *action, return; } - pbox = gtk_dialog_new_with_buttons (_("Eyes Preferences"), NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - "gtk-close", GTK_RESPONSE_CLOSE, - "gtk-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_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_box_new (GTK_ORIENTATION_VERTICAL, 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_box_new (GTK_ORIENTATION_VERTICAL, 18); - gtk_box_pack_start (GTK_BOX (vbox), categories_vbox, TRUE, TRUE, 0); - gtk_widget_show (categories_vbox); - - category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0); - gtk_widget_show (category_vbox); - - title = g_strconcat ("", _("Themes"), "", 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_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0); - g_free (title); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 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_box_new (GTK_ORIENTATION_VERTICAL, 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_label_set_xalign (GTK_LABEL (label), 0.0); - 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); + builder = gtk_builder_new_from_resource ("/org/mate/mate-applets/eyes/themes.ui"); - 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); + eyes_applet->prop_box.pbox = GET_WIDGET ("preferences_dialog"); + tree = GET_WIDGET ("themes_treeview"); + label = GET_WIDGET ("select_theme_label"); + model = gtk_list_store_new (TOTAL_COLS, G_TYPE_STRING, G_TYPE_STRING); + gtk_tree_view_set_model (GTK_TREE_VIEW (tree), GTK_TREE_MODEL (model)); 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 ( ! g_settings_is_writable (eyes_applet->settings, "theme-path")) { gtk_widget_set_sensitive (tree, FALSE); gtk_widget_set_sensitive (label, FALSE); @@ -408,14 +334,18 @@ properties_cb (GtkAction *action, #ifndef PATH_MAX g_free (filename); #endif + g_object_unref (model); - gtk_box_pack_start (GTK_BOX (control_vbox), scrolled, TRUE, TRUE, 0); + /* signals */ + gtk_builder_add_callback_symbols (builder, + "on_preferences_dialog_response", G_CALLBACK (presponse_cb), + "on_themes_treeselection_changed", G_CALLBACK (theme_selected_cb), + NULL); + gtk_builder_connect_signals (builder, eyes_applet); - gtk_widget_show_all (pbox); + g_object_unref (builder); - eyes_applet->prop_box.pbox = pbox; + gtk_widget_show_all (eyes_applet->prop_box.pbox); return; } - - diff --git a/geyes/themes.ui b/geyes/themes.ui new file mode 100644 index 00000000..70409f3b --- /dev/null +++ b/geyes/themes.ui @@ -0,0 +1,171 @@ + + + + + + True + False + help-browser + + + True + False + window-close + + + False + 12 + Eyes Preferences + 300 + 200 + mate-eyes-applet + dialog + + + + False + vertical + 2 + + + False + end + + + _Help + True + True + True + image1 + True + True + + + True + True + 0 + + + + + _Close + True + True + True + True + True + image2 + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + True + 0 + none + + + True + False + 12 + + + True + False + 6 + 6 + True + vertical + 6 + + + True + False + start + _Select a theme: + True + themes_treeview + + + False + True + 0 + + + + + True + True + True + True + never + in + + + True + True + True + True + False + False + + + + + + + + + + False + True + 1 + + + + + + + + + True + False + Themes + + + + + + + + False + True + 1 + + + + + + button1 + button2 + + + + + + -- cgit v1.2.1