From 3fec92aaceff1e9a36e5435841d3b4d5fe20cd0e Mon Sep 17 00:00:00 2001 From: rbuj Date: Wed, 27 May 2020 17:24:42 +0200 Subject: command: Add command-preferences.ui --- command/Makefile.am | 23 +++- command/command-preferences.ui | 191 ++++++++++++++++++++++++++++++++ command/command-resources.gresource.xml | 6 + command/command.c | 77 ++++--------- 4 files changed, 238 insertions(+), 59 deletions(-) create mode 100644 command/command-preferences.ui create mode 100644 command/command-resources.gresource.xml (limited to 'command') diff --git a/command/Makefile.am b/command/Makefile.am index fbb3a141..81debe28 100644 --- a/command/Makefile.am +++ b/command/Makefile.am @@ -6,10 +6,19 @@ AM_CPPFLAGS = \ APPLET_LOCATION = $(libexecdir)/command-applet libexec_PROGRAMS = command-applet + +BUILT_SOURCES = command-resources.c command-resources.h +nodist_command_applet_SOURCES = $(BUILT_SOURCES) command_applet_SOURCES = command.c ma-command.c ma-command.h command_applet_LDADD = $(MATE_APPLETS4_LIBS) command_applet_CFLAGS = $(WARN_CFLAGS) +command-resources.c: command-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/command-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name command $< + +command-resources.h: command-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/command-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name command $< + appletsdir = $(datadir)/mate-panel/applets applets_in_files = org.mate.applets.CommandApplet.mate-panel-applet.desktop.in applets_DATA = $(applets_in_files:.mate-panel-applet.desktop.in=.mate-panel-applet) @@ -38,8 +47,16 @@ gsettings_SCHEMAS = $(command_gschema_in_files:.xml.in=.xml) EXTRA_DIST = \ $(applets_in_files).in \ $(service_in_files) \ - $(command_gschema_in_files) - -CLEANFILES = $(applets_DATA) $(applets_in_files) $(service_DATA) $(gsettings_SCHEMAS) *.gschema.valid + $(command_gschema_in_files) \ + command-preferences.ui \ + command-resources.gresource.xml + +CLEANFILES = \ + $(BUILT_SOURCES) \ + $(applets_DATA) \ + $(applets_in_files) \ + $(service_DATA) \ + $(gsettings_SCHEMAS) \ + *.gschema.valid -include $(top_srcdir)/git.mk diff --git a/command/command-preferences.ui b/command/command-preferences.ui new file mode 100644 index 00000000..9a2d5435 --- /dev/null +++ b/command/command-preferences.ui @@ -0,0 +1,191 @@ + + + + + + True + False + window-close + + + 1 + 86400 + 1 + 10 + + + 1 + 100 + 1 + 10 + + + False + 12 + Command Applet Preferences + utilities-terminal + dialog + + + False + vertical + 2 + + + False + end + + + _Close + True + True + True + image1 + True + True + + + True + True + 0 + + + + + False + False + 0 + + + + + True + False + vertical + 6 + + + True + False + 6 + 12 + + + True + False + start + C_ommand: + True + command_entry + + + 0 + 0 + + + + + True + False + start + _Interval (seconds): + True + interval_spinbutton + + + 0 + 1 + + + + + True + False + start + Maximum _width (chars): + True + width_spinbutton + + + 0 + 2 + + + + + True + True + True + + + + 1 + 0 + + + + + True + True + True + interval_adjustment + + + + 1 + 1 + + + + + True + True + True + width_adjustment + + + + 1 + 2 + + + + + False + True + 0 + + + + + _Show icon + True + True + False + start + True + True + + + False + True + 1 + + + + + False + True + 1 + + + + + + button1 + + + + + + diff --git a/command/command-resources.gresource.xml b/command/command-resources.gresource.xml new file mode 100644 index 00000000..72f8ac4c --- /dev/null +++ b/command/command-resources.gresource.xml @@ -0,0 +1,6 @@ + + + + command-preferences.ui + + diff --git a/command/command.c b/command/command.c index 20c020ae..107f97d3 100644 --- a/command/command.c +++ b/command/command.c @@ -50,6 +50,9 @@ #define GK_COMMAND_OUTPUT "Output" #define GK_COMMAND_ICON "Icon" +#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x)))) +#define GET_DIALOG(x) (GTK_DIALOG (gtk_builder_get_object (builder, (x)))) + typedef struct { MatePanelApplet *applet; @@ -184,65 +187,27 @@ static void command_settings_callback (GtkAction *action, CommandApplet *command_applet) { GtkDialog *dialog; - GtkGrid *grid; - GtkWidget *widget; - GtkWidget *command; - GtkWidget *interval; - GtkWidget *width; - GtkWidget *showicon; - - dialog = GTK_DIALOG (gtk_dialog_new_with_buttons(_("Command Applet Preferences"), - NULL, - GTK_DIALOG_MODAL, - "gtk-close", - GTK_RESPONSE_CLOSE, - NULL)); - grid = GTK_GRID (gtk_grid_new ()); - gtk_grid_set_row_spacing (grid, 12); - gtk_grid_set_column_spacing (grid, 12); - - gtk_window_set_default_size (GTK_WINDOW (dialog), 350, 150); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 10); - - widget = gtk_label_new (_("Command:")); - gtk_label_set_xalign (GTK_LABEL (widget), 1.0); - gtk_label_set_yalign (GTK_LABEL (widget), 0.5); - gtk_grid_attach (grid, widget, 1, 0, 1, 1); - - command = gtk_entry_new (); - gtk_grid_attach (grid, command, 2, 0, 1, 1); - - widget = gtk_label_new (_("Interval (seconds):")); - gtk_label_set_xalign (GTK_LABEL (widget), 1.0); - gtk_label_set_yalign (GTK_LABEL (widget), 0.5); - gtk_grid_attach (grid, widget, 1, 1, 1, 1); - - interval = gtk_spin_button_new_with_range (1.0, 86400.0, 1.0); - gtk_grid_attach (grid, interval, 2, 1, 1, 1); - - widget = gtk_label_new (_("Maximum width (chars):")); - gtk_label_set_xalign (GTK_LABEL (widget), 1.0); - gtk_label_set_yalign (GTK_LABEL (widget), 0.5); - gtk_grid_attach (grid, widget, 1, 2, 1, 1); - - width = gtk_spin_button_new_with_range(1.0, 100.0, 1.0); - gtk_grid_attach (grid, width, 2, 2, 1, 1); - - showicon = gtk_check_button_new_with_label (_("Show icon")); - gtk_grid_attach (grid, showicon, 2, 3, 1, 1); - - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), GTK_WIDGET (grid), TRUE, TRUE, 0); + GtkBuilder *builder; + + builder = gtk_builder_new_from_resource ("/org/mate/mate-applets/command/command-preferences.ui"); + + dialog = GET_DIALOG ("preferences_dialog"); + + g_settings_bind (command_applet->settings, COMMAND_KEY, GET_WIDGET ("command_entry"), "text", G_SETTINGS_BIND_GET_NO_CHANGES); + g_settings_bind (command_applet->settings, INTERVAL_KEY, GET_WIDGET ("interval_spinbutton"), "value", G_SETTINGS_BIND_GET_NO_CHANGES); + g_settings_bind (command_applet->settings, WIDTH_KEY, GET_WIDGET ("width_spinbutton"), "value", G_SETTINGS_BIND_GET_NO_CHANGES); + g_settings_bind (command_applet->settings, SHOW_ICON_KEY, GET_WIDGET ("show_icon_check"), "active", G_SETTINGS_BIND_DEFAULT); + /* signals */ + gtk_builder_add_callback_symbols (builder, + "on_command_entry_focus_out_event", G_CALLBACK (command_text_changed), + "on_interval_spinbutton_value_changed", G_CALLBACK (interval_value_changed), + "on_width_spinbutton_value_changed", G_CALLBACK (width_value_changed), + NULL); + gtk_builder_connect_signals (builder, command_applet); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); - g_signal_connect(command, "focus-out-event", G_CALLBACK (command_text_changed), command_applet); - g_signal_connect(interval, "value-changed", G_CALLBACK (interval_value_changed), command_applet); - g_signal_connect(width, "value-changed", G_CALLBACK (width_value_changed), command_applet); - /* use g_settings_bind to manage settings */ - g_settings_bind (command_applet->settings, COMMAND_KEY, command, "text", G_SETTINGS_BIND_GET_NO_CHANGES); - g_settings_bind (command_applet->settings, INTERVAL_KEY, interval, "value", G_SETTINGS_BIND_GET_NO_CHANGES); - g_settings_bind (command_applet->settings, WIDTH_KEY, width, "value", G_SETTINGS_BIND_GET_NO_CHANGES); - g_settings_bind (command_applet->settings, SHOW_ICON_KEY, showicon, "active", G_SETTINGS_BIND_DEFAULT); + g_object_unref (builder); gtk_widget_show_all (GTK_WIDGET (dialog)); } -- cgit v1.2.1