Implement option "Show application icons"

This commit is contained in:
Mike Massonnet
2010-10-04 19:52:44 +02:00
parent 6cdb08c947
commit 36ccc36bb7
4 changed files with 56 additions and 19 deletions

View File

@@ -60,6 +60,8 @@ static void xtm_process_tree_view_finalize (GObject *object);
static gboolean treeview_clicked (XtmProcessTreeView *treeview, GdkEventButton *event); static gboolean treeview_clicked (XtmProcessTreeView *treeview, GdkEventButton *event);
static gboolean treeview_key_pressed (XtmProcessTreeView *treeview, GdkEventKey *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 columns_changed (XtmProcessTreeView *treeview);
static void read_columns_positions (XtmProcessTreeView *treeview); static void read_columns_positions (XtmProcessTreeView *treeview);
static void save_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 static void
xtm_process_tree_view_init (XtmProcessTreeView *treeview) xtm_process_tree_view_init (XtmProcessTreeView *treeview)
{ {
#ifdef HAVE_WNCK GtkCellRenderer *cell_text, *cell_right_aligned;
GtkCellRenderer *cell_text, *cell_right_aligned, *cell_icon, *cell_cmdline;
#else
GtkCellRenderer *cell_text, *cell_right_aligned, *cell_cmdline;
#endif
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
gboolean visible; gboolean visible;
@@ -119,9 +117,6 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
cell_right_aligned = gtk_cell_renderer_text_new (); cell_right_aligned = gtk_cell_renderer_text_new ();
g_object_set (cell_right_aligned, "xalign", 1.0, NULL); 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 */ /* Retrieve initial tree view columns positions */
read_columns_positions (treeview); 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 #define COLUMN_PROPERTIES "expand", TRUE, "clickable", TRUE, "reorderable", TRUE, "resizable", TRUE, "visible", TRUE
column = gtk_tree_view_column_new (); column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column), _("Task")); gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column), _("Task"));
#ifdef HAVE_WNCK column_task_pack_cells (treeview, column);
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);
g_object_set (column, COLUMN_PROPERTIES, NULL); 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), "sort-column-id", GINT_TO_POINTER (XTM_PTV_COLUMN_COMMAND));
g_object_set_data (G_OBJECT (column), "column-id", GINT_TO_POINTER (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, "columns-changed", G_CALLBACK (columns_changed), NULL);
g_signal_connect (treeview, "button-press-event", G_CALLBACK (treeview_clicked), 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 (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 static void
@@ -258,6 +248,37 @@ xtm_process_tree_view_finalize (GObject *object)
* Helper functions * Helper functions
*/ */
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 static void
columns_changed (XtmProcessTreeView *treeview) columns_changed (XtmProcessTreeView *treeview)
{ {

View File

@@ -98,6 +98,7 @@ xtm_settings_dialog_init (XtmSettingsDialog *dialog)
dialog->window = GTK_WIDGET (gtk_builder_get_object (builder, "settings-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-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-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-monitor-paint-box", dialog->settings, "monitor-paint-box");

View File

@@ -45,6 +45,18 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">6</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> <child>
<object class="GtkCheckButton" id="button-full-command-line"> <object class="GtkCheckButton" id="button-full-command-line">
<property name="label" translatable="yes">Show full command lines</property> <property name="label" translatable="yes">Show full command lines</property>
@@ -56,7 +68,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">0</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -70,7 +82,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -85,7 +97,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -110,7 +122,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">3</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@@ -37,6 +37,7 @@ enum
PROP_FULL_COMMAND_LINE, PROP_FULL_COMMAND_LINE,
PROP_SHOW_STATUS_ICON, PROP_SHOW_STATUS_ICON,
PROP_MONITOR_PAINT_BOX, PROP_MONITOR_PAINT_BOX,
PROP_SHOW_APPLICATION_ICONS,
PROP_TOOLBAR_STYLE, PROP_TOOLBAR_STYLE,
PROP_PROMPT_TERMINATE_TASK, PROP_PROMPT_TERMINATE_TASK,
PROP_REFRESH_RATE, 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_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_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_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_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_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, g_object_class_install_property (class, PROP_PROMPT_TERMINATE_TASK,