Commit d254ed8d authored by Benoît Dejean's avatar Benoît Dejean Committed by Benoît Dejean
Browse files

Dropped dead code. Every app now has a default icon. Reworked the

2007-05-19  Benoît Dejean  <benoit@placenet.org>

	* src/defaulttable.h:
	* src/prettytable.cpp:
	* src/prettytable.h:
	
	Dropped dead code.
	Every app now has a default icon.
	Reworked the defaultable:
		- uses regexes.
		- uses generic icon name whenever possible.

svn path=/trunk/; revision=2038
parent 6a89e55e
2007-05-19 Benoît Dejean <benoit@placenet.org>
* src/defaulttable.h:
* src/prettytable.cpp:
* src/prettytable.h:
Dropped dead code.
Every app now has a default icon.
Reworked the defaultable:
- uses regexes.
- uses generic icon name whenever possible.
2007-05-19 Benoît Dejean <benoit@placenet.org>
* configure.in:
......
#ifndef _PROCMAN_DEFAULTTABLE_H_
#define _PROCMAN_DEFAULTTABLE_H_
/* This file contains prettynames and icons for well-known applications, that by default has no .desktop entry */
#include <string>
#include <tr1/memory>
#include <pcrecpp.h>
typedef struct _PrettyTableItem PrettyTableItem;
/* This file contains prettynames and icons for well-known applications, that by default has no .desktop entry */
struct _PrettyTableItem
struct PrettyTableItem
{
const char *command;
const char *icon;
std::tr1::shared_ptr<pcrecpp::RE> command;
std::string icon;
};
#define ITEM(CMD, ICON) { std::tr1::shared_ptr<pcrecpp::RE>(new pcrecpp::RE((CMD "$"))), (ICON) }
/* The current table is only a test */
static const PrettyTableItem default_table[] = {
/* "0", "gnome-run", */
{"X", "gnome-mdi"},
{"Xorg", "gnome-mdi"},
{"aio" G_DIR_SEPARATOR_S "0", "gnome-run"},
{"aio" G_DIR_SEPARATOR_S "1", "gnome-run"},
{"aio" G_DIR_SEPARATOR_S "2", "gnome-run"},
{"aio" G_DIR_SEPARATOR_S "3", "gnome-run"},
{"apache", "other" G_DIR_SEPARATOR_S "SMB-Server-alt"},
{"apache2", "other" G_DIR_SEPARATOR_S "SMB-Server-alt"},
{"atd", "gnome-set-time"},
{"bash", "gnome-term"},
{"cron", "gnome-set-time"},
{"CRON", "gnome-set-time"},
{"cupsd", "other" G_DIR_SEPARATOR_S "Printer"},
{"cvsd", "other" G_DIR_SEPARATOR_S "SMB-Server-alt"},
{"dbus-daemon-1", "other" G_DIR_SEPARATOR_S "Reading"},
{"emacs", "gnome-emacs"},
{"emacsserver", "gnome-emacs"},
{"emacs21", "gnome-emacs"},
{"events" G_DIR_SEPARATOR_S "0", "other" G_DIR_SEPARATOR_S "Dialog-Warning5"},
{"events" G_DIR_SEPARATOR_S "1", "other" G_DIR_SEPARATOR_S "Dialog-Warning5"},
{"events" G_DIR_SEPARATOR_S "2", "other" G_DIR_SEPARATOR_S "Dialog-Warning5"},
{"events" G_DIR_SEPARATOR_S "3", "other" G_DIR_SEPARATOR_S "Dialog-Warning5"},
{"evolution-alarm-notify", "other" G_DIR_SEPARATOR_S "Button-Apps"},
{"evolution-wombat", "other" G_DIR_SEPARATOR_S "Button-Apps"},
{"exim4", "other" G_DIR_SEPARATOR_S "Envelope"},
{"famd", "other" G_DIR_SEPARATOR_S "Find-Files2"},
{"gam_server", "other" G_DIR_SEPARATOR_S "Find-Files2"},
{"gconfd-2", "other" G_DIR_SEPARATOR_S "Control-Center2"},
{"gdm", "gdm"},
{"getty", "gksu-icon"},
{"gnome-session", "gnome-logo-icon-transparent"},
{"inetd", "other" G_DIR_SEPARATOR_S "Networking"},
{"logger", "gnome-log"},
{"kblockd" G_DIR_SEPARATOR_S "0", "other" G_DIR_SEPARATOR_S "Disks"},
{"kblockd" G_DIR_SEPARATOR_S "1", "other" G_DIR_SEPARATOR_S "Disks"},
{"kblockd" G_DIR_SEPARATOR_S "2", "other" G_DIR_SEPARATOR_S "Disks"},
{"kblockd" G_DIR_SEPARATOR_S "3", "other" G_DIR_SEPARATOR_S "Disks"},
/* "khelper", "other" G_DIR_SEPARATOR_S "Help", */
{"kirqd", "other" G_DIR_SEPARATOR_S "Connection-Ethernet"},
{"klogd", "gnome-log"},
{"ksoftirqd" G_DIR_SEPARATOR_S "0", "other" G_DIR_SEPARATOR_S "Connection-Ethernet"},
{"ksoftirqd" G_DIR_SEPARATOR_S "1", "other" G_DIR_SEPARATOR_S "Connection-Ethernet"},
{"ksoftirqd" G_DIR_SEPARATOR_S "2", "other" G_DIR_SEPARATOR_S "Connection-Ethernet"},
{"ksoftirqd" G_DIR_SEPARATOR_S "3", "other" G_DIR_SEPARATOR_S "Connection-Ethernet"},
/* "kswapd0", "other" G_DIR_SEPARATOR_S "Harddisk", */
{"mc", "mc"},
{"metacity", "metacity-properties"},
{"migration" G_DIR_SEPARATOR_S "0" ,"other" G_DIR_SEPARATOR_S "Bird"},
{"migration" G_DIR_SEPARATOR_S "1" ,"other" G_DIR_SEPARATOR_S "Bird"},
{"migration" G_DIR_SEPARATOR_S "2" ,"other" G_DIR_SEPARATOR_S "Bird"},
{"migration" G_DIR_SEPARATOR_S "3" ,"other" G_DIR_SEPARATOR_S "Bird"},
{"mysqld", "other" G_DIR_SEPARATOR_S "MySQL"},
{"mutt", "mutt"},
{"pdflush", "gnome-run"},
{"portmap","other" G_DIR_SEPARATOR_S "Connection-Ethernet"},
{"powernowd", "battstat"},
{"pppoe", "other" G_DIR_SEPARATOR_S "Modem"},
{"reiserfs" G_DIR_SEPARATOR_S "0","other" G_DIR_SEPARATOR_S "Disks"},
{"reiserfs" G_DIR_SEPARATOR_S "1","other" G_DIR_SEPARATOR_S "Disks"},
{"reiserfs" G_DIR_SEPARATOR_S "2","other" G_DIR_SEPARATOR_S "Disks"},
{"reiserfs" G_DIR_SEPARATOR_S "3","other" G_DIR_SEPARATOR_S "Disks"},
{"sendmail", "other" G_DIR_SEPARATOR_S "Envelope"},
{"setiathome", "other" G_DIR_SEPARATOR_S "WPicon2"},
{"sh", "gnome-term"},
{"squid", "other" G_DIR_SEPARATOR_S "Proxy-Config"},
{"sshd", "ssh-askpass-gnome"},
{"ssh", "ssh-askpass-gnome"},
{"ssh-agent", "ssh-askpass-gnome"},
{"syslogd", "gnome-log"},
{"tail", "other" G_DIR_SEPARATOR_S "Tail"},
{"top", "gnome-ccperiph"},
{"xfs", "other" G_DIR_SEPARATOR_S "Font-Capplet"},
{"xscreensaver", "xscreensaver"},
{"xterm", "gnome-xterm"},
{"vim", "vim"},
/* GNOME applets */
{"accessx-status-applet", "gnome-applets"},
{"battstat-applet-2", "gnome-applets"},
{"charpick_applet2", "gnome-applets"},
{"cpufreq-applet", "gnome-applets"},
{"drivemount_applet2", "gnome-applets"},
{"geyes_applet2", "gnome-applets"},
{"gnome-keyboard-applet", "gnome-applets"},
{"gtik2_applet2", "gnome-applets"},
{"gweather-applet-2", "gnome-applets"},
{"mini_commander_applet", "gnome-applets"},
{"mixer_applet2", "gnome-applets"},
{"modem_applet", "gnome-applets"},
{"multiload-applet-2", "gnome-applets"},
{"netspeed-applet-2", "gnome-applets"},
{"null_applet", "gnome-applets"},
{"rhythmbox-applet", "gnome-applets"},
{"stickynotes_applet", "gnome-applets"},
{"trashapplet", "gnome-applets"},
{"clock-applet", "gnome-applets"},
{"notification-area-applet", "gnome-applets"},
{"wnck-applet", "gnome-applets"}
ITEM("(ba|z|tc|c|k)sh", "utilities-terminal"),
ITEM("(k|sys|u)logd|logger", "internet-news-reader"),
ITEM("X(org)?", "display"),
ITEM("(ksoftirqd|aio|events|kondemand|reiserfs|kswapd|kblockd)/?\\d+", "applications-system"),
ITEM("kthread|khelper|khubd|kfand|ksuspend_usbd|pdflush", "applications-system"),
ITEM("apache2?|httpd|lighttpd", "internet-web-browser"),
ITEM("applet(-?2)?", "gnome-applets"),
ITEM("atd|cron|CRON|ntpd", "date"),
ITEM("cupsd|lpd?", "printer"),
ITEM("cvsd|mtn", "file-manager"),
ITEM("emacs(server|\\d+)?", "gnome-emacs"),
ITEM("evolution.*", "internet-mail"),
ITEM("famd|gam_server", "file-manager"),
ITEM("gconfd-2", "preferences-desktop"),
ITEM("getty", "input-keyboard"),
ITEM("metacity", "gnome-window-manager"),
ITEM("sendmail|exim\\d?", "internet-mail"),
ITEM("squid", "proxy"),
ITEM("ssh(d|-agent)", "ssh-askpass-gnome"),
ITEM("top|vmstat", "system-monitor"),
ITEM("vim?", "vim"),
ITEM("x?inetd", "internet-web-browser"),
ITEM("vino.*", "gnome-remote-desktop")
};
#undef ITEM
#endif /* _PROCMAN_DEFAULTTABLE_H_ */
......@@ -17,29 +17,6 @@
namespace
{
const unsigned APP_ICON_SIZE = 16;
GdkPixbuf*
create_scaled_icon(const char *iconpath)
{
GError* error = NULL;
GdkPixbuf* scaled;
scaled = gdk_pixbuf_new_from_file_at_scale(iconpath,
APP_ICON_SIZE, APP_ICON_SIZE,
TRUE,
&error);
if (error) {
if(!(error->domain == G_FILE_ERROR
&& error->code == G_FILE_ERROR_NOENT))
g_warning(error->message);
g_error_free(error);
return NULL;
}
return scaled;
}
}
......@@ -150,7 +127,7 @@ PrettyTable::get_icon_from_theme(pid_t, const gchar* command)
bool PrettyTable::get_default_icon_name(const string &cmd, string &name)
{
for (size_t i = 0; i != G_N_ELEMENTS(default_table); ++i) {
if (cmd == default_table[i].command) {
if (default_table[i].command->PartialMatch(cmd)) {
name = default_table[i].icon;
return true;
}
......@@ -212,6 +189,28 @@ PrettyTable::get_icon_from_wnck(pid_t pid, const gchar*)
GdkPixbuf*
PrettyTable::get_icon_from_name(pid_t, const gchar* command)
{
return gtk_icon_theme_load_icon(this->theme,
command,
APP_ICON_SIZE,
GTK_ICON_LOOKUP_USE_BUILTIN,
NULL);
}
GdkPixbuf*
PrettyTable::get_icon_dummy(pid_t, const gchar*)
{
return gtk_icon_theme_load_icon(this->theme,
"applications-other",
APP_ICON_SIZE,
GTK_ICON_LOOKUP_USE_BUILTIN,
NULL);
}
GdkPixbuf*
PrettyTable::get_icon(const gchar* command, pid_t pid)
{
......@@ -221,7 +220,9 @@ PrettyTable::get_icon(const gchar* command, pid_t pid)
const Getter getters[] = {
&PrettyTable::get_icon_from_wnck,
&PrettyTable::get_icon_from_theme,
&PrettyTable::get_icon_from_default
&PrettyTable::get_icon_from_default,
&PrettyTable::get_icon_from_name,
&PrettyTable::get_icon_dummy,
};
for (size_t i = 0; i < G_N_ELEMENTS(getters); ++i) {
......
......@@ -37,6 +37,8 @@ private:
GdkPixbuf* get_icon_from_theme(pid_t pid, const gchar* command);
GdkPixbuf* get_icon_from_default(pid_t pid, const gchar* command);
GdkPixbuf* get_icon_from_wnck(pid_t pid, const gchar* command);
GdkPixbuf* get_icon_from_name(pid_t pid, const gchar* command);
GdkPixbuf* get_icon_dummy(pid_t pid, const gchar* command);
bool get_default_icon_name(const string &cmd, string &name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment