Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
c477c2b9
Commit
c477c2b9
authored
19 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
Change menu system to cope with submenus.
parent
9f0926be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/ZMap/zmapWindow.h
+4
-3
4 additions, 3 deletions
src/include/ZMap/zmapWindow.h
src/zmapWindow/zmapWindowMenus.c
+80
-23
80 additions, 23 deletions
src/zmapWindow/zmapWindowMenus.c
with
84 additions
and
26 deletions
src/include/ZMap/zmapWindow.h
+
4
−
3
View file @
c477c2b9
...
...
@@ -26,9 +26,9 @@
* window displaying genome data.
*
* HISTORY:
* Last edited:
Oct 10 08:51
2005 (edgrif)
* Last edited:
Nov 11 15:36
2005 (edgrif)
* Created: Thu Jul 24 15:21:56 2003 (edgrif)
* CVS info: $Id: zmapWindow.h,v 1.4
2
2005-1
0
-1
0
1
0:30:59
edgrif Exp $
* CVS info: $Id: zmapWindow.h,v 1.4
3
2005-1
1
-1
4
1
1:17:16
edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_WINDOW_H
...
...
@@ -186,8 +186,9 @@ void zMapWindowUnlock(ZMapWindow window) ;
void
zMapWindowDestroy
(
ZMapWindow
window
)
;
/* this may be better in a utils directory...not sure.... */
void
zMapWindowMakeMenu
(
char
*
menu_title
,
ZMapWindowMenuItemStruc
t
menu_
items
[]
,
void
zMapWindowMakeMenu
(
char
*
menu_title
,
GLis
t
*
menu_
sets
,
GdkEventButton
*
button_event
)
;
...
...
This diff is collapsed.
Click to expand it.
src/zmapWindow/zmapWindowMenus.c
+
80
−
23
View file @
c477c2b9
...
...
@@ -20,24 +20,27 @@
* This file is part of the ZMap genome database package
* originated by
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
* Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk,
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
* Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk
*
* Description: Code implementing the menus for sequence display.
*
* Exported functions: ZMap/zmapWindows.h
*
* HISTORY:
* Last edited:
Jun 27 22:49
2005 (
rds
)
* Last edited:
Nov 14 11:16
2005 (
edgrif
)
* Created: Thu Mar 10 07:56:27 2005 (edgrif)
* CVS info: $Id: zmapWindowMenus.c,v 1.
4
2005-
06-27 21:49:26 rds
Exp $
* CVS info: $Id: zmapWindowMenus.c,v 1.
5
2005-
11-14 11:17:16 edgrif
Exp $
*-------------------------------------------------------------------
*/
#include
<string.h>
#include
<ZMap/zmapUtils.h>
#include
<zmapWindow_P.h>
/* REALLY THIS SHOULD GO IN THE GUI UTILS CODE IN THE UTILS DIRECTORY.... */
/* READ THIS:
*
* There seem to be 3 choices for implementing menus in gtk:
...
...
@@ -65,8 +68,8 @@
* gchar *path;
* gchar *accelerator;
* GtkItemFactoryCallback callback;
* guint
callback_action;
* gchar
*item_type;
* guint callback_action;
* gchar *item_type;
* gconstpointer extra_data;
* } GtkItemFactoryEntry;
*
...
...
@@ -89,7 +92,8 @@ typedef struct
static
char
*
makeMenuItemName
(
char
*
string
)
;
static
ZMapWindowMenuItem
copyMenu
(
ZMapWindowMenuItem
old_menu
,
int
*
menu_size
)
;
static
ZMapWindowMenuItem
makeSingleMenu
(
GList
*
menu_item_sets
,
int
*
menu_items_out
)
;
static
ZMapWindowMenuItem
copyMenu2NewMenu
(
ZMapWindowMenuItem
new_menu
,
ZMapWindowMenuItem
old_menu
)
;
static
void
destroyMenu
(
ZMapWindowMenuItem
menu
)
;
static
int
itemsInMenu
(
ZMapWindowMenuItem
menu
)
;
...
...
@@ -125,22 +129,22 @@ static void ourCB(gpointer callback_data, guint callback_action, GtkWidget *widg
* @param button_event The button event that triggered the menu to be popped up.
* @return <nothing>
* */
void
zMapWindowMakeMenu
(
char
*
menu_title
,
ZMapWindowMenuItemStruc
t
menu_item
s
[]
,
void
zMapWindowMakeMenu
(
char
*
menu_title
,
GLis
t
*
menu_item
_sets
,
GdkEventButton
*
button_event
)
{
int
num_menu_items
,
num_factory_items
,
i
,
menu_size
;
ZMapWindowMenuItem
menu_copy
;
ZMapWindowMenuItem
menu_items
,
menu_copy
;
GtkItemFactoryEntry
*
factory_items
,
*
item
;
GtkItemFactory
*
item_factory
;
CallbackData
our_cb_data
;
/* Make a single menu item list out of the supplied menu_item sets. */
menu_items
=
makeSingleMenu
(
menu_item_sets
,
&
num_menu_items
)
;
/* Set up our callback data, we use this to call our callers callback. */
our_cb_data
=
g_new0
(
CallbackDataStruct
,
1
)
;
/* Make a copy of the callers menu for use in our callback. */
our_cb_data
->
callers_menu_copy
=
menu_copy
=
copyMenu
(
menu_items
,
&
num_menu_items
)
;
our_cb_data
->
callers_menu_copy
=
menu_items
;
/*
...
...
@@ -168,6 +172,14 @@ void zMapWindowMakeMenu(char *menu_title, ZMapWindowMenuItemStruct menu_items[],
item
->
path
=
makeMenuItemName
(
menu_items
[
i
].
name
)
;
item
->
callback
=
ourCB
;
item
->
callback_action
=
i
;
/* This is not great, I need to add some types etc. to deal with submenus vs. other things. */
if
(
*
(
menu_items
[
i
].
name
)
==
'_'
)
{
item
->
item_type
=
"<Branch>"
;
item
->
callback
=
NULL
;
}
item
++
;
}
...
...
@@ -246,17 +258,63 @@ static char *makeMenuItemName(char *string)
/* Returns copy of menu and size of menu _NOT_ including the final terminating null entry. */
static
ZMapWindowMenuItem
copyMenu
(
ZMapWindowMenuItem
old_menu
,
int
*
menu_items_out
)
static
ZMapWindowMenuItem
makeSingleMenu
(
GList
*
menu_item_sets
,
int
*
menu_items_out
)
{
ZMapWindowMenuItem
new_menu
,
old_item
,
new_item
;
ZMapWindowMenuItem
new_menu
,
curr_menu
;
GList
*
curr_set
;
int
num_menu_items
;
num_menu_items
=
0
;
curr_set
=
g_list_first
(
menu_item_sets
)
;
while
(
curr_set
)
{
ZMapWindowMenuItem
sub_menu
;
sub_menu
=
(
ZMapWindowMenuItem
)
curr_set
->
data
;
num_menu_items
+=
itemsInMenu
(
sub_menu
)
;
curr_set
=
g_list_next
(
curr_set
)
;
}
/* Allocate memory for new menu. */
new_menu
=
g_new0
(
ZMapWindowMenuItemStruct
,
(
num_menu_items
+
1
))
;
/* Here we want to call a modified version of copy menu..... */
curr_set
=
g_list_first
(
menu_item_sets
)
;
curr_menu
=
new_menu
;
while
(
curr_set
)
{
ZMapWindowMenuItem
sub_menu
;
sub_menu
=
(
ZMapWindowMenuItem
)
curr_set
->
data
;
curr_menu
=
copyMenu2NewMenu
(
curr_menu
,
sub_menu
)
;
curr_set
=
g_list_next
(
curr_set
)
;
}
if
(
menu_items_out
)
*
menu_items_out
=
num_menu_items
;
return
new_menu
;
}
/* Returns pointer to next free menu item. */
static
ZMapWindowMenuItem
copyMenu2NewMenu
(
ZMapWindowMenuItem
new_menu
,
ZMapWindowMenuItem
old_menu
)
{
ZMapWindowMenuItem
next_menu
=
NULL
;
ZMapWindowMenuItem
old_item
,
new_item
;
int
i
,
num_menu_items
,
menu_size
;
num_menu_items
=
itemsInMenu
(
old_menu
)
;
/* Make a copy of the callers menu for use in our callback (remember null item on the end. */
menu_size
=
sizeof
(
ZMapWindowMenuItemStruct
)
*
(
num_menu_items
+
1
)
;
new_menu
=
g_memdup
(
old_menu
,
menu_size
)
;
/* Copy over menu items from old to new. */
num_menu_items
=
itemsInMenu
(
old_menu
)
;
menu_size
=
sizeof
(
ZMapWindowMenuItemStruct
)
*
num_menu_items
;
g_memmove
(
new_menu
,
old_menu
,
menu_size
)
;
/* Remember to copy the strings in the old menu. */
for
(
i
=
0
,
old_item
=
old_menu
,
new_item
=
new_menu
;
...
...
@@ -265,10 +323,9 @@ static ZMapWindowMenuItem copyMenu(ZMapWindowMenuItem old_menu, int *menu_items_
new_item
->
name
=
g_strdup
(
old_item
->
name
)
;
}
if
(
menu_items_out
)
*
menu_items_out
=
num_menu_items
;
next_menu
=
new_menu
+
num_menu_items
;
return
ne
w
_menu
;
return
ne
xt
_menu
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment