Commit f68fc88d authored by Martin Baulig's avatar Martin Baulig Committed by Martin Baulig

Improved handling of distribution specific menus.

2000-04-24  Martin Baulig  <baulig@suse.de>

	Improved handling of distribution specific menus.

	Rather than providing code for RH and Debian menus, we now
	have some generic "distribution menu" code - all customizing
	is done in a `DistributionInfo' array in distribution.c.

	This makes it very easy for distribution vendors to add a
	custom menu for their distribution (like the already existent
	AnotherLevel and Debian menus) with a about-10-line-change
	in a single source file.

	* distribution.h: New file.
	(DistributionType): Contains all possible Linux distributions.
	(DistributionInfo): New struct type containing info about
	distribution specific menus.

	* distribution.c: New file.
	(get_distribution): New global function; returns the current
	Linux distribution as a `DistributionType'.
	(get_distribution_info): New global global function; takes a
	`DistributionType' argument and returns a `DistributionInfo *',
	this struct contains information about distribution specific
	menus.

	* menu.h (MAIN_MENU_REDHAT): Renamed to `MAIN_MENU_DISTRIBUTION'.
	(MAIN_MENU_REDHAT_SUB): Renamed to `MAIN_MENU_DISTRIBUTION_SUB'.
	(MAIN_MENU_DEBIAN, MAIN_MENU_DEBIAN_SUB): Removed (replaced with
	`MAIN_MENU_OBSOLETE_DEBIAN' and `MAIN_MENU_OBSOLETE_DEBIAN_SUB'
	for compatibility with old config files).
	(DEBIAN_MENUDIR): Removed.

	* session.c (init_user_applets): Use the new distribution menu
	rather than the old RH and Debian menus.

	* panel.c (drop_menu): Don't check for "/etc/X11/wmconfig" etc.,
	but use the new get_distribution () function to get the
	current distribution.

	* menu.c (init_menus): Use the new get_distribution () function
	and run the `distribution_info->menu_init_func' hook if it
	exists.
	(setup_menuitem_try_pixmap): Allow the "try_file" to be NULL.
	(create_distribution_menu): New function. This replaces the
	old create_debian_menu () function but is now distribution
	independent.
	(create_debian_menu): Removed.
	(create_root_menu): Use the new distribution menus.
parent 9db04b79
2000-04-24 Martin Baulig <baulig@suse.de>
Improved handling of distribution specific menus.
Rather than providing code for RH and Debian menus, we now
have some generic "distribution menu" code - all customizing
is done in a `DistributionInfo' array in distribution.c.
This makes it very easy for distribution vendors to add a
custom menu for their distribution (like the already existent
AnotherLevel and Debian menus) with a about-10-line-change
in a single source file.
* distribution.h: New file.
(DistributionType): Contains all possible Linux distributions.
(DistributionInfo): New struct type containing info about
distribution specific menus.
* distribution.c: New file.
(get_distribution): New global function; returns the current
Linux distribution as a `DistributionType'.
(get_distribution_info): New global global function; takes a
`DistributionType' argument and returns a `DistributionInfo *',
this struct contains information about distribution specific
menus.
* menu.h (MAIN_MENU_REDHAT): Renamed to `MAIN_MENU_DISTRIBUTION'.
(MAIN_MENU_REDHAT_SUB): Renamed to `MAIN_MENU_DISTRIBUTION_SUB'.
(MAIN_MENU_DEBIAN, MAIN_MENU_DEBIAN_SUB): Removed (replaced with
`MAIN_MENU_OBSOLETE_DEBIAN' and `MAIN_MENU_OBSOLETE_DEBIAN_SUB'
for compatibility with old config files).
(DEBIAN_MENUDIR): Removed.
* session.c (init_user_applets): Use the new distribution menu
rather than the old RH and Debian menus.
* panel.c (drop_menu): Don't check for "/etc/X11/wmconfig" etc.,
but use the new get_distribution () function to get the
current distribution.
* menu.c (init_menus): Use the new get_distribution () function
and run the `distribution_info->menu_init_func' hook if it
exists.
(setup_menuitem_try_pixmap): Allow the "try_file" to be NULL.
(create_distribution_menu): New function. This replaces the
old create_debian_menu () function but is now distribution
independent.
(create_debian_menu): Removed.
(create_root_menu): Use the new distribution menus.
Thu Jun 15 22:18:15 2000 George Lebl <jirka@5z.com>
* button-widget.c: make the previous fix work well with autohidden
......
2000-04-24 Martin Baulig <baulig@suse.de>
Improved handling of distribution specific menus.
Rather than providing code for RH and Debian menus, we now
have some generic "distribution menu" code - all customizing
is done in a `DistributionInfo' array in distribution.c.
This makes it very easy for distribution vendors to add a
custom menu for their distribution (like the already existent
AnotherLevel and Debian menus) with a about-10-line-change
in a single source file.
* distribution.h: New file.
(DistributionType): Contains all possible Linux distributions.
(DistributionInfo): New struct type containing info about
distribution specific menus.
* distribution.c: New file.
(get_distribution): New global function; returns the current
Linux distribution as a `DistributionType'.
(get_distribution_info): New global global function; takes a
`DistributionType' argument and returns a `DistributionInfo *',
this struct contains information about distribution specific
menus.
* menu.h (MAIN_MENU_REDHAT): Renamed to `MAIN_MENU_DISTRIBUTION'.
(MAIN_MENU_REDHAT_SUB): Renamed to `MAIN_MENU_DISTRIBUTION_SUB'.
(MAIN_MENU_DEBIAN, MAIN_MENU_DEBIAN_SUB): Removed (replaced with
`MAIN_MENU_OBSOLETE_DEBIAN' and `MAIN_MENU_OBSOLETE_DEBIAN_SUB'
for compatibility with old config files).
(DEBIAN_MENUDIR): Removed.
* session.c (init_user_applets): Use the new distribution menu
rather than the old RH and Debian menus.
* panel.c (drop_menu): Don't check for "/etc/X11/wmconfig" etc.,
but use the new get_distribution () function to get the
current distribution.
* menu.c (init_menus): Use the new get_distribution () function
and run the `distribution_info->menu_init_func' hook if it
exists.
(setup_menuitem_try_pixmap): Allow the "try_file" to be NULL.
(create_distribution_menu): New function. This replaces the
old create_debian_menu () function but is now distribution
independent.
(create_debian_menu): Removed.
(create_root_menu): Use the new distribution menus.
Thu Jun 15 22:18:15 2000 George Lebl <jirka@5z.com>
* button-widget.c: make the previous fix work well with autohidden
......
......@@ -13,6 +13,7 @@ INCLUDES = -I. -I$(srcdir) \
-I$(top_builddir)/intl \
-I$(top_builddir)/panel \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGNOME_DATADIR=\""$(datadir)"\" \
-I$(includedir) $(GNOME_INCLUDEDIR) $(ORB_CFLAGS) \
@PIXBUF_CFLAGS@
......@@ -83,6 +84,8 @@ panel_SOURCES=\
panel_config.c \
panel_config.h \
panel_config_global.h \
distribution.c \
distribution.h \
menu.c \
menu.h \
menu-fentry.c \
......
/*
* GNOME panel linux distribution module.
* (C) 2000 The Free Software Foundation
*
* Authors: Martin Baulig <baulig@suse.de>
*/
#include <config.h>
#include <gnome.h>
#include "panel-include.h"
/* Note for distribution vendors:
*
* This file - especially the `distribution_info' array - is
* the only place which you need to custumize in order to make
* the `Distribution' menu in the panel working.
*
*/
static void rh_menu_init_func (void);
static void rh_menu_show_func (GtkWidget *, GtkMenuItem *);
DistributionInfo distribution_info [] = {
{ DISTRIBUTION_DEBIAN, "/etc/debian_version",
N_("Debian GNU/Linux"), N_("Debian menus"),
"gnome-debian.png", "/var/lib/gnome/Debian/.",
NULL, NULL
},
{ DISTRIBUTION_REDHAT, "/etc/redhat-release",
N_("Red Hat Linux"), N_("Red Hat menus"), NULL,
"apps-redhat",
rh_menu_init_func, rh_menu_show_func
},
{ DISTRIBUTION_SUSE, "/etc/SuSE-release",
N_("SuSE Linux"), N_("SuSE menus"), "gnome-suse.png",
GNOME_DATADIR "/gnome/distribution-menus/SuSE/.",
NULL, NULL
},
{ DISTRIBUTION_UNKNOWN, NULL, NULL, NULL, NULL }
};
DistributionType
get_distribution (void)
{
DistributionInfo *ptr;
for (ptr = distribution_info; ptr->type != DISTRIBUTION_UNKNOWN; ptr++)
if (g_file_exists (ptr->version_file))
return ptr->type;
return DISTRIBUTION_UNKNOWN;
}
const DistributionInfo *
get_distribution_info (DistributionType type)
{
DistributionInfo *ptr;
for (ptr = distribution_info; ptr->type != DISTRIBUTION_UNKNOWN; ptr++)
if (ptr->type == type)
return ptr;
return NULL;
}
/*
* Distribution specific menu functions.
*/
static void
rh_menu_init_func (void)
{
/* Use the fork version to create the Red Hat menus. */
create_rh_menu (TRUE);
}
static void
rh_menu_show_func (GtkWidget *menuw, GtkMenuItem *menuitem)
{
rh_submenu_to_display (menuw, menuitem);
}
#ifndef DISTRIBUTION_H
#define DISTRIBUTION_H
#include <panel-widget.h>
#include "applet.h"
BEGIN_GNOME_DECLS
typedef enum {
DISTRIBUTION_UNKNOWN = 0,
DISTRIBUTION_DEBIAN,
DISTRIBUTION_MANDRAKE,
DISTRIBUTION_SUSE,
DISTRIBUTION_REDHAT
} DistributionType;
typedef struct {
DistributionType type;
const gchar *version_file;
const gchar *distribution_name;
const gchar *menu_name;
const gchar *menu_icon;
const gchar *menu_path;
void (*menu_init_func) (void);
void (*menu_show_func) (GtkWidget *, GtkMenuItem *);
} DistributionInfo;
/* Distribution description array. */
extern DistributionInfo distribution_info [];
/* Get distribution type. */
DistributionType get_distribution (void);
/* Get info about a distribution or NULL. */
const DistributionInfo *get_distribution_info (DistributionType type);
END_GNOME_DECLS
#endif
......@@ -106,14 +106,13 @@ typedef struct {
/* don't forget to update the table size when changing the num of elements
in this array */
static MenuOptions menu_options[] = {
{ MAIN_MENU_SYSTEM, MAIN_MENU_SYSTEM_SUB, N_("Programs: ") },
{ MAIN_MENU_USER, MAIN_MENU_USER_SUB, N_("Favorites: ") },
{ MAIN_MENU_APPLETS, MAIN_MENU_APPLETS_SUB, N_("Applets: ") },
{ MAIN_MENU_REDHAT, MAIN_MENU_REDHAT_SUB, N_("AnotherLevel: ") },
{ MAIN_MENU_KDE, MAIN_MENU_KDE_SUB, N_("KDE: ") },
{ MAIN_MENU_DEBIAN, MAIN_MENU_DEBIAN_SUB, N_("Debian: ") },
{ MAIN_MENU_PANEL, MAIN_MENU_PANEL_SUB, N_("Panel: ") },
{ MAIN_MENU_DESKTOP, MAIN_MENU_DESKTOP_SUB, N_("Desktop: ") },
{ MAIN_MENU_SYSTEM, MAIN_MENU_SYSTEM_SUB, N_("Programs: ") },
{ MAIN_MENU_USER, MAIN_MENU_USER_SUB, N_("Favorites: ") },
{ MAIN_MENU_APPLETS, MAIN_MENU_APPLETS_SUB, N_("Applets: ") },
{ MAIN_MENU_DISTRIBUTION, MAIN_MENU_DISTRIBUTION_SUB, N_("Distribution: ") },
{ MAIN_MENU_KDE, MAIN_MENU_KDE_SUB, N_("KDE: ") },
{ MAIN_MENU_PANEL, MAIN_MENU_PANEL_SUB, N_("Panel: ") },
{ MAIN_MENU_DESKTOP, MAIN_MENU_DESKTOP_SUB, N_("Desktop: ") },
{ 0 }
};
......@@ -1108,9 +1107,8 @@ loadup_vals(void)
g_string_sprintf(buf,"menu_flags=%d",
(int)(MAIN_MENU_SYSTEM_SUB | MAIN_MENU_USER_SUB|
MAIN_MENU_APPLETS_SUB | MAIN_MENU_REDHAT_SUB|
MAIN_MENU_DEBIAN_SUB | MAIN_MENU_KDE_SUB|
MAIN_MENU_PANEL | MAIN_MENU_DESKTOP));
MAIN_MENU_APPLETS_SUB | MAIN_MENU_DISTRIBUTION_SUB|
MAIN_MENU_KDE_SUB | MAIN_MENU_PANEL | MAIN_MENU_DESKTOP));
global_config.menu_flags = gnome_config_get_int(buf->str);
global_config.keys_enabled = gnome_config_get_bool("keys_enabled=TRUE");
......
......@@ -106,14 +106,13 @@ typedef struct {
/* don't forget to update the table size when changing the num of elements
in this array */
static MenuOptions menu_options[] = {
{ MAIN_MENU_SYSTEM, MAIN_MENU_SYSTEM_SUB, N_("Programs: ") },
{ MAIN_MENU_USER, MAIN_MENU_USER_SUB, N_("Favorites: ") },
{ MAIN_MENU_APPLETS, MAIN_MENU_APPLETS_SUB, N_("Applets: ") },
{ MAIN_MENU_REDHAT, MAIN_MENU_REDHAT_SUB, N_("AnotherLevel: ") },
{ MAIN_MENU_KDE, MAIN_MENU_KDE_SUB, N_("KDE: ") },
{ MAIN_MENU_DEBIAN, MAIN_MENU_DEBIAN_SUB, N_("Debian: ") },
{ MAIN_MENU_PANEL, MAIN_MENU_PANEL_SUB, N_("Panel: ") },
{ MAIN_MENU_DESKTOP, MAIN_MENU_DESKTOP_SUB, N_("Desktop: ") },
{ MAIN_MENU_SYSTEM, MAIN_MENU_SYSTEM_SUB, N_("Programs: ") },
{ MAIN_MENU_USER, MAIN_MENU_USER_SUB, N_("Favorites: ") },
{ MAIN_MENU_APPLETS, MAIN_MENU_APPLETS_SUB, N_("Applets: ") },
{ MAIN_MENU_DISTRIBUTION, MAIN_MENU_DISTRIBUTION_SUB, N_("Distribution: ") },
{ MAIN_MENU_KDE, MAIN_MENU_KDE_SUB, N_("KDE: ") },
{ MAIN_MENU_PANEL, MAIN_MENU_PANEL_SUB, N_("Panel: ") },
{ MAIN_MENU_DESKTOP, MAIN_MENU_DESKTOP_SUB, N_("Desktop: ") },
{ 0 }
};
......@@ -1108,9 +1107,8 @@ loadup_vals(void)
g_string_sprintf(buf,"menu_flags=%d",
(int)(MAIN_MENU_SYSTEM_SUB | MAIN_MENU_USER_SUB|
MAIN_MENU_APPLETS_SUB | MAIN_MENU_REDHAT_SUB|
MAIN_MENU_DEBIAN_SUB | MAIN_MENU_KDE_SUB|
MAIN_MENU_PANEL | MAIN_MENU_DESKTOP));
MAIN_MENU_APPLETS_SUB | MAIN_MENU_DISTRIBUTION_SUB|
MAIN_MENU_KDE_SUB | MAIN_MENU_PANEL | MAIN_MENU_DESKTOP));
global_config.menu_flags = gnome_config_get_int(buf->str);
global_config.keys_enabled = gnome_config_get_bool("keys_enabled=TRUE");
......
......@@ -97,12 +97,10 @@ properties_apply_callback(GtkWidget *widget, int page, gpointer data)
GtkWidget *user_sub = gtk_object_get_data(GTK_OBJECT(widget), "user_sub");
GtkWidget *applets = gtk_object_get_data(GTK_OBJECT(widget), "applets");
GtkWidget *applets_sub = gtk_object_get_data(GTK_OBJECT(widget), "applets_sub");
GtkWidget *redhat = gtk_object_get_data(GTK_OBJECT(widget), "redhat");
GtkWidget *redhat_sub = gtk_object_get_data(GTK_OBJECT(widget), "redhat_sub");
GtkWidget *distribution = gtk_object_get_data(GTK_OBJECT(widget), "distribution");
GtkWidget *distribution_sub = gtk_object_get_data(GTK_OBJECT(widget), "distribution_sub");
GtkWidget *kde = gtk_object_get_data(GTK_OBJECT(widget), "kde");
GtkWidget *kde_sub = gtk_object_get_data(GTK_OBJECT(widget), "kde_sub");
GtkWidget *debian = gtk_object_get_data(GTK_OBJECT(widget), "debian");
GtkWidget *debian_sub = gtk_object_get_data(GTK_OBJECT(widget), "debian_sub");
GtkWidget *panel = gtk_object_get_data(GTK_OBJECT(widget), "panel");
GtkWidget *panel_sub = gtk_object_get_data(GTK_OBJECT(widget), "panel_sub");
......@@ -155,15 +153,10 @@ properties_apply_callback(GtkWidget *widget, int page, gpointer data)
else if (GTK_TOGGLE_BUTTON (applets)->active)
menu->main_menu_flags |= MAIN_MENU_APPLETS;
if(GTK_TOGGLE_BUTTON(redhat_sub)->active)
menu->main_menu_flags |= MAIN_MENU_REDHAT_SUB;
else if (GTK_TOGGLE_BUTTON (redhat)->active)
menu->main_menu_flags |= MAIN_MENU_REDHAT;
if(GTK_TOGGLE_BUTTON(debian_sub)->active)
menu->main_menu_flags |= MAIN_MENU_DEBIAN_SUB;
else if (GTK_TOGGLE_BUTTON (debian)->active)
menu->main_menu_flags |= MAIN_MENU_DEBIAN;
if(GTK_TOGGLE_BUTTON(distribution_sub)->active)
menu->main_menu_flags |= MAIN_MENU_DISTRIBUTION_SUB;
else if (GTK_TOGGLE_BUTTON (distribution)->active)
menu->main_menu_flags |= MAIN_MENU_DISTRIBUTION;
if(GTK_TOGGLE_BUTTON(kde_sub)->active)
menu->main_menu_flags |= MAIN_MENU_KDE_SUB;
......@@ -371,17 +364,13 @@ create_properties_dialog(Menu *menu)
menu->main_menu_flags&MAIN_MENU_APPLETS,
menu->main_menu_flags&MAIN_MENU_APPLETS_SUB);
add_menu_type_options(GTK_OBJECT(dialog),GTK_TABLE(table),3,
_("AnotherLevel menu (if found): "),"redhat",
menu->main_menu_flags&MAIN_MENU_REDHAT,
menu->main_menu_flags&MAIN_MENU_REDHAT_SUB);
_("Distribution menu (if found): "),"distribution",
menu->main_menu_flags&MAIN_MENU_DISTRIBUTION,
menu->main_menu_flags&MAIN_MENU_DISTRIBUTION_SUB);
add_menu_type_options(GTK_OBJECT(dialog),GTK_TABLE(table),4,
_("KDE menu (if found): "),"kde",
menu->main_menu_flags&MAIN_MENU_KDE,
menu->main_menu_flags&MAIN_MENU_KDE_SUB);
add_menu_type_options(GTK_OBJECT(dialog),GTK_TABLE(table),5,
_("Debian menu (if found): "),"debian",
menu->main_menu_flags&MAIN_MENU_DEBIAN,
menu->main_menu_flags&MAIN_MENU_DEBIAN_SUB);
add_menu_type_options(GTK_OBJECT(dialog),GTK_TABLE(table),6,
_("Panel menu: "),"panel",
menu->main_menu_flags&MAIN_MENU_PANEL,
......
......@@ -93,21 +93,18 @@ applet_menu_position (GtkMenu *menu, gint *x, gint *y, gpointer data)
int
get_default_menu_flags ()
{
DistributionType distribution = get_distribution();
int flags = MAIN_MENU_SYSTEM_SUB | MAIN_MENU_USER_SUB |
MAIN_MENU_APPLETS_SUB | MAIN_MENU_PANEL_SUB |
MAIN_MENU_DESKTOP;
/*guess redhat menus*/
if(g_file_exists(REDHAT_MENUDIR))
flags |= MAIN_MENU_REDHAT_SUB;
/*guess distribution menus*/
if(distribution != DISTRIBUTION_UNKNOWN)
flags |= MAIN_MENU_DISTRIBUTION_SUB;
/*guess KDE menus*/
if(g_file_exists(kde_menudir))
flags |= MAIN_MENU_KDE_SUB;
/*guess debian menus*/
if (g_file_exists(DEBIAN_MENUDIR))
flags |= MAIN_MENU_DEBIAN_SUB;
return flags;
}
......@@ -79,6 +79,9 @@ static GSList *tearoffs = NULL;
void
init_menus(void)
{
DistributionType distribution = get_distribution ();
const DistributionInfo *distribution_info = get_distribution_info (distribution);
/*just load the menus from disk, don't make the widgets
this just reads the .desktops of the top most directory
and a level down*/
......@@ -94,9 +97,9 @@ init_menus(void)
if(menu)
fr_read_dir(NULL,menu,NULL,2);
g_free(menu);
/*if redhat menus, use the fork version to read*/
if(g_file_exists(REDHAT_MENUDIR))
create_rh_menu(TRUE);
if(distribution_info && distribution_info->menu_init_func)
distribution_info->menu_init_func ();
}
/*the most important dialog in the whole application*/
......@@ -879,22 +882,19 @@ add_menu_to_panel (GtkWidget *widget, gpointer data)
{
char *menudir = data;
PanelWidget *panel;
DistributionType distribution = get_distribution ();
int flags = MAIN_MENU_SYSTEM_SUB | MAIN_MENU_USER_SUB |
MAIN_MENU_APPLETS_SUB | MAIN_MENU_PANEL_SUB |
MAIN_MENU_DESKTOP_SUB;
/*guess redhat menus*/
if (g_file_exists(REDHAT_MENUDIR))
flags |= MAIN_MENU_REDHAT_SUB;
/*guess distribution menus*/
if (distribution != DISTRIBUTION_UNKNOWN)
flags |= MAIN_MENU_DISTRIBUTION_SUB;
/*guess KDE menus*/
if(g_file_exists(kde_menudir))
flags |= MAIN_MENU_KDE_SUB;
/*guess debian menus*/
if (g_file_exists(DEBIAN_MENUDIR))
flags |= MAIN_MENU_DEBIAN_SUB;
panel = get_panel_from_menu_data (widget);
load_menu_applet (menudir, flags, panel, 0, FALSE);
......@@ -2721,18 +2721,22 @@ static void
setup_menuitem_try_pixmap (GtkWidget *menuitem, char *try_file,
char *title, int icon_size)
{
char *file;
char *file = NULL;
if (!gnome_preferences_get_menus_have_icons ()) {
setup_menuitem (menuitem, NULL, title);
return;
}
if (try_file) {
file = gnome_pixmap_file (try_file);
if (!file)
g_warning (_("Cannot find pixmap file %s"), try_file);
}
file = gnome_pixmap_file (try_file);
if (!file) {
g_message (_("Cannot find pixmap file %s"), try_file);
if (!file)
setup_menuitem (menuitem, NULL, title);
} else
else
setup_menuitem_with_size (menuitem,
fake_pixmap_at_size(file, icon_size),
title, icon_size);
......@@ -2800,19 +2804,37 @@ create_user_menu(char *title, char *dir, GtkWidget *menu, char *pixmap,
}
static GtkWidget *
create_debian_menu(GtkWidget *menu, gboolean fake_submenus, gboolean fake,
gboolean title)
create_distribution_menu(GtkWidget *menu, gboolean fake_submenus, gboolean fake,
gboolean title)
{
DistributionType distribution = get_distribution ();
const DistributionInfo *info = get_distribution_info (distribution);
gchar *pixmap_file = NULL, *menu_path;
if (!info)
return NULL;
if (info->menu_icon)
pixmap_file = gnome_pixmap_file (info->menu_icon);
if (info->menu_path [0] != '/')
menu_path = gnome_util_home_file (info->menu_path);
else
menu_path = g_strdup (info->menu_path);
if (!fake || menu) {
menu = create_menu_at (menu, DEBIAN_MENUDIR, FALSE,
_("Debian menus"), "gnome-debian.png",
menu = create_menu_at (menu, menu_path, FALSE,
info->menu_name, pixmap_file,
fake_submenus, FALSE, title);
} else {
menu = create_fake_menu_at (DEBIAN_MENUDIR, FALSE,
_("Debian menus"),
"gnome-debian.png", title);
menu = create_fake_menu_at (menu_path, FALSE,
info->menu_name, pixmap_file,
title);
}
g_free (pixmap_file);
g_free (menu_path);
return menu;
}
......@@ -4106,19 +4128,18 @@ create_root_menu(GtkWidget *root_menu,
GtkWidget *menu;
GtkWidget *menuitem;
DistributionType distribution = get_distribution ();
const DistributionInfo *distribution_info = get_distribution_info (distribution);
gboolean has_inline = (flags & (MAIN_MENU_SYSTEM |
MAIN_MENU_USER |
MAIN_MENU_APPLETS |
MAIN_MENU_KDE |
MAIN_MENU_REDHAT |
MAIN_MENU_DEBIAN));
MAIN_MENU_KDE));
gboolean has_subs = (flags & (MAIN_MENU_SYSTEM_SUB |
MAIN_MENU_USER_SUB |
MAIN_MENU_APPLETS_SUB |
MAIN_MENU_KDE_SUB |
MAIN_MENU_REDHAT_SUB |
MAIN_MENU_DEBIAN_SUB));
MAIN_MENU_KDE_SUB));
gboolean has_inline2 = (flags & (MAIN_MENU_DESKTOP |
MAIN_MENU_PANEL));
......@@ -4128,6 +4149,12 @@ create_root_menu(GtkWidget *root_menu,
IconSize size = global_config.use_large_icons
? MEDIUM_ICON_SIZE : SMALL_ICON_SIZE;
if (distribution_info) {
has_inline |= (flags & (MAIN_MENU_DISTRIBUTION));
has_subs |= (flags & (MAIN_MENU_DISTRIBUTION_SUB));
}
if(!root_menu)
root_menu = menu_new ();
if (tearoff && gnome_preferences_get_menus_have_tearoff ()) {
......@@ -4148,15 +4175,12 @@ create_root_menu(GtkWidget *root_menu,
if (flags & MAIN_MENU_APPLETS)
create_applets_menu(root_menu, fake_submenus, title);
if (flags & MAIN_MENU_REDHAT) {
rh_submenu_to_display(NULL,NULL);
create_user_menu(_("AnotherLevel menus"), "apps-redhat",
root_menu, NULL, fake_submenus, FALSE,
FALSE, title);
}
if (flags & MAIN_MENU_DISTRIBUTION) {
if (distribution_info->menu_show_func)
distribution_info->menu_show_func(NULL,NULL);
if (flags & MAIN_MENU_DEBIAN)
create_debian_menu(root_menu, fake_submenus, FALSE, title);
create_distribution_menu(root_menu, fake_submenus, FALSE, title);
}
if (flags & MAIN_MENU_KDE)
create_kde_menu(root_menu, fake_submenus, FALSE, FALSE, title);
......@@ -4198,7 +4222,7 @@ create_root_menu(GtkWidget *root_menu,
NULL);
}
if (flags & MAIN_MENU_APPLETS_SUB) {
menu = create_applets_menu(NULL, fake_submenus, TRUE);
menu = create_applets_menu(NULL, fake_submenus, FALSE);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
setup_menuitem_try_pixmap (menuitem, "gnome-applets.png",
......@@ -4209,38 +4233,25 @@ create_root_menu(GtkWidget *root_menu,
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
}
if (flags & MAIN_MENU_REDHAT_SUB) {
menu = create_user_menu(_("AnotherLevel menus"), "apps-redhat",
NULL, NULL, fake_submenus, TRUE, TRUE,
TRUE);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
setup_menuitem_with_size (menuitem, NULL,
_("AnotherLevel menus"),
size);
gtk_menu_append (GTK_MENU (root_menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
gtk_signal_connect(GTK_OBJECT(menu),"show",
GTK_SIGNAL_FUNC(rh_submenu_to_display),
menuitem);
gtk_signal_connect(GTK_OBJECT(menu),"show",
GTK_SIGNAL_FUNC(submenu_to_display), NULL);
}
if (flags & MAIN_MENU_DEBIAN_SUB) {
menu = create_debian_menu(NULL, fake_submenus, TRUE, TRUE);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
setup_menuitem_try_pixmap (menuitem,
"gnome-debian.png",
_("Debian menus"), size);
gtk_menu_append (GTK_MENU (root_menu), menuitem);
if(menu) {
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
menu);
if (flags & MAIN_MENU_DISTRIBUTION_SUB) {
g_assert (distribution_info != NULL);
menu = create_distribution_menu(NULL, fake_submenus, TRUE, TRUE);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
setup_menuitem_try_pixmap (menuitem,
(gchar*) distribution_info->menu_icon,
_(distribution_info->menu_name), size);
gtk_menu_append (GTK_MENU (root_menu), menuitem);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
menu);
if (distribution_info->menu_show_func)
gtk_signal_connect(GTK_OBJECT(menu),"show",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
}
GTK_SIGNAL_FUNC(distribution_info->menu_show_func),
menuitem);
gtk_signal_connect(GTK_OBJECT(menu),"show",
GTK_SIGNAL_FUNC(submenu_to_display),
NULL);
}
if (flags & MAIN_MENU_KDE_SUB) {
GtkWidget *pixmap = NULL;
......@@ -4382,9 +4393,10 @@ menu_button_pressed(GtkWidget *widget, gpointer data)
g_slist_free(list);
} else {
if(menu->main_menu_flags&MAIN_MENU_REDHAT &&
!(menu->main_menu_flags&MAIN_MENU_REDHAT_SUB))
rh_submenu_to_display(NULL,NULL);
if(menu->main_menu_flags&MAIN_MENU_DISTRIBUTION &&
!(menu->main_menu_flags&MAIN_MENU_DISTRIBUTION_SUB) &&
distribution_info && distribution_info->menu_show_func)
distribution_info->menu_show_func(NULL,NULL);
check_and_reread_applet(menu, main_menu);
}
......
......@@ -18,12 +18,13 @@ enum {
MAIN_MENU_USER_SUB = 1<<1,
MAIN_MENU_SYSTEM = 1<<2,
MAIN_MENU_SYSTEM_SUB = 1<<3,
MAIN_MENU_REDHAT = 1<<4,
MAIN_MENU_REDHAT_SUB = 1<<5,
MAIN_MENU_DISTRIBUTION = 1<<4,
MAIN_MENU_DISTRIBUTION_SUB = 1<<5,
MAIN_MENU_KDE = 1<<6,
MAIN_MENU_KDE_SUB = 1<<7,
MAIN_MENU_DEBIAN = 1<<8,
MAIN_MENU_DEBIAN_SUB = 1<<9,
/* keep this for compatibility. */
MAIN_MENU_OBSOLETE_DEBIAN = 1<<8,
MAIN_MENU_OBSOLETE_DEBIAN_SUB = 1<<9,
MAIN_MENU_APPLETS = 1<<10,
MAIN_MENU_APPLETS_SUB = 1<<11,
MAIN_MENU_PANEL = 1<<12,
......@@ -93,8 +94,6 @@ GtkWidget * create_root_menu(GtkWidget *root_menu,
#define MENU_PROPERTIES "menu_properties"
#define DEBIAN_MENUDIR "/var/lib/gnome/Debian/."
#define MENU_TYPES "types_menu"
#define MENU_TYPE_EDGE "type-edge"
#define MENU_TYPE_ALIGNED "type-aligned"
......
......@@ -23,6 +23,8 @@
#include "panel_config.h"
#include "panel_config_global.h"
#include "distribution.h"
#include "menu.h"
#include "menu-fentry.h"
#include "menu-rh.h"
......
......@@ -853,10 +853,11 @@ static void
drop_menu(PanelWidget *panel, int pos, char *dir)
{
int flags = MAIN_MENU_SYSTEM|MAIN_MENU_USER;
DistributionType distribution = get_distribution ();
/*guess redhat menus*/
if(g_file_exists("/etc/X11/wmconfig"))
flags |= MAIN_MENU_REDHAT_SUB;
/*guess distribution menus*/
if(distribution != DISTRIBUTION_UNKNOWN)
flags |= MAIN_MENU_DISTRIBUTION_SUB;
/* Guess KDE menus */
if(g_file_exists(kde_menudir))
flags |= MAIN_MENU_KDE_SUB;
......
......@@ -871,6 +871,7 @@ init_user_applets(void)
{
GString *buf;
int count, num;
DistributionType distribution = get_distribution();
count = gnome_config_get_int(PANEL_CONFIG_PATH
"panel/Config/applet_count=0");
......@@ -978,15 +979,12 @@ init_user_applets(void)
flags |= MAIN_MENU_SYSTEM_SUB|
MAIN_MENU_USER;
}
/*guess redhat menus*/
if(g_file_exists("/etc/X11/wmconfig"))
flags |= MAIN_MENU_REDHAT_SUB;
/*guess distribution menus*/
if(distribution != DISTRIBUTION_UNKNOWN)
flags |= MAIN_MENU_DISTRIBUTION_SUB;
/*guess KDE menus */
if(g_file_exists(kde_menudir))
flags |= MAIN_MENU_KDE_SUB;
/*guess debian menus*/
if (g_file_exists(DEBIAN_MENUDIR))
flags |= MAIN_MENU_DEBIAN_SUB;