settings: Replace toolbar with regular GtkBox
This commit is contained in:
committed by
Simon Steinbeiß
parent
265b1c2f5b
commit
5d03025219
@@ -32,7 +32,6 @@ xfce4_taskmanager_SOURCES = \
|
||||
process-tree-model.c process-tree-model.h \
|
||||
process-tree-view.c process-tree-view.h \
|
||||
process-statusbar.c process-statusbar.h \
|
||||
settings-tool-button.c settings-tool-button.h \
|
||||
settings-dialog_ui.h \
|
||||
settings-dialog.c settings-dialog.h \
|
||||
settings.c settings.h \
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "process-monitor.h"
|
||||
#include "process-tree-view.h"
|
||||
#include "process-statusbar.h"
|
||||
#include "settings-tool-button.h"
|
||||
#include "settings-dialog.h"
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ struct _XtmProcessWindow
|
||||
/*<private>*/
|
||||
GtkBuilder * builder;
|
||||
GtkWidget * window;
|
||||
GtkWidget * toolbar;
|
||||
GtkWidget * filter_entry;
|
||||
GtkWidget * cpu_monitor;
|
||||
GtkWidget * mem_monitor;
|
||||
@@ -208,6 +207,12 @@ xtm_process_window_class_init (XtmProcessWindowClass *klass)
|
||||
widget_class->hide = xtm_process_window_hide;
|
||||
}
|
||||
|
||||
static void
|
||||
show_settings_dialog (GtkButton *button, GtkWidget *parent)
|
||||
{
|
||||
xtm_settings_dialog_run (parent);
|
||||
}
|
||||
|
||||
static void
|
||||
xtm_show_legend (XtmProcessWindow *window)
|
||||
{
|
||||
@@ -224,7 +229,6 @@ xtm_process_window_init (XtmProcessWindow *window)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *icon;
|
||||
GtkToolItem *xwininfo;
|
||||
gint width, height;
|
||||
gboolean show_legend;
|
||||
|
||||
@@ -242,20 +246,16 @@ xtm_process_window_init (XtmProcessWindow *window)
|
||||
g_signal_connect_swapped(window->window, "configure-event",
|
||||
G_CALLBACK(xtm_process_window_configure_event), window);
|
||||
|
||||
window->toolbar = GTK_WIDGET (gtk_builder_get_object (window->builder, "process-toolbar"));
|
||||
|
||||
window->settings_button = xtm_settings_tool_button_new ();
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (window->toolbar), GTK_TOOL_ITEM (window->settings_button), 0);
|
||||
g_signal_connect_swapped (window->settings, "notify::show-legend", G_CALLBACK (xtm_show_legend), window);
|
||||
g_object_notify (G_OBJECT (window->settings), "show-legend");
|
||||
|
||||
icon = gtk_image_new_from_icon_name ("xc_crosshair", GTK_ICON_SIZE_LARGE_TOOLBAR);
|
||||
xwininfo = gtk_tool_button_new (icon, _("Identify Window"));
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (xwininfo), _("Identify an open window by clicking on it."));
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (window->toolbar), GTK_TOOL_ITEM (xwininfo), 1);
|
||||
g_signal_connect (G_OBJECT (xwininfo), "clicked",
|
||||
button = GTK_WIDGET (gtk_builder_get_object (window->builder, "button-settings"));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (show_settings_dialog), GTK_WIDGET (window->window));
|
||||
|
||||
button = GTK_WIDGET (gtk_builder_get_object (window->builder, "button-identify"));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (xwininfo_clicked_cb), window);
|
||||
gtk_widget_show_all (GTK_WIDGET (xwininfo));
|
||||
|
||||
{
|
||||
GtkWidget *toolitem;
|
||||
@@ -336,9 +336,6 @@ xtm_process_window_finalize (GObject *object)
|
||||
if (GTK_IS_BOX (window->statusbar))
|
||||
gtk_widget_destroy (window->statusbar);
|
||||
|
||||
if (GTK_IS_TOOL_ITEM (window->settings_button))
|
||||
gtk_widget_destroy (window->settings_button);
|
||||
|
||||
if (XTM_IS_SETTINGS (window->settings))
|
||||
g_object_unref (window->settings);
|
||||
|
||||
|
||||
@@ -1,52 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<requires lib="libxfce4ui-2" version="4.12"/>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">xc_crosshair</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">preferences-system</property>
|
||||
</object>
|
||||
<object class="XfceTitledDialog" id="process-window">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Task Manager</property>
|
||||
<property name="default_width">490</property>
|
||||
<property name="default_height">465</property>
|
||||
<property name="icon_name">org.xfce.taskmanager</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="process-vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolbar" id="process-toolbar">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="show_arrow">False</property>
|
||||
<property name="icon_size">1</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkToolItem" id="filter-toolitem">
|
||||
<property name="use_action_appearance">False</property>
|
||||
<object class="GtkButton" id="button-settings">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">2</property>
|
||||
<child>
|
||||
<object class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="xscale">0.5</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="filter-entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="primary_icon_stock">gtk-find</property>
|
||||
<property name="secondary_icon_stock">gtk-clear</property>
|
||||
<property name="secondary_icon_sensitive">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">image2</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button-identify">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Identify an open window by clicking on it.</property>
|
||||
<property name="image">image1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="filter-entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="primary_icon_stock">gtk-find</property>
|
||||
<property name="secondary_icon_stock">gtk-clear</property>
|
||||
<property name="secondary_icon_sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* 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-tool-button.h"
|
||||
#include "settings-dialog.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
|
||||
typedef struct _XtmSettingsToolButtonClass XtmSettingsToolButtonClass;
|
||||
struct _XtmSettingsToolButtonClass
|
||||
{
|
||||
GtkMenuToolButtonClass parent_class;
|
||||
};
|
||||
struct _XtmSettingsToolButton
|
||||
{
|
||||
GtkMenuToolButton parent;
|
||||
/*<private>*/
|
||||
};
|
||||
G_DEFINE_TYPE (XtmSettingsToolButton, xtm_settings_tool_button, GTK_TYPE_MENU_TOOL_BUTTON)
|
||||
|
||||
static GtkWidget * construct_menu (void);
|
||||
static void show_settings_dialog (XtmSettingsToolButton *button);
|
||||
|
||||
|
||||
|
||||
static void
|
||||
xtm_settings_tool_button_class_init (XtmSettingsToolButtonClass *klass)
|
||||
{
|
||||
xtm_settings_tool_button_parent_class = g_type_class_peek_parent (klass);
|
||||
}
|
||||
|
||||
static void
|
||||
xtm_settings_tool_button_init (XtmSettingsToolButton *button)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
|
||||
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (button), "gtk-preferences");
|
||||
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (button), TRUE);
|
||||
|
||||
menu = construct_menu ();
|
||||
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button), menu);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (show_settings_dialog), NULL);
|
||||
|
||||
gtk_widget_show_all (GTK_WIDGET (button));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
show_settings_dialog (XtmSettingsToolButton *button)
|
||||
{
|
||||
GtkWidget *parent_window = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW);
|
||||
|
||||
xtm_settings_dialog_run (parent_window);
|
||||
}
|
||||
|
||||
static void
|
||||
refresh_rate_toggled (GtkCheckMenuItem *mi, XtmSettings *settings)
|
||||
{
|
||||
if(gtk_check_menu_item_get_active(mi))
|
||||
{
|
||||
guint refresh_rate = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (mi), "refresh-rate"));
|
||||
g_object_set (settings, "refresh-rate", refresh_rate, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
menu_refresh_rate_append_item (GtkMenu *menu, gchar *title, guint refresh_rate, XtmSettings *settings)
|
||||
{
|
||||
GtkWidget *mi;
|
||||
guint cur_refresh_rate;
|
||||
static GSList *group = NULL;
|
||||
|
||||
g_object_get (settings, "refresh-rate", &cur_refresh_rate, NULL);
|
||||
|
||||
mi = gtk_radio_menu_item_new_with_label (group, title);
|
||||
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (mi));
|
||||
if (cur_refresh_rate == refresh_rate)
|
||||
{
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), TRUE);
|
||||
}
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
g_object_set_data (G_OBJECT (mi), "refresh-rate", GUINT_TO_POINTER (refresh_rate));
|
||||
g_signal_connect (mi, "activate", G_CALLBACK (refresh_rate_toggled), settings);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
build_refresh_rate_menu (XtmSettings *settings)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
/* TRANSLATORS: The next values are in seconds or milliseconds */
|
||||
menu_refresh_rate_append_item (GTK_MENU (menu), _("500ms"), 500, settings);
|
||||
menu_refresh_rate_append_item (GTK_MENU (menu), _("750ms"), 750, settings);
|
||||
menu_refresh_rate_append_item (GTK_MENU (menu), _("1s"), 1000, settings);
|
||||
menu_refresh_rate_append_item (GTK_MENU (menu), _("2s"), 2000, settings);
|
||||
menu_refresh_rate_append_item (GTK_MENU (menu), _("5s"), 5000, settings);
|
||||
menu_refresh_rate_append_item (GTK_MENU (menu), _("10s"), 10000, settings);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
static void
|
||||
item_toggled (GtkCheckMenuItem *mi, XtmSettings *settings)
|
||||
{
|
||||
gboolean active = gtk_check_menu_item_get_active (mi);
|
||||
gchar *setting_name = g_object_get_data (G_OBJECT (mi), "setting-name");
|
||||
g_object_set (settings, setting_name, active, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_notify (GObject *object, GParamSpec *pspec, GtkCheckMenuItem *mi)
|
||||
{
|
||||
gboolean active;
|
||||
g_object_get (object, pspec->name, &active, NULL);
|
||||
gtk_check_menu_item_set_active (mi, active);
|
||||
}
|
||||
|
||||
static void
|
||||
menu_append_item (GtkMenu *menu, gchar *title, gchar *setting_name, XtmSettings *settings)
|
||||
{
|
||||
GtkWidget *mi;
|
||||
gboolean active = FALSE;
|
||||
gchar *notify_name;
|
||||
|
||||
g_object_get (settings, setting_name, &active, NULL);
|
||||
|
||||
mi = gtk_check_menu_item_new_with_label (title);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
g_object_set_data (G_OBJECT (mi), "setting-name", setting_name);
|
||||
g_signal_connect (mi, "toggled", G_CALLBACK (item_toggled), settings);
|
||||
|
||||
notify_name = g_strdup_printf ("notify::%s", setting_name);
|
||||
g_signal_connect (settings, notify_name, G_CALLBACK (settings_notify), mi);
|
||||
g_free (notify_name);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
construct_menu (void)
|
||||
{
|
||||
XtmSettings *settings = xtm_settings_get_default ();
|
||||
GtkWidget *menu = gtk_menu_new ();
|
||||
GtkWidget *refresh_rate_menu;
|
||||
GtkWidget *mi;
|
||||
|
||||
menu_append_item (GTK_MENU (menu), _("Show all processes"), "show-all-processes", settings);
|
||||
|
||||
refresh_rate_menu = build_refresh_rate_menu (settings);
|
||||
mi = gtk_menu_item_new_with_label (_("Refresh rate"));
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), refresh_rate_menu);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
mi = gtk_separator_menu_item_new ();
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
menu_append_item (GTK_MENU (menu), _("PID"), "column-pid", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("PPID"), "column-ppid", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("State"), "column-state", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("Virtual Bytes"), "column-vsz", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("Private Bytes"), "column-rss", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("UID"), "column-uid", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("CPU"), "column-cpu", settings);
|
||||
menu_append_item (GTK_MENU (menu), _("Priority"), "column-priority", settings);
|
||||
|
||||
mi = gtk_separator_menu_item_new ();
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
menu_append_item (GTK_MENU (menu), _("Show Legend"), "show-legend", settings);
|
||||
|
||||
gtk_widget_show_all (menu);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GtkWidget *
|
||||
xtm_settings_tool_button_new (void)
|
||||
{
|
||||
return g_object_new (XTM_TYPE_SETTINGS_TOOL_BUTTON, NULL);
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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_TOOL_BUTTON_H
|
||||
#define SETTINGS_TOOL_BUTTON_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define XTM_TYPE_SETTINGS_TOOL_BUTTON (xtm_settings_tool_button_get_type ())
|
||||
#define XTM_SETTINGS_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XTM_TYPE_SETTINGS_TOOL_BUTTON, XtmSettingsToolButton))
|
||||
#define XTM_SETTINGS_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XTM_TYPE_SETTINGS_TOOL_BUTTON, XtmSettingsToolButtonClass))
|
||||
#define XTM_IS_SETTINGS_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XTM_TYPE_SETTINGS_TOOL_BUTTON))
|
||||
#define XTM_IS_SETTINGS_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XTM_TYPE_SETTINGS_TOOL_BUTTON))
|
||||
#define XTM_SETTINGS_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XTM_TYPE_SETTINGS_TOOL_BUTTON, XtmSettingsToolButtonClass))
|
||||
|
||||
typedef struct _XtmSettingsToolButton XtmSettingsToolButton;
|
||||
|
||||
GType xtm_settings_tool_button_get_type (void);
|
||||
GtkWidget * xtm_settings_tool_button_new (void);
|
||||
|
||||
#endif /* !SETTINGS_TOOL_BUTTON_H */
|
||||
Reference in New Issue
Block a user