Commit 0878fcbf authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

get rid of the "." main menu parameter hack. I feel sort of sentimental

Mon Nov 26 00:57:16 2001  George Lebl <jirka@5z.com>

	* applet.c, menu-properties.[ch], menu.[ch], panel.c, session.c:
	  get rid of the "." main menu parameter hack.  I feel sort of
	  sentimental removing this since this dates back from the days
	  when federico maintained the panel.  I don't know why it lived
	  on so long anyway :)

	* menu.c: remove the properties menu stuff, just about everyone
	  agreed it was quite a horrible UI

	* foobar-widget.c, menu.c, panel-util.[ch]: add
	  panel_is_program_in_path which is like g_find_program_in_path
	  but returns just a boolean

	* menu.h, session.c: remove some compatibility hacks dating to
	  some ancient 1.0 versions or whatnot.  We'll break config compat
	  anyway.
parent 78a869fa
Mon Nov 26 00:57:16 2001 George Lebl <jirka@5z.com>
* applet.c, menu-properties.[ch], menu.[ch], panel.c, session.c:
get rid of the "." main menu parameter hack. I feel sort of
sentimental removing this since this dates back from the days
when federico maintained the panel. I don't know why it lived
on so long anyway :)
* menu.c: remove the properties menu stuff, just about everyone
agreed it was quite a horrible UI
* foobar-widget.c, menu.c, panel-util.[ch]: add
panel_is_program_in_path which is like g_find_program_in_path
but returns just a boolean
* menu.h, session.c: remove some compatibility hacks dating to
some ancient 1.0 versions or whatnot. We'll break config compat
anyway.
Sun Nov 25 20:07:06 2001 George Lebl <jirka@5z.com>
* launcher.c, menu.c, menu-fentry.[ch], main.c: remove the
......
......@@ -164,8 +164,7 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
} else if (strcmp (menu->name, "help") == 0) {
Menu *menu2 = menu->info->data;
char *page;
page = (menu2->path && strcmp (menu2->path,"."))
? "menus" : "mainmenu";
page = menu2->main_menu ? "mainmenu" : "menus";
panel_show_help (page, NULL);
}
break;
......
......@@ -385,7 +385,6 @@ static void
append_desktop_menu (GtkWidget *menu_bar)
{
GtkWidget *menu, *item;
char *char_tmp;
int i;
static char *arrange[] = {
N_("By Name"), "--arrange-desktop-icons=name",
......@@ -426,16 +425,13 @@ append_desktop_menu (GtkWidget *menu_bar)
item = add_menu_separator (menu);
gmc_menu_items = g_list_prepend (gmc_menu_items, item);
char_tmp = g_find_program_in_path ("xscreensaver");
if (char_tmp) {
if (panel_is_program_in_path ("xscreensaver")) {
item = pixmap_menu_item_new (_("Lock Screen"),
"gnome-lockscreen.png");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (panel_lock), 0);
setup_internal_applet_drag(item, "LOCK:NEW");
g_free (char_tmp);
}
item = pixmap_menu_item_new (_("Log Out"), "gnome-term-night.png");
......
......@@ -62,24 +62,17 @@ struct _MenuDialogInfo {
};
char *
get_real_menu_path (const char *arguments)
get_real_menu_path (const char *arguments, gboolean main_menu)
{
char *this_menu;
if (main_menu)
return g_strdup ("programs:");
/*if null, let's put the main menu up*/
if (string_empty (arguments))
arguments = ".";
if (strcmp (arguments, ".") == 0)
this_menu = g_strdup ("programs:");
else if (*arguments == '~')
/* FIXME: this needs to be a URI */
this_menu = g_build_filename (g_get_home_dir(),
return g_build_filename (g_get_home_dir(),
&arguments[1], NULL);
else
this_menu = g_strdup (arguments);
return this_menu;
return g_strdup (arguments);
}
char *
......@@ -180,29 +173,31 @@ properties_apply_callback (Menu *menu)
}
need_edit_menus = FALSE;
/* default to non-main-menu */
menu->main_menu = FALSE;
if (GTK_TOGGLE_BUTTON (menu->dialog_info->main_menu)->active ||
GTK_TOGGLE_BUTTON (menu->dialog_info->global_main)->active) {
g_free (menu->path);
menu->path = g_strdup (".");
menu->main_menu = TRUE;
if (got_gmenu ()) {
need_edit_menus = TRUE;
}
} else {
g_free (menu->path);
s = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (menu->dialog_info->pathentry),
TRUE);
if(s == NULL) {
g_warning (_("Can't open directory, using main menu!"));
menu->path = g_strdup (".");
menu->main_menu = TRUE;
} else if (*s == '\0') {
menu->path = g_strdup (".");
menu->main_menu = TRUE;
} else {
g_free (menu->path);
menu->path = g_strdup (s);
}
}
/* Setup the edit_menus callback */
if (panel_applet_get_callback (menu->info->user_menu, "edit_menus"))
got_edit_menus = TRUE;
......@@ -277,12 +272,11 @@ properties_apply_callback (Menu *menu)
/* Apply menu changes */
if (need_reload) {
char *this_menu = get_real_menu_path (menu->path);
char *this_menu = get_real_menu_path (menu->path, menu->main_menu);
GSList *list = g_slist_append (NULL, this_menu);
gboolean main_menu = strcmp (menu->path, ".") == 0;
add_menu_widget (menu, PANEL_WIDGET (menu->button->parent),
list, main_menu, TRUE);
list, TRUE);
g_free (this_menu);
......@@ -291,7 +285,8 @@ properties_apply_callback (Menu *menu)
/* Apply icon changes */
if (change_icon) {
char *this_menu = get_real_menu_path(menu->path);
char *this_menu = get_real_menu_path (menu->path,
menu->main_menu);
char *pixmap_name;
if (menu->custom_icon &&
......@@ -299,7 +294,7 @@ properties_apply_callback (Menu *menu)
g_file_test (menu->custom_icon_file, G_FILE_TEST_EXISTS))
pixmap_name = g_strdup (menu->custom_icon_file);
else
pixmap_name = get_pixmap(this_menu, (strcmp (menu->path, ".") == 0));
pixmap_name = get_pixmap (this_menu, menu->main_menu);
button_widget_set_pixmap(BUTTON_WIDGET(menu->button),
pixmap_name, -1);
}
......@@ -491,8 +486,7 @@ create_properties_dialog (Menu *menu)
w = gtk_radio_button_new_with_label (NULL, _("Global main menu"));
global_main = w;
menu->dialog_info->global_main = w;
if((menu->path == NULL ||
strcmp(menu->path, ".") == 0) &&
if (menu->main_menu &&
menu->global_main)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
gtk_signal_connect (GTK_OBJECT (w), "toggled",
......@@ -505,8 +499,7 @@ create_properties_dialog (Menu *menu)
_("Main menu"));
main_menu = w;
menu->dialog_info->main_menu = w;
if((menu->path == NULL ||
strcmp(menu->path, ".") == 0) &&
if (menu->main_menu &&
! menu->global_main)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
gtk_signal_connect (GTK_OBJECT (w), "toggled",
......@@ -517,7 +510,7 @@ create_properties_dialog (Menu *menu)
w2 = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (global_main)),
_("Normal menu"));
if(menu->path && strcmp(menu->path, ".") != 0)
if ( ! menu->main_menu)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w2), TRUE);
gtk_signal_connect (GTK_OBJECT (w2), "toggled",
GTK_SIGNAL_FUNC (toggle_normal_menu),
......@@ -525,8 +518,7 @@ create_properties_dialog (Menu *menu)
gtk_box_pack_start(GTK_BOX(box), w2, TRUE, TRUE, 0);
f = gtk_frame_new(_("Main menu"));
if((menu->path &&
strcmp(menu->path, ".") != 0) ||
if ( ! menu->main_menu ||
menu->global_main)
gtk_widget_set_sensitive(f, FALSE);
menu->dialog_info->main_frame = f;
......@@ -587,11 +579,10 @@ create_properties_dialog (Menu *menu)
menu->main_menu_flags & MAIN_MENU_DESKTOP_SUB);
f = gtk_frame_new(_("Normal menu"));
if(menu->path == NULL ||
strcmp(menu->path, ".") == 0)
gtk_widget_set_sensitive(f, FALSE);
if ( ! menu->main_menu)
gtk_widget_set_sensitive (f, FALSE);
menu->dialog_info->normal_frame = f;
gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), f, FALSE, FALSE, 0);
box = gtk_hbox_new(FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width(GTK_CONTAINER(box), GNOME_PAD_SMALL);
......@@ -606,7 +597,7 @@ create_properties_dialog (Menu *menu)
t = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (w));
menu->dialog_info->pathentry = w;
if (menu->path) {
char *s = get_real_menu_path(menu->path);
char *s = get_real_menu_path (menu->path, menu->main_menu);
gtk_entry_set_text(GTK_ENTRY(t), s);
g_free(s);
}
......
......@@ -7,7 +7,8 @@ G_BEGIN_DECLS
void menu_properties (Menu *menu);
char * get_real_menu_path (const char *arguments);
char * get_real_menu_path (const char *arguments,
gboolean main_menu);
char * get_pixmap (const char *menudir,
gboolean main_menu);
......
This diff is collapsed.
......@@ -6,13 +6,6 @@
G_BEGIN_DECLS
/*compatibility only*/
typedef enum {
X_MAIN_MENU_BOTH,
X_MAIN_MENU_USER,
X_MAIN_MENU_SYSTEM
} X_MainMenuType;
enum {
MAIN_MENU_USER = 1<<0,
MAIN_MENU_USER_SUB = 1<<1,
......@@ -42,16 +35,23 @@ struct _Menu {
GtkWidget *menu;
gboolean custom_icon;
char *custom_icon_file;
gboolean main_menu;
/* If this is the main menu then path is irrelevant */
char *path;
int main_menu_flags;
gboolean global_main;
/* if global_main is on then main_menu_flags are irrelevant */
int main_menu_flags;
int age;
GtkWidget *prop_dialog;
MenuDialogInfo *dialog_info;
AppletInfo *info;
};
void load_menu_applet (const char *params,
void load_menu_applet (const char *path,
gboolean main_menu,
int main_menu_flags,
gboolean global_main,
gboolean custom_icon,
......@@ -62,7 +62,6 @@ void load_menu_applet (const char *params,
void add_menu_widget (Menu *menu,
PanelWidget *panel,
GSList *menudirl,
gboolean main_menu,
gboolean fake_subs);
void set_menu_applet_orient (Menu *menu,
......
......@@ -1219,3 +1219,14 @@ readbuf_close (ReadBuf *rb)
g_free (rb);
}
gboolean
panel_is_program_in_path (const char *program)
{
char *tmp = g_find_program_in_path (program);
if (tmp != NULL) {
g_free (tmp);
return TRUE;
} else {
return FALSE;
}
}
......@@ -107,6 +107,9 @@ char * panel_quote_string (const char *str);
void panel_push_window_busy (GtkWidget *window);
void panel_pop_window_busy (GtkWidget *window);
gboolean panel_is_program_in_path (const char *program);
/* GnomeVFS reading utils */
typedef struct _ReadBuf ReadBuf;
......
......@@ -950,7 +950,9 @@ drop_menu (PanelWidget *panel, int pos, const char *dir)
/* Guess KDE menus */
if (g_file_test (kde_menudir, G_FILE_TEST_IS_DIR))
flags |= MAIN_MENU_KDE_SUB;
load_menu_applet (dir, flags, TRUE, FALSE, NULL, panel, pos, TRUE);
/* FIXME: checkout gnome-vfs stuff for drop, this should be
* a uri */
load_menu_applet (dir, FALSE /* main_menu */, flags, TRUE, FALSE, NULL, panel, pos, TRUE);
}
static void
......
......@@ -473,7 +473,6 @@ save_applet_configuration(AppletInfo *info)
menu->main_menu_flags);
gnome_config_set_bool("global_main",
menu->global_main);
gnome_config_set_bool("old_style_main", FALSE);
gnome_config_set_bool("custom_icon",
menu->custom_icon);
gnome_config_set_string("custom_icon_file",
......@@ -999,11 +998,10 @@ push_correct_global_prefix (void)
}
static void
init_user_applets(void)
init_user_applets (void)
{
GString *buf;
int count, num;
DistributionType distribution = get_distribution_type ();
char *prefix;
const char *sep;
......@@ -1149,95 +1147,31 @@ init_user_applets(void)
g_free (params);
} else if (strcmp (applet_name, MENU_ID) == 0) {
char *params = conditional_get_string ("parameters",
".", NULL);
int type = conditional_get_int ("main_menu_type", -1,
NULL);
/* this defaults to false, because we want old menus to
* work in the old style */
gboolean global_main_was_default;
char *path = conditional_get_string ("path",
"programs:/", NULL);
gboolean main_menu =
conditional_get_bool ("main_menu", TRUE, NULL);
gboolean global_main =
conditional_get_bool ("global_main", FALSE,
&global_main_was_default);
int flags;
gboolean old_style =
conditional_get_bool ("old_style_main", TRUE,
NULL);
conditional_get_bool ("global_main", TRUE, NULL);
gboolean custom_icon =
conditional_get_bool ("custom_icon", FALSE,
NULL);
char *custom_icon_file =
conditional_get_string ("custom_icon_file",
NULL, NULL);
flags = conditional_get_int ("main_menu_flags",
int flags = conditional_get_int ("main_menu_flags",
get_default_menu_flags (),
NULL);
if (flags < 0)
flags = get_default_menu_flags ();
/* Hack to try to do the right conversion while trying
* to turn on the feature on as many setups as
* possible */
if (global_main_was_default &&
flags == global_config.menu_flags) {
global_main = TRUE;
}
if(type >= 0) {
flags = 0;
if (type == X_MAIN_MENU_BOTH) {
flags |= MAIN_MENU_SYSTEM|MAIN_MENU_USER;
} else if(type == X_MAIN_MENU_SYSTEM) {
flags |= MAIN_MENU_SYSTEM|
MAIN_MENU_USER_SUB;
} else {
flags |= MAIN_MENU_SYSTEM_SUB|
MAIN_MENU_USER;
}
/*guess distribution menus*/
if (distribution != DISTRIBUTION_UNKNOWN)
flags |= MAIN_MENU_DISTRIBUTION_SUB;
/*guess KDE menus */
if (g_file_test (kde_menudir, G_FILE_TEST_IS_DIR))
flags |= MAIN_MENU_KDE_SUB;
}
if(old_style) {
/*this is needed to make panel properly
read older style configs */
if(flags&MAIN_MENU_SYSTEM &&
flags&MAIN_MENU_SYSTEM_SUB)
flags &=~ MAIN_MENU_SYSTEM;
if(flags&MAIN_MENU_USER &&
flags&MAIN_MENU_USER_SUB)
flags &=~ MAIN_MENU_USER;
if(flags&MAIN_MENU_DISTRIBUTION &&
flags&MAIN_MENU_DISTRIBUTION_SUB)
flags &=~ MAIN_MENU_DISTRIBUTION;
/*keep this for compatibility with older
config files */
if(flags&MAIN_MENU_OBSOLETE_DEBIAN &&
flags&MAIN_MENU_OBSOLETE_DEBIAN_SUB)
flags &=~ MAIN_MENU_DISTRIBUTION;
if(flags&MAIN_MENU_KDE &&
flags&MAIN_MENU_KDE_SUB)
flags &=~ MAIN_MENU_KDE;
flags |= MAIN_MENU_APPLETS_SUB |
MAIN_MENU_PANEL_SUB |
MAIN_MENU_DESKTOP;
}
if (old_style)
load_menu_applet(params, flags, FALSE,
custom_icon, custom_icon_file,
panel, pos, TRUE);
else
load_menu_applet(params, flags, global_main,
load_menu_applet (path, main_menu,
flags, global_main,
custom_icon, custom_icon_file,
panel, pos, TRUE);
g_free (custom_icon_file);
g_free (params);
g_free (path);
} else if (strcmp (applet_name, DRAWER_ID) == 0) {
int mypanel = conditional_get_int ("parameters", -1,
......@@ -1312,7 +1246,9 @@ init_user_panels(void)
gtk_widget_show(panel);
/* load up the foot menu */
load_menu_applet(NULL, get_default_menu_flags (),
load_menu_applet ("programs:/",
TRUE /* main_menu */,
get_default_menu_flags (),
TRUE, FALSE, NULL,
PANEL_WIDGET(BASEP_WIDGET(panel)->panel),
0, TRUE);
......
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