[Xfce4-commits] <xfce4-taskmanager:master> Implement option "Show application icons"
Mike Massonnet
noreply at xfce.org
Mon Oct 4 19:56:01 CEST 2010
Updating branch refs/heads/master
to 36ccc36bb7f50f3a914364bf09e19662b00a7d91 (commit)
from 6cdb08c947d7b4fde370559d64c8e55c4b4b2c8d (commit)
commit 36ccc36bb7f50f3a914364bf09e19662b00a7d91
Author: Mike Massonnet <mmassonnet at xfce.org>
Date: Mon Oct 4 19:52:44 2010 +0200
Implement option "Show application icons"
src/process-tree-view.c | 51 +++++++++++++++++++++++++++++++++-------------
src/settings-dialog.c | 1 +
src/settings-dialog.ui | 20 ++++++++++++++---
src/settings.c | 3 ++
4 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/src/process-tree-view.c b/src/process-tree-view.c
index d749d90..3f50c06 100644
--- a/src/process-tree-view.c
+++ b/src/process-tree-view.c
@@ -60,6 +60,8 @@ static void xtm_process_tree_view_finalize (GObject *object);
static gboolean treeview_clicked (XtmProcessTreeView *treeview, GdkEventButton *event);
static gboolean treeview_key_pressed (XtmProcessTreeView *treeview, GdkEventKey *event);
+static void column_task_pack_cells (XtmProcessTreeView *treeview, GtkTreeViewColumn *column);
+static void cb_show_application_icons_toggled (XtmProcessTreeView *treeview);
static void columns_changed (XtmProcessTreeView *treeview);
static void read_columns_positions (XtmProcessTreeView *treeview);
static void save_columns_positions (XtmProcessTreeView *treeview);
@@ -81,11 +83,7 @@ xtm_process_tree_view_class_init (XtmProcessTreeViewClass *klass)
static void
xtm_process_tree_view_init (XtmProcessTreeView *treeview)
{
-#ifdef HAVE_WNCK
- GtkCellRenderer *cell_text, *cell_right_aligned, *cell_icon, *cell_cmdline;
-#else
- GtkCellRenderer *cell_text, *cell_right_aligned, *cell_cmdline;
-#endif
+ GtkCellRenderer *cell_text, *cell_right_aligned;
GtkTreeViewColumn *column;
gboolean visible;
@@ -119,9 +117,6 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
cell_right_aligned = gtk_cell_renderer_text_new ();
g_object_set (cell_right_aligned, "xalign", 1.0, NULL);
- cell_cmdline = gtk_cell_renderer_text_new ();
- g_object_set (cell_cmdline, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-
/* Retrieve initial tree view columns positions */
read_columns_positions (treeview);
@@ -129,13 +124,7 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
#define COLUMN_PROPERTIES "expand", TRUE, "clickable", TRUE, "reorderable", TRUE, "resizable", TRUE, "visible", TRUE
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column), _("Task"));
-#ifdef HAVE_WNCK
- cell_icon = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), cell_icon, FALSE);
- gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), cell_icon, "pixbuf", XTM_PTV_COLUMN_ICON, "cell-background", XTM_PTV_COLUMN_BACKGROUND, NULL);
-#endif
- gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), cell_cmdline, TRUE);
- gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), cell_cmdline, "text", XTM_PTV_COLUMN_COMMAND, "cell-background", XTM_PTV_COLUMN_BACKGROUND, "foreground", XTM_PTV_COLUMN_FOREGROUND, NULL);
+ column_task_pack_cells (treeview, column);
g_object_set (column, COLUMN_PROPERTIES, NULL);
g_object_set_data (G_OBJECT (column), "sort-column-id", GINT_TO_POINTER (XTM_PTV_COLUMN_COMMAND));
g_object_set_data (G_OBJECT (column), "column-id", GINT_TO_POINTER (COLUMN_COMMAND));
@@ -227,6 +216,7 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
g_signal_connect (treeview, "columns-changed", G_CALLBACK (columns_changed), NULL);
g_signal_connect (treeview, "button-press-event", G_CALLBACK (treeview_clicked), NULL);
g_signal_connect (treeview, "key-press-event", G_CALLBACK (treeview_key_pressed), NULL);
+ g_signal_connect_swapped (treeview->settings, "notify::show-application-icons", G_CALLBACK (cb_show_application_icons_toggled), treeview);
}
static void
@@ -259,6 +249,37 @@ xtm_process_tree_view_finalize (GObject *object)
*/
static void
+column_task_pack_cells (XtmProcessTreeView *treeview, GtkTreeViewColumn *column)
+{
+ GtkCellRenderer *cell_cmdline, *cell_icon;
+ gboolean show_application_icons;
+
+ g_object_get (treeview->settings, "show-application-icons", &show_application_icons, NULL);
+ if (show_application_icons)
+ {
+#ifdef HAVE_WNCK
+ cell_icon = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), cell_icon, FALSE);
+ gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), cell_icon, "pixbuf", XTM_PTV_COLUMN_ICON, "cell-background", XTM_PTV_COLUMN_BACKGROUND, NULL);
+#endif
+ }
+
+ cell_cmdline = gtk_cell_renderer_text_new ();
+ g_object_set (cell_cmdline, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), cell_cmdline, TRUE);
+ gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), cell_cmdline, "text", XTM_PTV_COLUMN_COMMAND, "cell-background", XTM_PTV_COLUMN_BACKGROUND, "foreground", XTM_PTV_COLUMN_FOREGROUND, NULL);
+}
+
+static void
+cb_show_application_icons_toggled (XtmProcessTreeView *treeview)
+{
+ GtkTreeViewColumn *column;
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), treeview->columns_positions[COLUMN_COMMAND]);
+ gtk_tree_view_column_clear (column);
+ column_task_pack_cells (treeview, column);
+}
+
+static void
columns_changed (XtmProcessTreeView *treeview)
{
GList *columns, *l;
diff --git a/src/settings-dialog.c b/src/settings-dialog.c
index 419af6d..ca6baf7 100644
--- a/src/settings-dialog.c
+++ b/src/settings-dialog.c
@@ -98,6 +98,7 @@ xtm_settings_dialog_init (XtmSettingsDialog *dialog)
dialog->window = GTK_WIDGET (gtk_builder_get_object (builder, "settings-dialog"));
+ builder_bind_toggle_button (builder, "button-show-application-icons", dialog->settings, "show-application-icons");
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");
diff --git a/src/settings-dialog.ui b/src/settings-dialog.ui
index f4e1211..4c84edc 100644
--- a/src/settings-dialog.ui
+++ b/src/settings-dialog.ui
@@ -46,6 +46,18 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
+ <object class="GtkCheckButton" id="button-show-application-icons">
+ <property name="label" translatable="yes">Show application icons</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="position">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="button-full-command-line">
<property name="label" translatable="yes">Show full command lines</property>
<property name="visible">True</property>
@@ -56,7 +68,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -70,7 +82,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -85,7 +97,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -110,7 +122,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
diff --git a/src/settings.c b/src/settings.c
index 5224442..3b9d11b 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -37,6 +37,7 @@ enum
PROP_FULL_COMMAND_LINE,
PROP_SHOW_STATUS_ICON,
PROP_MONITOR_PAINT_BOX,
+ PROP_SHOW_APPLICATION_ICONS,
PROP_TOOLBAR_STYLE,
PROP_PROMPT_TERMINATE_TASK,
PROP_REFRESH_RATE,
@@ -94,6 +95,8 @@ xtm_settings_class_init (XtmSettingsClass *klass)
g_param_spec_boolean ("show-status-icon", "ShowStatusIcon", "Show/hide the status icon", TRUE, 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_SHOW_APPLICATION_ICONS,
+ g_param_spec_boolean ("show-application-icons", "ShowApplicationIcons", "Show application icons", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (class, PROP_TOOLBAR_STYLE,
g_param_spec_enum ("toolbar-style", "ToolbarStyle", "Toolbar style", XTM_TYPE_TOOLBAR_STYLE, XTM_TOOLBAR_STYLE_DEFAULT, G_PARAM_READWRITE));
g_object_class_install_property (class, PROP_PROMPT_TERMINATE_TASK,
More information about the Xfce4-commits
mailing list