Commit 30ca53c5 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

added main menu count and added a way for the remove item to be grayed

Mon May 04 21:13:53 1998  George Lebl  <jirka@5z.com>

	* panel.c,main.c,panel-widget.[ch]: added main menu count
	  and added a way for the remove item to be grayed out, if
	  either you right click on the last main menu or if you
	  right clock on a full panel (you can only remove empty
	  ones)
parent 483d1086
Mon May 04 21:13:53 1998 George Lebl <jirka@5z.com>
* panel.c,main.c,panel-widget.[ch]: added main menu count
and added a way for the remove item to be grayed out, if
either you right click on the last main menu or if you
right clock on a full panel (you can only remove empty
ones)
1998-05-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* launcher.c (properties_apply_callback): Made launcher use the
......
Mon May 04 21:13:53 1998 George Lebl <jirka@5z.com>
* panel.c,main.c,panel-widget.[ch]: added main menu count
and added a way for the remove item to be grayed out, if
either you right click on the last main menu or if you
right clock on a full panel (you can only remove empty
ones)
1998-05-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* launcher.c (properties_apply_callback): Made launcher use the
......
......@@ -33,6 +33,8 @@ extern GtkWidget * root_menu;
char *panel_cfg_path=NULL;
char *old_panel_cfg_path=NULL;
gint main_menu_count=0;
GtkTooltips *panel_tooltips = NULL;
GnomeClient *client = NULL;
......@@ -203,6 +205,8 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
register_toy(menu->button,menu->menu,menu,MENU_ID,params,pos,
panel,NULL,APPLET_MENU);
if(!params || strcmp(params,".")==0)
main_menu_count++;
} else if(strcmp(id_str,LAUNCHER_ID) == 0) {
Launcher *launcher;
......
......@@ -473,6 +473,18 @@ panel_widget_set_size(PanelWidget *panel, gint size)
}
}
/*get the number of applets*/
gint
panel_widget_get_applet_count(PanelWidget *panel)
{
gint i;
GList *list;
for(i=0,list=panel->applet_list;list!=NULL;list=g_list_next(list),i++)
;
return i;
}
static AppletData *
get_applet_data_pos(PanelWidget *panel, gint pos)
{
......
......@@ -235,6 +235,8 @@ void panel_widget_set_drawer_pos (PanelWidget *panel,
gint x,
gint y);
/*get the number of applets*/
gint panel_widget_get_applet_count (PanelWidget *panel);
extern GList *panels;
......
......@@ -45,6 +45,8 @@ extern GlobalConfig global_config;
extern char *panel_cfg_path;
extern char *old_panel_cfg_path;
extern gint main_menu_count;
void
apply_global_config(void)
{
......@@ -384,10 +386,14 @@ panel_clean_applet(gint applet_id)
gtk_widget_destroy(info->assoc);
info->assoc=NULL;
}
if(type == APPLET_MENU && (!info->params ||
strcmp(info->params,".")==0))
main_menu_count--;
info->assoc=NULL;
if(info->menu)
gtk_widget_unref(info->menu);
info->menu = NULL;
info->remove_item = NULL;
if(info->id_str) g_free(info->id_str);
info->id_str=NULL;
......@@ -435,32 +441,33 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
}
}
static GtkWidget *
create_applet_menu(gint applet_id, GList *user_menu)
static void
create_applet_menu(AppletInfo *info)
{
GtkWidget *menuitem;
GtkWidget *applet_menu;
AppletInfo *info = get_applet_info(applet_id);
GList *user_menu = info->user_menu;
applet_menu = gtk_menu_new();
info->menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label(_("Remove from panel"));
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) remove_applet_callback,
ITOP(applet_id));
gtk_menu_append(GTK_MENU(applet_menu), menuitem);
ITOP(info->applet_id));
gtk_menu_append(GTK_MENU(info->menu), menuitem);
gtk_widget_show(menuitem);
info->remove_item = menuitem;
menuitem = gtk_menu_item_new_with_label(_("Move applet"));
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) move_applet_callback,
ITOP(applet_id));
gtk_menu_append(GTK_MENU(applet_menu), menuitem);
ITOP(info->applet_id));
gtk_menu_append(GTK_MENU(info->menu), menuitem);
gtk_widget_show(menuitem);
if(user_menu) {
menuitem = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(applet_menu), menuitem);
gtk_menu_append(GTK_MENU(info->menu), menuitem);
gtk_widget_show(menuitem);
}
......@@ -470,11 +477,9 @@ create_applet_menu(gint applet_id, GList *user_menu)
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) applet_callback_callback,
menu);
gtk_menu_append(GTK_MENU(applet_menu), menuitem);
gtk_menu_append(GTK_MENU(info->menu), menuitem);
gtk_widget_show(menuitem);
}
return applet_menu;
}
static void
......@@ -541,7 +546,17 @@ show_applet_menu(gint applet_id)
g_return_if_fail(info!=NULL);
if (!info->menu)
info->menu = create_applet_menu(applet_id,info->user_menu);
create_applet_menu(info);
if((info->type == APPLET_DRAWER &&
panel_widget_get_applet_count(PANEL_WIDGET(info->assoc))>0) ||
(info->type == APPLET_MENU &&
main_menu_count <= 1 &&
(!info->params ||
strcmp(info->params,".")==0)))
gtk_widget_set_sensitive(info->remove_item,FALSE);
else
gtk_widget_set_sensitive(info->remove_item,TRUE);
gtk_menu_popup(GTK_MENU(info->menu), NULL, NULL, applet_menu_position,
ITOP(applet_id), 0/*3*/, time(NULL));
......@@ -586,7 +601,7 @@ applet_show_menu(gint applet_id)
g_return_if_fail(info != NULL);
if (!info->menu)
info->menu = create_applet_menu(applet_id,info->user_menu);
create_applet_menu(info);
if(!arrow)
arrow = gdk_cursor_new(GDK_ARROW);
......
......@@ -72,6 +72,7 @@ struct _AppletInfo {
GtkWidget *applet_widget; /*the actual applet widget*/
GtkWidget *assoc; /*associated widget, e.g. a drawer or a menu*/
GtkWidget *menu; /*the applet menu*/
GtkWidget *remove_item; /*remove item in the applet_menu*/
gpointer data;
gchar *id_str; /*used for IOR or string Id*/
gchar *cfg; /*used for passing around the per applet config path*/
......
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