Commit 8c723537 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

unified the "Panel" submenu in root menu and the right click submenu for

Mon Jul 27 03:38:22 1998  George Lebl  <jirka@5z.com>

        * menu.[ch],panel.c: unified the "Panel" submenu in root
          menu and the right click submenu for panels
parent 7870de70
Mon Jul 27 03:38:22 1998 George Lebl <jirka@5z.com>
* menu.[ch],panel.c: unified the "Panel" submenu in root
menu and the right click submenu for panels
Fri Jul 24 02:15:03 1998 George Lebl <jirka@5z.com>
* applet.[ch],panel.[ch]: moved panel menu creation to panel.c
......
Mon Jul 27 03:38:22 1998 George Lebl <jirka@5z.com>
* menu.[ch],panel.c: unified the "Panel" submenu in root
menu and the right click submenu for panels
Fri Jul 24 02:15:03 1998 George Lebl <jirka@5z.com>
* applet.[ch],panel.[ch]: moved panel menu creation to panel.c
......
......@@ -488,7 +488,7 @@ static GtkWidget * create_menu_at (GtkWidget *menu,
static GtkWidget *
check_and_reread(GtkWidget *menuw,Menu *menu,int main_menu)
{
/*we arecreating a whole new menuf or an applet if menu isn't NULL*/
/*we are creating a whole new menuf or an applet if menu isn't NULL*/
if(menu) {
GList *mfl = gtk_object_get_data(GTK_OBJECT(menuw), "mf");
GList *list;
......@@ -533,8 +533,8 @@ check_and_reread(GtkWidget *menuw,Menu *menu,int main_menu)
int need_reread = FALSE;
int all_fake = TRUE;
if(!mfl)
g_warning("Weird menu doesn't have mf entry");
/*if(!mfl)
g_warning("Weird menu doesn't have mf entry");*/
/*check if we need to reread this*/
for(list = mfl; list != NULL; list = g_list_next(list)) {
......@@ -1011,16 +1011,80 @@ create_add_panel_submenu (void)
}
static GtkWidget *
create_panel_submenu (GtkWidget *app_menu, GtkWidget *applet_menu)
create_system_app_menu(int fake_submenus)
{
GtkWidget *menu, *menuitem;
GtkWidget *sapp_menu;
char *menu_base = gnome_unconditional_datadir_file ("apps");
char *menudir;
menudir = g_concat_dir_and_file (menu_base, ".");
g_free (menu_base);
if (!g_file_exists (menudir)) {
g_free (menudir);
return NULL;
}
menu = gtk_menu_new ();
sapp_menu = create_menu_at (NULL,menudir,TRUE,FALSE,_("System Menus"),
fake_submenus);
g_return_val_if_fail(sapp_menu,NULL);
make_app_menu(sapp_menu, NULL, menudir, _("System Menus"));
g_free (menudir);
return sapp_menu;
}
static GtkWidget *
create_user_app_menu(int fake_submenus)
{
GtkWidget *uapp_menu=NULL;
char *menu_base = gnome_util_home_file ("apps");
char *menudir = g_concat_dir_and_file (menu_base, ".");
g_free (menu_base);
if (!g_file_exists (menudir))
mkdir (menudir, 0755);
if (g_file_exists (menudir)) {
uapp_menu = create_menu_at (NULL,menudir, TRUE,FALSE,
_("User Menus"),fake_submenus);
if(uapp_menu)
make_app_menu(uapp_menu, NULL,
menudir, _("User Menus"));
else
uapp_menu = create_fake_menu_at (menudir, TRUE,FALSE,
_("User Menus"));
}
g_free (menudir);
return uapp_menu;
}
static void
current_panel_config(GtkWidget *w, gpointer data)
{
GtkWidget *parent = gtk_object_get_data(GTK_OBJECT(current_panel),
PANEL_PARENT);
panel_config(parent);
}
void
make_panel_submenu (GtkWidget *menu, int fake_submenus)
{
GtkWidget *menuitem;
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("Add app to panel"));
setup_menuitem (menuitem, 0, _("Add app to panel (system menus)"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), app_menu);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
create_system_app_menu(fake_submenus));
gtk_signal_connect(GTK_OBJECT(menuitem),"select",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("Add app to panel (user menus)"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
create_user_app_menu(fake_submenus));
gtk_signal_connect(GTK_OBJECT(menuitem),"select",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
......@@ -1028,7 +1092,8 @@ create_panel_submenu (GtkWidget *app_menu, GtkWidget *applet_menu)
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("Add applet"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), applet_menu);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
create_applets_menu(fake_submenus));
gtk_signal_connect(GTK_OBJECT(menuitem),"select",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
......@@ -1045,14 +1110,14 @@ create_panel_submenu (GtkWidget *app_menu, GtkWidget *applet_menu)
setup_menuitem (menuitem, 0, _("Add main menu"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) add_menu_to_panel,
GTK_SIGNAL_FUNC(add_menu_to_panel),
NULL);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("Add log out button"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) add_logout_to_panel,
GTK_SIGNAL_FUNC(add_logout_to_panel),
NULL);
......@@ -1060,7 +1125,7 @@ create_panel_submenu (GtkWidget *app_menu, GtkWidget *applet_menu)
setup_menuitem (menuitem, 0, _("Add swallowed app"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) ask_about_swallowing,NULL);
GTK_SIGNAL_FUNC(ask_about_swallowing),NULL);
add_menu_separator(menu);
......@@ -1068,21 +1133,22 @@ create_panel_submenu (GtkWidget *app_menu, GtkWidget *applet_menu)
setup_menuitem (menuitem,
gnome_stock_pixmap_widget(menu,
GNOME_STOCK_PIXMAP_PREFERENCES),
_("Global properties..."));
_("This panel properties..."));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) panel_configure, 0);
GTK_SIGNAL_FUNC(current_panel_config),
NULL);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem,
gnome_stock_pixmap_widget(menu,
GNOME_STOCK_PIXMAP_ABOUT),
_("About..."));
GNOME_STOCK_PIXMAP_PREFERENCES),
_("Global properties..."));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) about_cb, 0);
GTK_SIGNAL_FUNC(panel_configure),
NULL);
return menu;
}
static void
......@@ -1092,25 +1158,21 @@ panel_lock (GtkWidget *widget, void *data)
}
static void
panel_logout (GtkWidget *widget, void *data)
{
panel_quit();
}
static void
add_special_entries (GtkWidget *menu, GtkWidget *app_menu, GtkWidget *applet_menu)
add_special_entries (GtkWidget *menu, int fake_submenus)
{
GtkWidget *menuitem;
GtkWidget *panel_menu;
/* Panel entry */
add_menu_separator (menu);
panel_menu = gtk_menu_new();
make_panel_submenu(panel_menu,fake_submenus);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("Panel"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
create_panel_submenu (app_menu,applet_menu));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),panel_menu);
add_menu_separator (menu);
......@@ -1120,6 +1182,16 @@ add_special_entries (GtkWidget *menu, GtkWidget *app_menu, GtkWidget *applet_men
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(panel_lock), 0);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem,
gnome_stock_pixmap_widget(menu,
GNOME_STOCK_PIXMAP_ABOUT),
_("About..."));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(about_cb),
NULL);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem,
gnome_stock_pixmap_widget(menu,
......@@ -1127,7 +1199,7 @@ add_special_entries (GtkWidget *menu, GtkWidget *app_menu, GtkWidget *applet_men
_("Log out"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(panel_logout), 0);
GTK_SIGNAL_FUNC(panel_quit), 0);
}
......@@ -1136,10 +1208,6 @@ create_root_menu(int fake_submenus, MainMenuType type)
{
GtkWidget *root_menu;
GtkWidget *uroot_menu;
GtkWidget *app_menu;
GtkWidget *uapp_menu=NULL;
GtkWidget *sapp_menu;
GtkWidget *applet_menu;
char *menu_base = gnome_unconditional_datadir_file ("apps");
char *menudir;
char *user_menudir;
......@@ -1149,15 +1217,11 @@ create_root_menu(int fake_submenus, MainMenuType type)
g_free (menu_base);
if (!g_file_exists (menudir)) {
g_free (menudir);
return;
return NULL;
}
root_menu = create_menu_at(NULL,menudir,FALSE,FALSE,NULL,fake_submenus);
g_return_val_if_fail(root_menu,NULL);
sapp_menu = create_menu_at (NULL,menudir,TRUE,FALSE,_("System Menus"),
fake_submenus);
g_return_val_if_fail(sapp_menu,NULL);
make_app_menu(sapp_menu, NULL, menudir, _("System Menus"));
g_free (menudir);
menu_base = gnome_util_home_file ("apps");
......@@ -1172,11 +1236,6 @@ create_root_menu(int fake_submenus, MainMenuType type)
else
uroot_menu = create_menu_at(NULL,menudir,FALSE,FALSE,
NULL,fake_submenus);
uapp_menu = create_menu_at (NULL,menudir, TRUE,FALSE,
_("User Menus"),fake_submenus);
if(uapp_menu)
make_app_menu(uapp_menu, NULL,
menudir, _("User Menus"));
} else if(type != MAIN_MENU_BOTH)
uroot_menu = gtk_menu_new();
g_free (menudir);
......@@ -1204,30 +1263,7 @@ create_root_menu(int fake_submenus, MainMenuType type)
NULL);
}
if(uapp_menu) {
GtkWidget *menuitem;
app_menu = gtk_menu_new();
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("System Menus"));
gtk_menu_append (GTK_MENU (app_menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
sapp_menu);
gtk_signal_connect(GTK_OBJECT(menuitem),"select",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, 0, _("User Menus"));
gtk_menu_append (GTK_MENU (app_menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
uapp_menu);
gtk_signal_connect(GTK_OBJECT(menuitem),"select",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
} else
app_menu = sapp_menu;
applet_menu = create_applets_menu(FALSE);
add_special_entries (root_menu, app_menu, applet_menu);
add_special_entries (root_menu, fake_submenus);
return root_menu;
......@@ -1423,10 +1459,7 @@ static void
set_show_small_icons_foreach(gpointer data, gpointer user_data)
{
GtkWidget *w = data;
if (!w) {
g_warning("Internal error in set_show_small_icons_foreach (!w)");
return;
}
g_return_if_fail(w);
if (global_config.show_small_icons)
gtk_widget_show(w);
else
......
......@@ -28,6 +28,7 @@ void set_menu_applet_orient(Menu *menu, PanelOrientType orient);
void set_show_small_icons(void);
void setup_menuitem (GtkWidget *menuitem, GtkWidget *pixmap, char *title);
void make_panel_submenu (GtkWidget *menu, int fake_submenus);
END_GNOME_DECLS
......
......@@ -47,6 +47,11 @@ extern GnomeClient *client;
extern GlobalConfig global_config;
/*???? this might be ugly, but I guess we can safely assume that we can only
have one menu open and that nothing weird will happen to the panel that
opened that menu whilethe user is looking over the choices*/
extern PanelWidget *current_panel;
/*a list of started extern applet child processes*/
extern GList * children;
......@@ -66,49 +71,29 @@ create_panel_root_menu(GtkWidget *panel)
panel_menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label(_("This panel properties..."));
gtk_signal_connect_object(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(panel_config),
GTK_OBJECT(panel));
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
make_panel_submenu(panel_menu,TRUE);
menuitem = gtk_menu_item_new_with_label(_("Global properties..."));
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(panel_config_global),
NULL);
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label(_("Remove this panel"));
gtk_signal_connect_object(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(gtk_widget_destroy),
GTK_OBJECT(panel));
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem, NULL, _("Remove this panel"));
gtk_menu_append (GTK_MENU (panel_menu), menuitem);
gtk_signal_connect_object (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(gtk_widget_destroy),
GTK_OBJECT(panel));
gtk_object_set_data(GTK_OBJECT(panel),"remove_item",menuitem);
menuitem = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label(_("Add main menu applet"));
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(panel_add_main_menu),
panel);
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label(_("Log out"));
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(panel_quit),
NULL);
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new ();
setup_menuitem (menuitem,
gnome_stock_pixmap_widget(panel_menu,
GNOME_STOCK_PIXMAP_QUIT),
_("Log out"));
gtk_menu_append (GTK_MENU (panel_menu), menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(panel_quit),
NULL);
return panel_menu;
}
......@@ -867,7 +852,7 @@ panel_event(GtkWidget *widget, GdkEvent *event, gpointer data)
if(IS_SNAPPED_WIDGET(widget)) {
SnappedWidget *snapped =
SNAPPED_WIDGET(widget);
PanelWidget *panel =
current_panel =
PANEL_WIDGET(snapped->panel);
if(base_panels <= 1)
gtk_widget_set_sensitive(rem,
......@@ -880,16 +865,21 @@ panel_event(GtkWidget *widget, GdkEvent *event, gpointer data)
} else if(IS_CORNER_WIDGET(widget)) {
CornerWidget *corner =
CORNER_WIDGET(widget);
PanelWidget *panel = PANEL_WIDGET(corner->panel);
current_panel = PANEL_WIDGET(corner->panel);
if(base_panels <= 1)
gtk_widget_set_sensitive(rem,
FALSE);
else
gtk_widget_set_sensitive(rem,
TRUE);
} else if(IS_DRAWER_WIDGET(widget)) {
DrawerWidget *drawer =
DRAWER_WIDGET(widget);
current_panel = PANEL_WIDGET(drawer->panel);
gtk_widget_set_sensitive(rem, TRUE);
} else
gtk_widget_set_sensitive(rem,
TRUE);
gtk_widget_set_sensitive(rem,
TRUE);
gtk_menu_popup(GTK_MENU(data), NULL, NULL,
panel_menu_position,
widget, bevent->button,
......
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