diff --git a/src/Makefile.am b/src/Makefile.am index 2d16b7a..05ecebe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,8 +31,10 @@ xfce4_taskmanager_SOURCES = \ process-statusbar.c process-statusbar.h \ exec-tool-button.c exec-tool-button.h \ settings-tool-button.c settings-tool-button.h \ - task-manager.c task-manager.h \ + settings-dialog_ui.h \ + settings-dialog.c settings-dialog.h \ settings.c settings.h \ + task-manager.c task-manager.h \ $(NULL) if HAVE_WNCK @@ -56,10 +58,12 @@ xfce4_taskmanager_SOURCES += task-manager-skel.c endif if MAINTAINER_MODE -BUILT_SOURCES = process-window_ui.h +BUILT_SOURCES = process-window_ui.h settings-dialog_ui.h process-window_ui.h: process-window.ui $(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=process_window_ui $< >$@ +settings-dialog_ui.h: settings-dialog.ui + $(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=settings_dialog_ui $< >$@ endif -EXTRA_DIST = process-window.ui +EXTRA_DIST = process-window.ui settings-dialog.ui diff --git a/src/settings-dialog.c b/src/settings-dialog.c new file mode 100644 index 0000000..8484b22 --- /dev/null +++ b/src/settings-dialog.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2010 Mike Massonnet, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "settings.h" +#include "settings-dialog.h" +#include "settings-dialog_ui.h" + + + +typedef struct _XtmSettingsDialogClass XtmSettingsDialogClass; +struct _XtmSettingsDialogClass +{ + GtkWidgetClass parent_class; +}; +struct _XtmSettingsDialog +{ + GtkWidget parent; + /**/ + GtkWidget * window; + XtmSettings * settings; +}; +G_DEFINE_TYPE (XtmSettingsDialog, xtm_settings_dialog, GTK_TYPE_WIDGET) + +static void xtm_settings_dialog_finalize (GObject *object); +static void xtm_settings_dialog_show (GtkWidget *widget); +static void xtm_settings_dialog_hide (GtkWidget *widget); + + + +static void +xtm_settings_dialog_class_init (XtmSettingsDialogClass *klass) +{ + GObjectClass *class; + GtkWidgetClass *widget_class; + xtm_settings_dialog_parent_class = g_type_class_peek_parent (klass); + class = G_OBJECT_CLASS (klass); + class->finalize = xtm_settings_dialog_finalize; + widget_class = GTK_WIDGET_CLASS (klass); + widget_class->show = xtm_settings_dialog_show; + widget_class->hide = xtm_settings_dialog_hide; +} + +static void +button_toggled (GtkToggleButton *button, XtmSettings *settings) +{ + gboolean active = gtk_toggle_button_get_active (button); + gchar *setting_name = g_object_get_data (G_OBJECT (button), "setting-name"); + g_object_set (settings, setting_name, active, NULL); +} + +static void +builder_bind_toggle_button (GtkBuilder *builder, gchar *widget_name, XtmSettings *settings, gchar *setting_name) +{ + gboolean active; + GtkWidget *button; + + g_object_get (settings, setting_name, &active, NULL); + + button = GTK_WIDGET (gtk_builder_get_object (builder, widget_name)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active); + g_object_set_data (G_OBJECT (button), "setting-name", setting_name); + g_signal_connect (button, "toggled", G_CALLBACK (button_toggled), settings); +} + +static void +xtm_settings_dialog_init (XtmSettingsDialog *dialog) +{ + GtkBuilder *builder; + + g_object_ref_sink (dialog); + + dialog->settings = xtm_settings_get_default (); + + builder = gtk_builder_new (); + gtk_builder_add_from_string (builder, settings_dialog_ui, settings_dialog_ui_length, NULL); + + dialog->window = GTK_WIDGET (gtk_builder_get_object (builder, "settings-dialog")); + + builder_bind_toggle_button (builder, "button-full-command-line", dialog->settings, "full-command-line"); + builder_bind_toggle_button (builder, "button-more-precision", dialog->settings, "more-precision"); + builder_bind_toggle_button (builder, "button-monitor-paint-box", dialog->settings, "monitor-paint-box"); + builder_bind_toggle_button (builder, "button-quiet-signal", dialog->settings, "send-quiet-signals"); + builder_bind_toggle_button (builder, "button-show-status-icon", dialog->settings, "show-status-icon"); + + g_object_unref (builder); +} + +static void +xtm_settings_dialog_finalize (GObject *object) +{ + XtmSettingsDialog *dialog = XTM_SETTINGS_DIALOG (object); + gtk_widget_destroy (dialog->window); + g_object_unref (dialog->settings); +} + + + +GtkWidget * +xtm_settings_dialog_new (GtkWindow *parent_window) +{ + GtkWidget *dialog = g_object_new (XTM_TYPE_SETTINGS_DIALOG, NULL); + gtk_window_set_transient_for (GTK_WINDOW (XTM_SETTINGS_DIALOG (dialog)->window), parent_window); + return dialog; +} + +static void +xtm_settings_dialog_show (GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_WIDGET (XTM_SETTINGS_DIALOG (widget)->window)); + gtk_widget_show (XTM_SETTINGS_DIALOG (widget)->window); + gtk_window_present (GTK_WINDOW (XTM_SETTINGS_DIALOG (widget)->window)); + GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE); +} + +static void +xtm_settings_dialog_hide (GtkWidget *widget) +{ + gint winx, winy; + g_return_if_fail (GTK_IS_WIDGET (widget)); + if (!GTK_IS_WIDGET (XTM_SETTINGS_DIALOG (widget)->window)) + return; + gtk_window_get_position (GTK_WINDOW (XTM_SETTINGS_DIALOG (widget)->window), &winx, &winy); + gtk_widget_hide (XTM_SETTINGS_DIALOG (widget)->window); + gtk_window_move (GTK_WINDOW (XTM_SETTINGS_DIALOG (widget)->window), winx, winy); + GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE); +} + +void +xtm_settings_dialog_run (XtmSettingsDialog *dialog) +{ + gtk_dialog_run (GTK_DIALOG (dialog->window)); +} + diff --git a/src/settings-dialog.h b/src/settings-dialog.h new file mode 100644 index 0000000..5074dac --- /dev/null +++ b/src/settings-dialog.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010 Mike Massonnet, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef SETTINGS_DIALOG_H +#define SETTINGS_DIALOG_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#define XTM_TYPE_SETTINGS_DIALOG (xtm_settings_dialog_get_type ()) +#define XTM_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XTM_TYPE_SETTINGS_DIALOG, XtmSettingsDialog)) +#define XTM_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XTM_TYPE_SETTINGS_DIALOG, XtmSettingsDialogClass)) +#define XTM_IS_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XTM_TYPE_SETTINGS_DIALOG)) +#define XTM_IS_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XTM_TYPE_SETTINGS_DIALOG)) +#define XTM_SETTINGS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XTM_TYPE_SETTINGS_DIALOG, XtmSettingsDialogClass)) + +typedef struct _XtmSettingsDialog XtmSettingsDialog; + +GType xtm_settings_dialog_get_type (void); +GtkWidget * xtm_settings_dialog_new (GtkWindow *parent_window); +void xtm_settings_dialog_run (XtmSettingsDialog *dialog); + +#endif /* !SETTINGS_DIALOG_H */ diff --git a/src/settings-dialog.ui b/src/settings-dialog.ui new file mode 100644 index 0000000..e8b025f --- /dev/null +++ b/src/settings-dialog.ui @@ -0,0 +1,391 @@ + + + + + + 5 + Settings for Task Manager + False + True + True + gtk-preferences + normal + False + + + True + vertical + 2 + + + True + True + False + + + True + 6 + + + True + vertical + 6 + + + True + 0 + none + + + True + 6 + 12 + + + True + vertical + 6 + + + Show full command lines + True + True + False + True + + + False + False + 0 + + + + + Show values with more precision + True + True + False + True + + + False + False + 1 + + + + + Draw borders around monitors + True + False + True + False + 0.49000000953674316 + True + + + False + False + 2 + + + + + True + False + 6 + + + True + Toolbar style: + + + False + False + 0 + + + + + True + liststore-columns + + + False + False + 1 + + + + + False + False + 3 + + + + + + + + + True + <b>Interface style</b> + True + + + + + False + False + 0 + + + + + True + 0 + none + + + True + 6 + 12 + + + True + vertical + 6 + + + Don't ask for terminating tasks + True + False + True + False + True + + + False + False + 0 + + + + + Hide into the notification area + True + True + False + True + + + False + False + 1 + + + + + + + + + True + <b>Miscellaneous</b> + True + + + + + False + False + 1 + + + + + 0 + + + + + True + vertical + + + False + 6 + 1 + + + + + True + vertical + 6 + + + True + False + 0 + none + + + True + 6 + 12 + + + True + vertical + 6 + + + True + 6 + + + True + Refresh rate: + + + False + False + 0 + + + + + True + + + False + False + 1 + + + + + False + False + 0 + + + + + True + 0 + Columns: + + + False + False + 1 + + + + + True + 12 + + + True + True + never + never + in + + + True + True + + + + + + + 2 + + + + + + + + + True + <b>Information</b> + True + + + + + 0 + + + + + 2 + + + + + + + True + Settings + + + False + + + + + + + + + + + + + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + button-close + + + diff --git a/src/settings-tool-button.c b/src/settings-tool-button.c index 7842167..44bbe2a 100644 --- a/src/settings-tool-button.c +++ b/src/settings-tool-button.c @@ -16,6 +16,7 @@ #include #include "settings-tool-button.h" +#include "settings-dialog.h" #include "settings.h" @@ -61,9 +62,12 @@ xtm_settings_tool_button_init (XtmSettingsToolButton *button) static void -show_settings_dialog () +show_settings_dialog (XtmSettingsToolButton *button) { - g_debug ("show settings dialog"); + GtkWidget *parent_window = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW); + GtkWidget *dialog = xtm_settings_dialog_new (GTK_WINDOW (parent_window)); + xtm_settings_dialog_run (XTM_SETTINGS_DIALOG (dialog)); + g_object_unref (dialog); } static void @@ -158,9 +162,6 @@ construct_menu () GtkWidget *mi; menu_append_item (GTK_MENU (menu), _("Show all processes"), "show-all-processes", settings); - //menu_append_item (GTK_MENU (menu), _("More precision"), "more-precision", settings); - //menu_append_item (GTK_MENU (menu), _("Full command line"), "full-command-line", settings); - //menu_append_item (GTK_MENU (menu), _("Show status icon"), "show-status-icon", settings); refresh_rate_menu = build_refresh_rate_menu (settings); mi = gtk_menu_item_new_with_label (_("Refresh rate")); diff --git a/src/settings.c b/src/settings.c index 6550f61..e9c9f9a 100644 --- a/src/settings.c +++ b/src/settings.c @@ -35,6 +35,9 @@ enum PROP_MORE_PRECISION, PROP_FULL_COMMAND_LINE, PROP_SHOW_STATUS_ICON, + PROP_SEND_QUIET_SIGNALS, + PROP_MONITOR_PAINT_BOX, + PROP_TOOLBAR_STYLE, PROP_REFRESH_RATE, PROP_COLUMNS_POSITIONS, PROP_COLUMN_UID, @@ -88,6 +91,12 @@ xtm_settings_class_init (XtmSettingsClass *klass) g_param_spec_boolean ("full-command-line", "FullCommandLine", "Full command line", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_SHOW_STATUS_ICON, g_param_spec_boolean ("show-status-icon", "ShowStatusIcon", "Show/hide the status icon", TRUE, G_PARAM_READWRITE)); + g_object_class_install_property (class, PROP_SEND_QUIET_SIGNALS, + g_param_spec_boolean ("send-quiet-signals", "SendQuietSignals", "Send quiet signals", FALSE, G_PARAM_READWRITE)); + g_object_class_install_property (class, PROP_MONITOR_PAINT_BOX, + g_param_spec_boolean ("monitor-paint-box", "MonitorPaintBox", "Paint box around monitor", TRUE, G_PARAM_READWRITE)); + //g_object_class_install_property (class, PROP_TOOLBAR_STYLE, + // g_param_spec_... ("toolbar-style", "ToolbarStyle", "Toolbar style", ...)); g_object_class_install_property (class, PROP_REFRESH_RATE, g_param_spec_uint ("refresh-rate", "RefreshRate", "Refresh rate in milliseconds", 0, G_MAXUINT, 750, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_COLUMNS_POSITIONS,