From 39ffa8406ba4ec338d677fbdfae97b35ac7ad4b8 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Wed, 30 May 2012 10:23:27 +0000 Subject: [PATCH] Code cleanup. Removing usage of EDE_PANEL_APPLET_CLASS since there is no much usage of it. Also, marked all applet widgets as EDE_PANEL_WIDGET_TYPE so panel knows it is widget. Added license info in some code, but whole ede2 tree needs to be revised for that. --- ede-panel/Applet.h | 12 +++++------ ede-panel/Panel.cpp | 20 +++++++++++++++++++ ede-panel/Panel.h | 20 +++++++++++++++++++ ede-panel/applets/clock/Clock.cpp | 2 +- ede-panel/applets/cpu-monitor/CpuMonitor.h | 2 +- ede-panel/applets/demo/AppletDemo.cpp | 2 +- .../applets/keyboard-layout/KeyLayout.cpp | 2 +- ede-panel/applets/mem-monitor/MemMonitor.h | 2 +- ede-panel/applets/pager/Pager.cpp | 2 +- .../applets/quick-launch/QuickLaunch.cpp | 2 +- ede-panel/applets/start-menu/StartMenu.cpp | 2 +- ede-panel/applets/system-tray/Tray.h | 2 +- ede-panel/applets/taskbar/Taskbar.h | 2 +- 13 files changed, 56 insertions(+), 16 deletions(-) diff --git a/ede-panel/Applet.h b/ede-panel/Applet.h index ed54228..97927c0 100644 --- a/ede-panel/Applet.h +++ b/ede-panel/Applet.h @@ -26,6 +26,9 @@ class Fl_Widget; /* stored version in each applet shared library in case interface get changed */ #define EDE_PANEL_APPLET_INTERFACE_VERSION 0x01 +/* all panel widgets are marked with this type (make sure it is greater than FL_DOUBLE_WINDOW */ +#define EDE_PANEL_WIDGET_TYPE 0xFA + /* * Options assigned to each applet: how it will be resizable (horizontally or vertically) * and how it will be aligned. Each applet is by default aligned left without resizing ability. @@ -58,10 +61,11 @@ typedef float (*applet_version_t)(void); * The main macro each applet library must implement. It will assign apropriate values * so applet loader can use them to load applet class with some common metadata. */ - #define EDE_PANEL_APPLET_EXPORT(klass, aoptions, aname, aversion, aicon, aauthor) \ extern "C" Fl_Widget *ede_panel_applet_create(void) { \ - return new klass; \ + klass *k = new klass; \ + k->type(EDE_PANEL_WIDGET_TYPE); \ + return k; \ } \ \ extern "C" void ede_panel_applet_destroy(Fl_Widget *w) { \ @@ -88,8 +92,4 @@ extern "C" int ede_panel_applet_get_iface_version(void) { return EDE_PANEL_APPLET_INTERFACE_VERSION; \ } -/* each applet must use this so applets can be easily extended in the future */ - -#define EDE_PANEL_APPLET_CLASS(c, inherits) class c : public inherits - #endif diff --git a/ede-panel/Panel.cpp b/ede-panel/Panel.cpp index 5d986c0..d9308da 100644 --- a/ede-panel/Panel.cpp +++ b/ede-panel/Panel.cpp @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * Copyright (C) 2012 Sanel Zukan + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + #include #include #include diff --git a/ede-panel/Panel.h b/ede-panel/Panel.h index 8cbe314..de0de7f 100644 --- a/ede-panel/Panel.h +++ b/ede-panel/Panel.h @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * Copyright (C) 2012 Sanel Zukan + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + #ifndef __PANEL_H__ #define __PANEL_H__ diff --git a/ede-panel/applets/clock/Clock.cpp b/ede-panel/applets/clock/Clock.cpp index 1db0e20..aaf9a81 100644 --- a/ede-panel/applets/clock/Clock.cpp +++ b/ede-panel/applets/clock/Clock.cpp @@ -11,7 +11,7 @@ EDELIB_NS_USING(run_async) static void clock_refresh(void *o); -EDE_PANEL_APPLET_CLASS(Clock, Fl_Box) { +class Clock : public Fl_Box { private: int hour; char buf[64], tbuf[128]; diff --git a/ede-panel/applets/cpu-monitor/CpuMonitor.h b/ede-panel/applets/cpu-monitor/CpuMonitor.h index 7dea502..2f5b250 100644 --- a/ede-panel/applets/cpu-monitor/CpuMonitor.h +++ b/ede-panel/applets/cpu-monitor/CpuMonitor.h @@ -19,7 +19,7 @@ enum { IWM_STATES }; -EDE_PANEL_APPLET_CLASS(CPUMonitor, Fl_Box) { +class CPUMonitor : public Fl_Box { private: bool m_draw_label; int m_old_samples; diff --git a/ede-panel/applets/demo/AppletDemo.cpp b/ede-panel/applets/demo/AppletDemo.cpp index 6c73a23..a2e3692 100644 --- a/ede-panel/applets/demo/AppletDemo.cpp +++ b/ede-panel/applets/demo/AppletDemo.cpp @@ -4,7 +4,7 @@ #include #include -EDE_PANEL_APPLET_CLASS(MyButton, Fl_Button) { +class MyButton : public Fl_Button { public: MyButton() : Fl_Button(0, 0, 90, 25, "xxx") { color(FL_RED); diff --git a/ede-panel/applets/keyboard-layout/KeyLayout.cpp b/ede-panel/applets/keyboard-layout/KeyLayout.cpp index cf09fd7..2be0459 100644 --- a/ede-panel/applets/keyboard-layout/KeyLayout.cpp +++ b/ede-panel/applets/keyboard-layout/KeyLayout.cpp @@ -41,7 +41,7 @@ EDELIB_NS_USING(RES_SYS_ONLY) static Atom _XA_XKB_RF_NAMES_PROP_ATOM = 0; -EDE_PANEL_APPLET_CLASS(KeyLayout, Fl_Button) { +class KeyLayout : public Fl_Button { private: bool should_show_flag; String path, curr_layout; diff --git a/ede-panel/applets/mem-monitor/MemMonitor.h b/ede-panel/applets/mem-monitor/MemMonitor.h index deff134..b4e2d5b 100644 --- a/ede-panel/applets/mem-monitor/MemMonitor.h +++ b/ede-panel/applets/mem-monitor/MemMonitor.h @@ -4,7 +4,7 @@ #include #include "Applet.h" -EDE_PANEL_APPLET_CLASS(MemMonitor, Fl_Box) { +class MemMonitor : public Fl_Box { private: int mem_usedp, swap_usedp; diff --git a/ede-panel/applets/pager/Pager.cpp b/ede-panel/applets/pager/Pager.cpp index da80088..bc543ad 100644 --- a/ede-panel/applets/pager/Pager.cpp +++ b/ede-panel/applets/pager/Pager.cpp @@ -18,7 +18,7 @@ EDELIB_NS_USING(netwm_callback_add) EDELIB_NS_USING(netwm_callback_remove) EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKSPACE) -EDE_PANEL_APPLET_CLASS(Pager, Fl_Group) { +class Pager : public Fl_Group { public: Pager(); ~Pager(); diff --git a/ede-panel/applets/quick-launch/QuickLaunch.cpp b/ede-panel/applets/quick-launch/QuickLaunch.cpp index 37ef967..bbb258c 100644 --- a/ede-panel/applets/quick-launch/QuickLaunch.cpp +++ b/ede-panel/applets/quick-launch/QuickLaunch.cpp @@ -14,7 +14,7 @@ EDELIB_NS_USING(run_async) -EDE_PANEL_APPLET_CLASS(QuickLaunch, Fl_Input) { +class QuickLaunch : public Fl_Input { private: Fl_Image *img; int img_x, img_y; diff --git a/ede-panel/applets/start-menu/StartMenu.cpp b/ede-panel/applets/start-menu/StartMenu.cpp index 8dbf9df..a801418 100644 --- a/ede-panel/applets/start-menu/StartMenu.cpp +++ b/ede-panel/applets/start-menu/StartMenu.cpp @@ -13,7 +13,7 @@ EDELIB_NS_USING(MenuBase) /* some of this code was ripped from Fl_Menu_Button.cxx */ -EDE_PANEL_APPLET_CLASS(StartMenu, MenuBase) { +class StartMenu : public MenuBase { private: MenuItem *mcontent; public: diff --git a/ede-panel/applets/system-tray/Tray.h b/ede-panel/applets/system-tray/Tray.h index 15b3336..677e770 100644 --- a/ede-panel/applets/system-tray/Tray.h +++ b/ede-panel/applets/system-tray/Tray.h @@ -16,7 +16,7 @@ struct WinInfo { typedef list WinList; typedef list::iterator WinListIt; -EDE_PANEL_APPLET_CLASS(Tray, Fl_Group) { +class Tray : public Fl_Group { private: Atom opcode, message_data; WinList win_list; diff --git a/ede-panel/applets/taskbar/Taskbar.h b/ede-panel/applets/taskbar/Taskbar.h index 86bb2c6..f00083f 100644 --- a/ede-panel/applets/taskbar/Taskbar.h +++ b/ede-panel/applets/taskbar/Taskbar.h @@ -7,7 +7,7 @@ class TaskButton; class Panel; -EDE_PANEL_APPLET_CLASS(Taskbar, Fl_Group) { +class Taskbar : public Fl_Group { public: TaskButton *curr_active, *prev_active; Panel *panel;