Commit 7fffbf1a authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin

bit of namespace loving.

2001-11-09  Mark McLoughlin  <mark@skynet.ie>

        * applet.c, applet.h: bit of namespace loving.

        * drawer.c, extern.c, gnome-run.c, launcher.c,
          logout.c, menu-properties.c, menu.c,
          panel-applet-frame.c, panel.c, session.c,
          status.c, swallow.c: update.
parent 0f2bf428
2001-11-09 Mark McLoughlin <mark@skynet.ie>
* applet.c, applet.h: bit of namespace loving.
* drawer.c, extern.c, gnome-run.c, launcher.c,
logout.c, menu-properties.c, menu.c,
panel-applet-frame.c, panel.c, session.c,
status.c, swallow.c: update.
2001-11-09 Mark McLoughlin <mark@skynet.ie>
* applet.c, applet.h: kill horrible applets_last hack.
......
......@@ -58,7 +58,7 @@ move_applet_callback (GtkWidget *widget, AppletInfo *info)
/*destroy widgets and call the above cleanup function*/
void
panel_clean_applet (AppletInfo *info)
panel_applet_clean (AppletInfo *info)
{
g_return_if_fail (info != NULL);
......@@ -88,7 +88,7 @@ kill_applet_in_idle(gpointer data)
swallow->clean_remove = TRUE;
}
panel_clean_applet (info);
panel_applet_clean (info);
return FALSE;
}
......@@ -227,8 +227,8 @@ applet_menu_deactivate(GtkWidget *w, AppletInfo *info)
}
AppletUserMenu *
applet_get_callback (GList *user_menu,
const char *name)
panel_applet_get_callback (GList *user_menu,
const char *name)
{
GList *l;
......@@ -243,16 +243,16 @@ applet_get_callback (GList *user_menu,
}
void
applet_add_callback(AppletInfo *info,
const char *callback_name,
const char *stock_item,
const char *menuitem_text)
panel_applet_add_callback (AppletInfo *info,
const char *callback_name,
const char *stock_item,
const char *menuitem_text)
{
AppletUserMenu *menu;
g_return_if_fail (info != NULL);
menu = applet_get_callback (info->user_menu, callback_name);
menu = panel_applet_get_callback (info->user_menu, callback_name);
if (menu == NULL) {
menu = g_new0 (AppletUserMenu, 1);
menu->name = g_strdup (callback_name);
......@@ -287,13 +287,14 @@ applet_add_callback(AppletInfo *info,
}
void
applet_remove_callback(AppletInfo *info, const char *callback_name)
panel_applet_remove_callback (AppletInfo *info,
const char *callback_name)
{
AppletUserMenu *menu;
g_return_if_fail (info != NULL);
menu = applet_get_callback (info->user_menu, callback_name);
menu = panel_applet_get_callback (info->user_menu, callback_name);
if (menu != NULL) {
info->user_menu = g_list_remove (info->user_menu, menu);
g_free(menu->name);
......@@ -321,13 +322,15 @@ applet_remove_callback(AppletInfo *info, const char *callback_name)
}
void
applet_callback_set_sensitive(AppletInfo *info, const char *callback_name, int sensitive)
panel_applet_callback_set_sensitive (AppletInfo *info,
const gchar *callback_name,
gint sensitive)
{
AppletUserMenu *menu;
g_return_if_fail(info != NULL);
menu = applet_get_callback(info->user_menu, callback_name);
menu = panel_applet_get_callback(info->user_menu, callback_name);
if (menu != NULL)
menu->sensitive = sensitive;
else
......@@ -425,7 +428,7 @@ add_to_submenus (AppletInfo *info,
p++;
t = g_strconcat (path, n, "/", NULL);
s_menu = applet_get_callback (user_menu, t);
s_menu = panel_applet_get_callback (user_menu, t);
/*the user did not give us this sub menu, whoops, will create an empty
one then*/
if (s_menu == NULL) {
......@@ -492,8 +495,8 @@ applet_setup_panel_menu (gboolean is_basep)
}
void
create_applet_menu (AppletInfo *info,
gboolean is_basep)
panel_applet_create_menu (AppletInfo *info,
gboolean is_basep)
{
GtkWidget *menuitem;
GList *l;
......@@ -596,7 +599,7 @@ applet_show_menu (AppletInfo *info,
panel = get_panel_parent (info->widget);
if (!info->menu)
create_applet_menu (info, BASEP_IS_WIDGET (panel));
panel_applet_create_menu (info, BASEP_IS_WIDGET (panel));
g_assert (info->menu);
......@@ -817,7 +820,7 @@ panel_applet_register (GtkWidget *applet,
/*can't put it anywhere, clean up*/
gtk_widget_destroy(applet);
info->widget = NULL;
panel_clean_applet(info);
panel_applet_clean(info);
g_warning(_("Can't find an empty spot"));
g_free (info);
return NULL;
......
......@@ -7,16 +7,16 @@
G_BEGIN_DECLS
#define EMPTY_ID "Empty" /*this applet should not be loaded*/
#define MENU_ID "Menu"
#define DRAWER_ID "Drawer"
#define LOGOUT_ID "Logout"
#define SWALLOW_ID "Swallow"
#define EXTERN_ID "Extern"
#define EMPTY_ID "Empty"
#define MENU_ID "Menu"
#define DRAWER_ID "Drawer"
#define LOGOUT_ID "Logout"
#define SWALLOW_ID "Swallow"
#define EXTERN_ID "Extern"
#define LAUNCHER_ID "Launcher"
#define LOCK_ID "Lock"
#define STATUS_ID "Status"
#define RUN_ID "Run"
#define LOCK_ID "Lock"
#define STATUS_ID "Status"
#define RUN_ID "Run"
typedef enum {
APPLET_EXTERN,
......@@ -38,57 +38,61 @@ typedef enum {
GDK_BUTTON_RELEASE_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK)
typedef struct {
AppletType type;
int applet_id;
GtkWidget *widget;
GtkWidget *menu;
int menu_age;
GList *user_menu;
gpointer data;
GDestroyNotify data_destroy;
} AppletInfo;
typedef struct {
gchar *name;
gchar *stock_item;
gchar *text;
gint sensitive;
AppletInfo *info;
GtkWidget *menuitem;
GtkWidget *submenu;
} AppletUserMenu;
AppletInfo *panel_applet_register (GtkWidget *applet,
gpointer data,
GDestroyNotify data_destroy,
PanelWidget *panel,
gint pos,
gboolean exactpos,
AppletType type);
void panel_applet_clean (AppletInfo *info);
void panel_applet_create_menu (AppletInfo *info,
gboolean is_basep);
void panel_applet_add_callback (AppletInfo *info,
const gchar *callback_name,
const gchar *stock_item,
const gchar *menuitem_text);
void panel_applet_remove_callback (AppletInfo *info,
const char *callback_name);
AppletUserMenu *panel_applet_get_callback (GList *user_menu,
const gchar *name);
void panel_applet_callback_set_sensitive (AppletInfo *info,
const char *callback_name,
gint sensitive);
typedef struct _AppletUserMenu AppletUserMenu;
typedef struct _AppletInfo AppletInfo;
struct _AppletUserMenu {
char *name;
char *stock_item;
char *text;
int sensitive;
AppletInfo *info;
GtkWidget *menuitem;
GtkWidget *submenu;
};
struct _AppletInfo {
AppletType type;
int applet_id;
GtkWidget *widget; /*an event box*/
GtkWidget *menu; /*the applet menu*/
int menu_age;
GList *user_menu; /*list of AppletUserMenu items for callbacks*/
gpointer data; /*the per applet structure, if it exists*/
GDestroyNotify data_destroy;
};
AppletInfo *panel_applet_register (GtkWidget *applet,
gpointer data,
GDestroyNotify data_destroy,
PanelWidget *panel,
gint pos,
gboolean exactpos,
AppletType type);
void panel_clean_applet(AppletInfo *info);
/*applet menu stuff*/
void create_applet_menu(AppletInfo *info, gboolean is_basep);
void applet_add_callback(AppletInfo *info,
const char *callback_name,
const char *stock_item,
const char *menuitem_text);
void applet_remove_callback(AppletInfo *info,
const char *callback_name);
AppletUserMenu * applet_get_callback (GList *user_menu, const char *name);
void applet_callback_set_sensitive(AppletInfo *info,
const char *callback_name,
int sensitive);
/* during session save, we call this to unlink the .desktop files of
* removed launchers */
void remove_unused_launchers (void);
G_END_DECLS
......
......@@ -494,12 +494,12 @@ load_drawer_applet (int mypanel_id, const char *pixmap, const char *tooltip,
drawer_setup (drawer);
if (!commie_mode)
applet_add_callback (info,
"properties",
GTK_STOCK_PROPERTIES,
_("Properties..."));
panel_applet_add_callback (info,
"properties",
GTK_STOCK_PROPERTIES,
_("Properties..."));
applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
return drawer;
}
......
......@@ -487,7 +487,7 @@ extern_remove_applet (Extern ext)
extern_ref (ext);
panel_clean_applet (ext->info);
panel_applet_clean (ext->info);
ext->info = NULL;
extern_unref (ext);
......@@ -954,7 +954,7 @@ send_position_change (Extern ext)
GNOME_Applet2_change_position (ext->applet, x, y, &env);
if (BONOBO_EX (&env))
panel_clean_applet (ext->info);
panel_applet_clean (ext->info);
CORBA_exception_free (&env);
}
......@@ -1072,19 +1072,10 @@ reserve_applet_spot (Extern ext,
AppletType type)
{
GtkWidget *socket;
gint events;
gint size;
ext->ebox = gtk_event_box_new ();
/*
* FIXME: duplicated in panel_applet_register ?
*/
events = gtk_widget_get_events (ext->ebox) | APPLET_EVENT_MASK;
events &= ~(GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
gtk_widget_set_events (ext->ebox, events);
size = CLAMP (panel->sz, 0, 14);
gtk_widget_set_usize (ext->ebox, size, size);
......@@ -1988,7 +1979,7 @@ s_panelspot_register_us (PortableServer_Servant servant,
*/
ext->clean_remove = TRUE;
panel_clean_applet (ext->info);
panel_applet_clean (ext->info);
}
extern_unref (ext);
......@@ -2003,7 +1994,7 @@ s_panelspot_unregister_us(PortableServer_Servant servant,
extern_save_last_position (ext, TRUE /* sync */);
panel_clean_applet(ext->info);
panel_applet_clean(ext->info);
}
static void
......@@ -2022,7 +2013,7 @@ s_panelspot_abort_load(PortableServer_Servant servant,
return;
ext->clean_remove = TRUE;
panel_clean_applet (ext->info);
panel_applet_clean (ext->info);
}
static void
......@@ -2041,7 +2032,7 @@ s_panelspot_show_menu(PortableServer_Servant servant,
panel = get_panel_parent (ext->info->widget);
if (!ext->info->menu)
create_applet_menu(ext->info, BASEP_IS_WIDGET (panel));
panel_applet_create_menu (ext->info, BASEP_IS_WIDGET (panel));
if (BASEP_IS_WIDGET (panel)) {
BASEP_WIDGET(panel)->autohide_inhibit = TRUE;
......@@ -2118,8 +2109,8 @@ s_panelspot_add_callback(PortableServer_Servant servant,
strcmp (callback_name, "properties") == 0))
return;
applet_add_callback(ext->info, callback_name, stock_item,
menuitem_text);
panel_applet_add_callback (ext->info, callback_name,
stock_item, menuitem_text);
}
static void
......@@ -2129,9 +2120,9 @@ s_panelspot_remove_callback(PortableServer_Servant servant,
{
Extern ext = (Extern)servant;
g_assert(ext != NULL);
g_assert(ext->info != NULL);
applet_remove_callback(ext->info, callback_name);
g_assert(ext && ext->info);
panel_applet_remove_callback (ext->info, callback_name);
}
static void
......@@ -2142,9 +2133,9 @@ s_panelspot_callback_set_sensitive(PortableServer_Servant servant,
{
Extern ext = (Extern)servant;
g_assert(ext != NULL);
g_assert(ext->info != NULL);
applet_callback_set_sensitive(ext->info, callback_name, sensitive);
g_assert (ext && ext->info);
panel_applet_callback_set_sensitive (ext->info, callback_name, sensitive);
}
static void
......@@ -2389,7 +2380,7 @@ send_draw (Extern ext)
if (ext->applet != NULL) {
GNOME_Applet2_draw (ext->applet, &env);
if (BONOBO_EX (&env))
panel_clean_applet (ext->info);
panel_applet_clean (ext->info);
}
CORBA_exception_free (&env);
......
......@@ -1318,5 +1318,5 @@ load_run_applet (PanelWidget *panel,
if (!info)
return;
applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
}
......@@ -481,7 +481,9 @@ setup_button (Launcher *launcher)
/* Setup help */
docpath = gnome_desktop_item_get_string (launcher->ditem,
"DocPath");
applet_remove_callback (launcher->info, "help_on_app");
panel_applet_remove_callback (launcher->info, "help_on_app");
real_docpath = panel_gnome_kde_help_path (docpath);
if (real_docpath != NULL) {
char *title;
......@@ -490,9 +492,10 @@ setup_button (Launcher *launcher)
title = g_strdup_printf (_("Help on %s Application"), name);
applet_add_callback (launcher->info, "help_on_app",
GTK_STOCK_HELP,
title);
panel_applet_add_callback (launcher->info,
"help_on_app",
GTK_STOCK_HELP,
title);
g_free (title);
}
}
......@@ -662,12 +665,12 @@ load_launcher_applet_full (const char *params, GnomeDesktopItem *ditem,
}
if (!commie_mode)
applet_add_callback (launcher->info,
"properties",
GTK_STOCK_PROPERTIES,
_("Properties..."));
panel_applet_add_callback (launcher->info,
"properties",
GTK_STOCK_PROPERTIES,
_("Properties..."));
applet_add_callback (launcher->info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (launcher->info, "help", GTK_STOCK_HELP, _("Help"));
/* setup button according to ditem */
setup_button (launcher);
......
......@@ -123,7 +123,7 @@ load_logout_applet (PanelWidget *panel,
if (!info)
return;
applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
}
static GtkWidget *
......@@ -200,13 +200,13 @@ load_lock_applet (PanelWidget *panel,
<jwz> and "xscreensaver-demo"
*/
applet_add_callback (info, "activate", NULL, _("Blank Screen Now"));
applet_add_callback (info, "lock", NULL, _("Lock Screen Now"));
applet_add_callback (info, "exit", NULL, _("Kill Daemon"));
applet_add_callback (info, "restart", NULL, _("Restart Daemon"));
panel_applet_add_callback (info, "activate", NULL, _("Blank Screen Now"));
panel_applet_add_callback (info, "lock", NULL, _("Lock Screen Now"));
panel_applet_add_callback (info, "exit", NULL, _("Kill Daemon"));
panel_applet_add_callback (info, "restart", NULL, _("Restart Daemon"));
if (!commie_mode)
applet_add_callback (info, "prefs", NULL, _("Preferences"));
panel_applet_add_callback (info, "prefs", NULL, _("Preferences"));
applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
}
......@@ -210,17 +210,19 @@ properties_apply_callback (Menu *menu)
/* Setup the edit_menus callback */
if (applet_get_callback (menu->info->user_menu, "edit_menus") != NULL)
if (panel_applet_get_callback (menu->info->user_menu, "edit_menus"))
got_edit_menus = TRUE;
else
got_edit_menus = FALSE;
if (need_edit_menus && ! got_edit_menus)
applet_add_callback (menu->info, "edit_menus",
NULL,
_("Edit menus..."));
else if ( ! need_edit_menus && got_edit_menus)
applet_remove_callback (menu->info, "edit_menus");
panel_applet_add_callback (menu->info,
"edit_menus",
NULL,
_("Edit menus..."));
else if (!need_edit_menus && got_edit_menus)
panel_applet_remove_callback (menu->info, "edit_menus");
......
......@@ -5951,20 +5951,22 @@ load_menu_applet(const char *params, int main_menu_flags, gboolean global_main,
menu->info = info;
if (!commie_mode) {
applet_add_callback (info,
"properties",
GTK_STOCK_PROPERTIES,
_("Properties..."));
panel_applet_add_callback (info,
"properties",
GTK_STOCK_PROPERTIES,
_("Properties..."));
if(params && strcmp(params, ".")==0 &&
(tmp = gnome_is_program_in_path("gmenu"))) {
g_free(tmp);
applet_add_callback (info, "edit_menus",
NULL, _("Edit menus..."));
panel_applet_add_callback (info,
"edit_menus",
NULL,
_("Edit menus..."));
}
}
applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
}
}
......
......@@ -12,9 +12,6 @@ panel_bonobo_applet_widget (const gchar *iid)
event_box = gtk_event_box_new ();
gtk_widget_set_events (event_box,
GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
control = bonobo_widget_new_control (iid, NULL);
gtk_container_add (GTK_CONTAINER (event_box), control);
......
......@@ -557,7 +557,7 @@ panel_destroy (GtkWidget *widget, gpointer data)
"applet_info");
Drawer *drawer = info->data;
drawer->drawer = NULL;
panel_clean_applet (info);
panel_applet_clean (info);
gtk_object_remove_data (GTK_OBJECT (master_widget),
"applet_info");
}
......@@ -1168,7 +1168,7 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
AppletInfo *info = g_slist_nth_data (applets, applet_num);
if (info != NULL)
panel_clean_applet (info);
panel_applet_clean (info);
}
}
......
......@@ -325,7 +325,7 @@ send_applet_session_save (AppletInfo *info,
}
} else if(ev._major) {
gtk_timeout_remove(timeout);
panel_clean_applet(info);
panel_applet_clean(info);
CORBA_exception_free(&ev);
save_next_applet();
return;
......
......@@ -374,7 +374,7 @@ load_status_applet(PanelWidget *panel, int pos, gboolean exactpos)
if (!info)
return TRUE;
applet_add_callback (the_status->info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (the_status->info, "help", GTK_STOCK_HELP, _("Help"));
return TRUE;
}
......@@ -428,7 +428,7 @@ load_swallow_applet (const char *path, const char *params, int width, int height
swallow->clean_remove = FALSE;
applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("Help"));
swallow_launch (swallow);
}
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