Initial settings dialog shown on settings-tool-button click

Not yet finished, it includes control for some check buttons currently.
This commit is contained in:
Mike Massonnet
2010-08-08 14:12:49 +02:00
parent 4fc28e6b8b
commit f546aa846b
6 changed files with 594 additions and 8 deletions

View File

@@ -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

148
src/settings-dialog.c Normal file
View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 2010 Mike Massonnet, <mmassonnet@xfce.org>
*
* 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 <config.h>
#endif
#include <glib-object.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#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;
/*<private>*/
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));
}

33
src/settings-dialog.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2010 Mike Massonnet, <mmassonnet@xfce.org>
*
* 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 <config.h>
#endif
#include <glib-object.h>
#include <gtk/gtk.h>
#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 */

391
src/settings-dialog.ui Normal file
View File

@@ -0,0 +1,391 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="settings-dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Settings for Task Manager</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">gtk-preferences</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">False</property>
<child>
<object class="GtkHBox" id="hbox">
<property name="visible">True</property>
<property name="border_width">6</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="frame-interface">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment-interface">
<property name="visible">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox-interface">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="button-full-command-line">
<property name="label" translatable="yes">Show full command lines</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="button-more-precision">
<property name="label" translatable="yes">Show values with more precision</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="button-monitor-paint-box">
<property name="label" translatable="yes">Draw borders around monitors</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.49000000953674316</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox-toolbar-style">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label-toolbar-style">
<property name="visible">True</property>
<property name="label" translatable="yes">Toolbar style:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox-toolbar-style">
<property name="visible">True</property>
<property name="model">liststore-columns</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label-interface">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Interface style&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame-misc">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment-misc">
<property name="visible">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox-misc">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="button-quiet-signal">
<property name="label" translatable="yes">Don't ask for terminating tasks</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="button-show-status-icon">
<property name="label" translatable="yes">Hide into the notification area</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label-misc">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Miscellaneous&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="frame-information">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment-information">
<property name="visible">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox-information">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox-refresh-rate">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label-refresh-rate">
<property name="visible">True</property>
<property name="label" translatable="yes">Refresh rate:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox-refresh-rate">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</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="GtkLabel" id="label-columns">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Columns:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment-columns">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow-columns">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="treeview-columns">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label-information">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Information&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="label" translatable="yes">Settings</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button-close">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button-close</action-widget>
</action-widgets>
</object>
</interface>

View File

@@ -16,6 +16,7 @@
#include <gtk/gtk.h>
#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"));

View File

@@ -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,