From ab588714dcd386b03e68f1e9c6aee4bde62aef7a Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 17 Jun 1999 15:07:06 +0000 Subject: [PATCH] r12: Added menu sources files. --- ROX-Filer/src/menu.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ROX-Filer/src/menu.h | 11 ++++++ 2 files changed, 110 insertions(+) create mode 100644 ROX-Filer/src/menu.c create mode 100644 ROX-Filer/src/menu.h diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c new file mode 100644 index 00000000..b6372b25 --- /dev/null +++ b/ROX-Filer/src/menu.c @@ -0,0 +1,99 @@ +/* vi: set cindent: + * $Id$ + * + * ROX-Filer, filer for the ROX desktop project + * By Thomas Leonard, . + */ + +/* menu.c - code for handling the popup menu */ + +#include + +#include "filer.h" +#include "support.h" + +#define C_ "" + +GtkAccelGroup *filer_keys; + + +/* Static prototypes */ +static void position_menu(GtkMenu *menu, gint *x, gint *y, gpointer data); +static void open_parent(gpointer data, guint action, GtkWidget *widget); + +static GtkWidget *filer_menu; /* The popup filer menu */ +static FilerWindow *menu_owner; + +static GtkItemFactoryEntry filer_menu_def[] = { +{"/_Display", NULL, NULL, 0, ""}, +{"/Display/_Large Icons", NULL, NULL, 0, ""}, +{"/Display/_Small Icons", NULL, NULL, 0, "/Display/Large Icons"}, +{"/Display/_Full Info", NULL, NULL, 0, "/Display/Large Icons"}, +{"/Display/Separator", NULL, NULL, 0, ""}, +{"/Display/Sort by _Name", NULL, NULL, 0, ""}, +{"/Display/Sort by _Type", NULL, NULL, 0, "/Display/Sort by Name"}, +{"/Display/Sort by _Date", NULL, NULL, 0, "/Display/Sort by Name"}, +{"/Display/Sort by Si_ze", NULL, NULL, 0, "/Display/Sort by Name"}, +{"/Display/Separator", NULL, NULL, 0, ""}, +{"/Display/Show _Hidden", C_"H", NULL, 0, ""}, +{"/Display/Refresh", C_"L", NULL, 0, NULL}, +{"/File", NULL, NULL, 0, ""}, +{"/File/_Copy", NULL, NULL, 0, NULL}, +{"/File/_Rename", NULL, NULL, 0, NULL}, +{"/File/_Help", "F1", NULL, 0, NULL}, +{"/File/_Info", NULL, NULL, 0, NULL}, +{"/File/Separator", NULL, NULL, 0, ""}, +{"/File/_Delete", C_"X", NULL, 0, NULL}, +{"/File/Disk _Usage", C_"U", NULL, 0, NULL}, +{"/File/_Permissions", NULL, NULL, 0, NULL}, +{"/File/_Stamp", NULL, NULL, 0, NULL}, +{"/File/_Find", NULL, NULL, 0, NULL}, +{"/_Select All", C_"A", NULL, 0, NULL}, +{"/_Clear Selection", C_"Z", NULL, 0, NULL}, +{"/_Options", NULL, NULL, 0, ""}, +{"/Options/_Confirm", NULL, NULL, 0, ""}, +{"/Options/_Verbose", NULL, NULL, 0, ""}, +{"/Options/_Force", NULL, NULL, 0, ""}, +{"/Options/_Newer", NULL, NULL, 0, ""}, +{"/_New directory", NULL, NULL, 0, NULL}, +{"/_Open parent", NULL, open_parent, 0, NULL}, +}; + + +void menu_init() +{ + GtkItemFactory *item_factory; + + filer_keys = gtk_accel_group_new(); + item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "", filer_keys); + + gtk_item_factory_create_items(item_factory, + sizeof(filer_menu_def) / sizeof(*filer_menu_def), + filer_menu_def, + NULL); + + filer_menu = gtk_item_factory_get_widget(item_factory, ""); +} + +static void position_menu(GtkMenu *menu, gint *x, gint *y, gpointer data) +{ + GtkRequisition requisition; + + gtk_widget_size_request(GTK_WIDGET(menu), &requisition); + + *x -= requisition.width >> 2; + *y -= requisition.height >> 2; +} + +void show_filer_menu(FilerWindow *filer_window, GdkEventButton *event) +{ + menu_owner = filer_window; + + gtk_menu_popup(GTK_MENU(filer_menu), NULL, NULL, position_menu, + NULL, event->button, event->time); +} + +static void open_parent(gpointer data, guint action, GtkWidget *widget) +{ + filer_opendir(make_path(menu_owner->dir->path, "/..")->str); +} diff --git a/ROX-Filer/src/menu.h b/ROX-Filer/src/menu.h new file mode 100644 index 00000000..0d79b5aa --- /dev/null +++ b/ROX-Filer/src/menu.h @@ -0,0 +1,11 @@ +/* vi: set cindent: + * $Id$ + * + * ROX-Filer, filer for the ROX desktop project + * By Thomas Leonard, . + */ + +extern GtkAccelGroup *filer_keys; + +void menu_init(void); +void show_filer_menu(FilerWindow *filer_window, GdkEventButton *event); -- 2.11.4.GIT