diff options
-rw-r--r-- | command/Makefile.am | 23 | ||||
-rw-r--r-- | command/command-preferences.ui | 191 | ||||
-rw-r--r-- | command/command-resources.gresource.xml | 6 | ||||
-rw-r--r-- | command/command.c | 77 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
5 files changed, 239 insertions, 59 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.36.0 --> +<interface> + <requires lib="gtk+" version="3.22"/> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">window-close</property> + </object> + <object class="GtkAdjustment" id="interval_adjustment"> + <property name="lower">1</property> + <property name="upper">86400</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="width_adjustment"> + <property name="lower">1</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkDialog" id="preferences_dialog"> + <property name="can_focus">False</property> + <property name="border_width">12</property> + <property name="title" translatable="yes">Command Applet Preferences</property> + <property name="icon_name">utilities-terminal</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button1"> + <property name="label" translatable="yes">_Close</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image1</property> + <property name="use_underline">True</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">C_ommand:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">command_entry</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">_Interval (seconds):</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">interval_spinbutton</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Maximum _width (chars):</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">width_spinbutton</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="command_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <signal name="focus-out-event" handler="on_command_entry_focus_out_event" swapped="no"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="interval_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="adjustment">interval_adjustment</property> + <signal name="value-changed" handler="on_interval_spinbutton_value_changed" swapped="no"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="width_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="adjustment">width_adjustment</property> + <signal name="value-changed" handler="on_width_spinbutton_value_changed" swapped="no"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="show_icon_check"> + <property name="label" translatable="yes">_Show icon</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="halign">start</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-7">button1</action-widget> + </action-widgets> + <child type="titlebar"> + <placeholder/> + </child> + </object> +</interface> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/mate/mate-applets/command"> + <file compressed="true">command-preferences.ui</file> + </gresource> +</gresources> 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)); } diff --git a/po/POTFILES.in b/po/POTFILES.in index d9b471d3..0195c0f3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -14,6 +14,7 @@ charpick/org.mate.applets.CharpickerApplet.mate-panel-applet.desktop.in.in charpick/org.mate.panel.applet.charpick.gschema.xml.in charpick/properties.c command/command.c +command/command-preferences.ui command/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in command/org.mate.panel.applet.command.gschema.xml.in cpufreq/cpufreq-preferences.ui |