[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.2-20090328-68-g501f6d9)
The branch, master has been updated
via 501f6d99dc6cb7ba207138b52d1e86371b924bfe (commit)
via 34eed8e6b473e15590116d12c76db580fa41b789 (commit)
via fb7ad07015ae8c55d3885c32afb0a1744f8d83c2 (commit)
via c7ed765efa438a9028799cf16cd1b6318c5fc4ec (commit)
via 8adc9d6195c13f6e898d8f9cef6341681a119f46 (commit)
via 8ca990145aee1532c0cde02d329ceba13a1b9b86 (commit)
from a1f2394de855ee1d0cc2c931ed9aef86763eecbf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
gschem/include/Makefile.am | 2 +
gschem/include/gschem.h | 2 +
gschem/include/gschem_accel_label.h | 83 +++++++++
gschem/include/gschem_action.h | 56 ++++++
gschem/lib/system-gschemrc.in | 254 +++++++++++++-------------
gschem/scheme/gschem.scm | 7 -
gschem/src/Makefile.am | 2 +
gschem/src/gschem_accel_label.c | 337 +++++++++++++++++++++++++++++++++++
gschem/src/gschem_action.c | 237 ++++++++++++++++++++++++
gschem/src/x_menus.c | 122 ++++++-------
10 files changed, 905 insertions(+), 197 deletions(-)
create mode 100644 gschem/include/gschem_accel_label.h
create mode 100644 gschem/include/gschem_action.h
create mode 100644 gschem/src/gschem_accel_label.c
create mode 100644 gschem/src/gschem_action.c
=================
Commit Messages
=================
commit 501f6d99dc6cb7ba207138b52d1e86371b924bfe
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Add "_" style accelerators within menus
Copying accelerators for other common applications, such as "_Open",
"_New" etc. This aids keyboard navigation once we are in the menus
(which have a key-grab, so gschem's multi-key accelerators don't work.)
To set the accelerator on "Open Recen_t", we also have to edit x_menu.c,
since the recent files magic is hooked on the menu text (including the
accelerator). We also remove the explicit override of the label text in
x_menus.c, since we want to show the accelerator.
:100644 100644 31a85c5... 89ef69d... M gschem/lib/system-gschemrc.in
:100644 100644 f2a625f... 5587aaf... M gschem/src/x_menus.c
commit 34eed8e6b473e15590116d12c76db580fa41b789
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Assign shortcuts "vd" and "vl" for changing between color schemes
NB: "vl" was previously an alias for zoom extents.
:100644 100644 9d048c5... 31a85c5... M gschem/lib/system-gschemrc.in
commit fb7ad07015ae8c55d3885c32afb0a1744f8d83c2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Reorder / rename some menu items to better match other programs
:100644 100644 0c22c4a... 9d048c5... M gschem/lib/system-gschemrc.in
:100644 100644 367122d... f2a625f... M gschem/src/x_menus.c
commit c7ed765efa438a9028799cf16cd1b6318c5fc4ec
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Add stock icons to menus as appropriate
Using stock GTK icons as appropriate to help increase the usability
of gschem's menus.
:100644 100644 122966d... 0c22c4a... M gschem/lib/system-gschemrc.in
:100644 100644 a86f036... 367122d... M gschem/src/x_menus.c
commit 8adc9d6195c13f6e898d8f9cef6341681a119f46
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Specify menus have no bound actions with #f, rather than no-action
:100644 100644 d98f7b6... 122966d... M gschem/lib/system-gschemrc.in
:100644 100644 e6d4302... 0d37d6b... M gschem/scheme/gschem.scm
:100644 100644 0aff7ba... a86f036... M gschem/src/x_menus.c
commit 8ca990145aee1532c0cde02d329ceba13a1b9b86
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add GschemAction and GschemAccelLabel subclasses of their Gtk equivalents
These subclass are intended to encapsulate information relating to
gschem's multi-key shortcuts. Their code is based on GTK 2.14.5 (LGPL).
For GschemAccelLabel, we have to subclass GtkAccelLabel rather than just
GtkLabel, otherwise the menu doesn't correctly pad the accelerators into
their own column.
To set the accel_width, we have to go poking in a private part of the
GtkAccelLabel widget. The relevant field has been protected with GSEAL,
so this will not work in GTK3.0, or when compiled with GSEAL active.
:100644 100644 ca13ee0... 386c2ef... M gschem/include/Makefile.am
:100644 100644 b5180b7... 3dabd30... M gschem/include/gschem.h
:000000 100644 0000000... bbd2039... A gschem/include/gschem_accel_label.h
:000000 100644 0000000... 04d1380... A gschem/include/gschem_action.h
:100644 100644 765a1b9... 1aabef4... M gschem/src/Makefile.am
:000000 100644 0000000... ab1419d... A gschem/src/gschem_accel_label.c
:000000 100644 0000000... 428a831... A gschem/src/gschem_action.c
:100644 100644 926246c... 0aff7ba... M gschem/src/x_menus.c
=========
Changes
=========
commit 501f6d99dc6cb7ba207138b52d1e86371b924bfe
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Add "_" style accelerators within menus
Copying accelerators for other common applications, such as "_Open",
"_New" etc. This aids keyboard navigation once we are in the menus
(which have a key-grab, so gschem's multi-key accelerators don't work.)
To set the accelerator on "Open Recen_t", we also have to edit x_menu.c,
since the recent files magic is hooked on the menu text (including the
accelerator). We also remove the explicit override of the label text in
x_menus.c, since we want to show the accelerator.
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index 31a85c5..89ef69d 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -1400,35 +1400,35 @@
;; menu item name menu action menu hotkey function menu stock icon
;;
'( ("New Window" file-new-window file-new-window #f)
- ("New" file-new file-new "gtk-new")
- ("Open..." file-open file-open "gtk-open")
+ ("_New" file-new file-new "gtk-new")
+ ("_Open..." file-open file-open "gtk-open")
;; The entry below will be removed from the menu if glib < 2.6 is detected
- ("Open Recent" #f #f #f)
+ ("Open Recen_t" #f #f #f)
("SEPARATOR" #f #f #f)
- ("Save" file-save file-save "gtk-save")
- ("Save As..." file-save-as file-save-as "gtk-save-as")
+ ("_Save" file-save file-save "gtk-save")
+ ("Save _As..." file-save-as file-save-as "gtk-save-as")
("Save All" file-save-all file-save-all "gtk-save")
- ("Revert" page-revert page-revert "gtk-revert-to-saved")
+ ("_Revert" page-revert page-revert "gtk-revert-to-saved")
("SEPARATOR" #f #f #f)
- ("Print..." file-print file-print "gtk-print")
- ("Write image..." file-image file-image #f)
+ ("_Print..." file-print file-print "gtk-print")
+ ("Write _image..." file-image file-image #f)
("SEPARATOR" #f #f #f)
("Execute Script..." file-script file-script "gtk-execute")
("SEPARATOR" #f #f #f)
- ("Close" file-close-window file-close-window "gtk-close")
- ("Quit" file-quit file-quit "gtk-quit")))
+ ("_Close" file-close-window file-close-window "gtk-close")
+ ("_Quit" file-quit file-quit "gtk-quit")))
(define edit-menu-items
;;
;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Undo" edit-undo edit-undo "gtk-undo")
- ("Redo" edit-redo edit-redo "gtk-redo")
+ '( ("_Undo" edit-undo edit-undo "gtk-undo")
+ ("_Redo" edit-redo edit-redo "gtk-redo")
("SEPARATOR" #f #f #f)
- ("Cut" clipboard-cut clipboard-cut "gtk-cut")
- ("Copy" clipboard-copy clipboard-copy "gtk-copy")
- ("Paste" clipboard-paste-hotkey clipboard-paste-hotkey "gtk-paste")
- ("Delete" edit-delete edit-delete "gtk-delete" )
+ ("Cu_t" clipboard-cut clipboard-cut "gtk-cut")
+ ("_Copy" clipboard-copy clipboard-copy "gtk-copy")
+ ("_Paste" clipboard-paste-hotkey clipboard-paste-hotkey "gtk-paste")
+ ("_Delete" edit-delete edit-delete "gtk-delete" )
("SEPARATOR" #f #f #f)
("Select Mode" edit-select edit-select #f)
("Copy Mode" edit-copy edit-copy-hotkey #f)
@@ -1476,94 +1476,94 @@
(define view-menu-items
;;
-;; menu item name menu action menu hotkey action menu stock icon
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Redraw" view-redraw view-redraw "gtk-refresh")
- ("Pan" view-pan view-pan-hotkey #f)
- ("Zoom Box" view-zoom-box view-zoom-box-hotkey #f)
- ("Zoom Extents" view-zoom-extents view-zoom-extents "gtk-zoom-fit")
- ("Zoom In" view-zoom-in view-zoom-in-hotkey "gtk-zoom-in")
- ("Zoom Out" view-zoom-out view-zoom-out-hotkey "gtk-zoom-out")
- ("Zoom Full" view-zoom-full view-zoom-full #f)
- ("SEPARATOR" #f #f #f)
- ("Dark color scheme" view-dark-colors view-dark-colors #f)
- ("Light color scheme" view-light-colors view-light-colors #f)
+ '( ("_Redraw" view-redraw view-redraw "gtk-refresh")
+ ("_Pan" view-pan view-pan-hotkey #f)
+ ("Zoom _Box" view-zoom-box view-zoom-box-hotkey #f)
+ ("Zoom _Extents" view-zoom-extents view-zoom-extents "gtk-zoom-fit")
+ ("Zoom _In" view-zoom-in view-zoom-in-hotkey "gtk-zoom-in")
+ ("Zoom _Out" view-zoom-out view-zoom-out-hotkey "gtk-zoom-out")
+ ("Zoom _Full" view-zoom-full view-zoom-full #f)
+ ("SEPARATOR" #f #f #f)
+ ("_Dark color scheme" view-dark-colors view-dark-colors #f)
+ ("_Light color scheme" view-light-colors view-light-colors #f)
))
(define page-menu-items
;;
;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Manager..." page-manager page-manager #f)
- ("Previous" page-prev page-prev "gtk-go-back")
- ("Next" page-next page-next "gtk-go-forward")
- ("New" page-new page-new "gtk-new")
- ("Revert" page-revert page-revert "gtk-revert-to-saved")
- ("Close" page-close page-close "gtk-close")
+ '( ("_Manager..." page-manager page-manager #f)
+ ("_Previous" page-prev page-prev "gtk-go-back")
+ ("_Next" page-next page-next "gtk-go-forward")
+ ("Ne_w" page-new page-new "gtk-new")
+ ("_Revert" page-revert page-revert "gtk-revert-to-saved")
+ ("_Close" page-close page-close "gtk-close")
("SEPARATOR" #f #f #f)
- ("Discard" page-discard page-discard "gtk-discard")))
+ ("_Discard" page-discard page-discard "gtk-discard")))
(define add-menu-items
;;
;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Component..." add-component add-component)
- ("Net" add-net add-net-hotkey)
- ("Bus" add-bus add-bus-hotkey)
- ("Attribute..." add-attribute add-attribute-hotkey)
- ("Text..." add-text add-text)
- ("SEPARATOR" #f #f)
- ("Line" add-line add-line-hotkey)
- ("Box" add-box add-box-hotkey)
- ("Circle" add-circle add-circle-hotkey)
- ("Arc" add-arc add-arc-hotkey)
- ("Pin" add-pin add-pin-hotkey)
- ("Picture..." add-picture add-picture-hotkey)))
+ '( ("_Component..." add-component add-component)
+ ("_Net" add-net add-net-hotkey)
+ ("B_us" add-bus add-bus-hotkey)
+ ("_Attribute..." add-attribute add-attribute-hotkey)
+ ("_Text..." add-text add-text)
+ ("SEPARATOR" #f #f)
+ ("_Line" add-line add-line-hotkey)
+ ("_Box" add-box add-box-hotkey)
+ ("C_ircle" add-circle add-circle-hotkey)
+ ("A_rc" add-arc add-arc-hotkey)
+ ("_Pin" add-pin add-pin-hotkey)
+ ("Pictu_re..." add-picture add-picture-hotkey)))
(define hierarchy-menu-items
;;
;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Down Schematic" hierarchy-down-schematic hierarchy-down-schematic "gtk-go-down")
- ("Down Symbol" hierarchy-down-symbol hierarchy-down-symbol "gtk-goto-bottom")
- ("Up" hierarchy-up hierarchy-up "gtk-go-up")
- ("Documentation..." hierarchy-documentation hierarchy-documentation #f)))
+ '( ("_Down Schematic" hierarchy-down-schematic hierarchy-down-schematic "gtk-go-down")
+ ("Down _Symbol" hierarchy-down-symbol hierarchy-down-symbol "gtk-goto-bottom")
+ ("_Up" hierarchy-up hierarchy-up "gtk-go-up")
+ ("D_ocumentation..." hierarchy-documentation hierarchy-documentation #f)))
(define attributes-menu-items
;;
;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Attach" attributes-attach attributes-attach #f)
- ("Detach" attributes-detach attributes-detach #f)
- ("Show Value" attributes-show-value attributes-show-value #f)
- ("Show Name" attributes-show-name attributes-show-name #f)
- ("Show Both" attributes-show-both attributes-show-both #f)
- ("Toggle Visibility" attributes-visibility-toggle
- attributes-visibility-toggle #f)
- ("Find Specific Text..." edit-find-text edit-find-text "gtk-find")
- ("Hide Specific Text..." edit-hide-text edit-hide-text #f)
- ("Show Specific Text..." edit-show-text edit-show-text #f)
- ("Autonumber Text..." edit-autonumber edit-autonumber #f)))
+ '( ("_Attach" attributes-attach attributes-attach #f)
+ ("_Detach" attributes-detach attributes-detach #f)
+ ("Show _Value" attributes-show-value attributes-show-value #f)
+ ("Show _Name" attributes-show-name attributes-show-name #f)
+ ("Show _Both" attributes-show-both attributes-show-both #f)
+ ("_Toggle Visibility" attributes-visibility-toggle
+ attributes-visibility-toggle #f)
+ ("_Find Specific Text..." edit-find-text edit-find-text "gtk-find")
+ ("_Hide Specific Text..." edit-hide-text edit-hide-text #f)
+ ("_Show Specific Text..." edit-show-text edit-show-text #f)
+ ("A_utonumber Text..." edit-autonumber edit-autonumber #f)))
(define options-menu-items
;;
;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Text Size..." options-text-size options-text-size)
- ("Cycle grid styles" options-grid options-grid)
- ("Toggle Snap On/Off" options-snap options-snap)
- ("Snap Grid Spacing..." options-snap-size options-snap-size)
- ("Scale up Grid Spacing" options-scale-up-snap-size
+ '( ("_Text Size..." options-text-size options-text-size)
+ ("Cycle _grid styles" options-grid options-grid)
+ ("Toggle _Snap On/Off" options-snap options-snap)
+ ("Snap Grid S_pacing..." options-snap-size options-snap-size)
+ ("Scale _up Grid Spacing" options-scale-up-snap-size
options-scale-up-snap-size)
- ("Scale down Grid Spacing" options-scale-down-snap-size
+ ("Scale _down Grid Spacing" options-scale-down-snap-size
options-scale-down-snap-size)
- ("Toggle Outline/Box" options-action-feedback
+ ("Toggle _Outline/Box" options-action-feedback
options-action-feedback)
- ("Toggle Net Rubberband" options-rubberband options-rubberband)
- ("Toggle Magnetic Net" options-magneticnet options-magneticnet)
- ("Show Log Window..." options-show-log-window
+ ("Toggle Net _Rubberband" options-rubberband options-rubberband)
+ ("Toggle _Magnetic Net" options-magneticnet options-magneticnet)
+ ("Show _Log Window..." options-show-log-window
options-show-log-window)
- ("Show Coord Window..." options-show-coord-window
+ ("Show _Coord Window..." options-show-coord-window
options-show-coord-window)))
; Set up some functions used to open help files for the help menu
@@ -1579,13 +1579,13 @@
;; menu item name menu action menu hotkey action menu stock icon
;;
'(
- ("gEDA Documentation..." help-manual help-manual "gtk-help")
- ("gschem FAQ..." help-faq help-faq #f)
- ("gEDA Wiki..." help-wiki help-wiki #f)
- ("Component Documentation..." hierarchy-documentation hierarchy-documentation #f)
+ ("gEDA Docu_mentation..." help-manual help-manual "gtk-help")
+ ("gschem _FAQ..." help-faq help-faq #f)
+ ("gEDA _Wiki..." help-wiki help-wiki #f)
+ ("Component D_ocumentation..." hierarchy-documentation hierarchy-documentation #f)
("SEPARATOR" #f #f #f)
- ("Hotkeys..." help-hotkeys help-hotkeys #f)
- ("About..." help-about help-about "gtk-about")))
+ ("_Hotkeys..." help-hotkeys help-hotkeys #f)
+ ("_About..." help-about help-about "gtk-about")))
;
; Now actually add the menus. The order here defines the order in which
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index f2a625f..5587aaf 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -416,7 +416,7 @@ static void update_recent_files_menus()
recent_menu_item =
(GtkWidget *) gtk_object_get_data(GTK_OBJECT(w_current->menubar),
- "File/Open Recent");
+ "File/Open Recen_t");
if(recent_menu_item == NULL)
return;
@@ -485,7 +485,7 @@ void x_menu_attach_recent_files_submenu(GSCHEM_TOPLEVEL *w_current)
GtkWidget *recent_menu_item, *recent_submenu;
recent_menu_item = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(
- w_current->menubar), "File/Open Recent");
+ w_current->menubar), "File/Open Recen_t");
if(recent_menu_item == NULL)
return;
@@ -498,11 +498,6 @@ void x_menu_attach_recent_files_submenu(GSCHEM_TOPLEVEL *w_current)
gtk_signal_disconnect(recent_menu_item, id);
}
- /* remove 'q' from the menu item string; there has to be a better way to
- * create a menu item without a hotkey being assigned to it automatically */
- GtkWidget *label = gtk_bin_get_child(GTK_BIN(recent_menu_item));
- gtk_label_set_text(GTK_LABEL(label), _("Open Recent"));
-
recent_submenu = gtk_menu_new();
GList *p = recent_files;
while(p) {
commit 34eed8e6b473e15590116d12c76db580fa41b789
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Assign shortcuts "vd" and "vl" for changing between color schemes
NB: "vl" was previously an alias for zoom extents.
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index 9d048c5..31a85c5 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -1242,12 +1242,13 @@
'(("r" . view-redraw)
("b" . view-zoom-box-hotkey)
("f" . view-zoom-full)
- ("l" . view-zoom-extents)
("e" . view-zoom-extents)
("p" . view-pan-hotkey)
("u" . view-update-cues)
("o" . view-zoom-out-hotkey)
("i" . view-zoom-in-hotkey)
+ ("d" . view-dark-colors)
+ ("l" . view-light-colors)
))
(define buffer-keymap
@@ -1485,8 +1486,8 @@
("Zoom Out" view-zoom-out view-zoom-out-hotkey "gtk-zoom-out")
("Zoom Full" view-zoom-full view-zoom-full #f)
("SEPARATOR" #f #f #f)
- ("Dark color scheme" view-dark-colors #f #f)
- ("Light color scheme" view-light-colors #f #f)
+ ("Dark color scheme" view-dark-colors view-dark-colors #f)
+ ("Light color scheme" view-light-colors view-light-colors #f)
))
(define page-menu-items
commit fb7ad07015ae8c55d3885c32afb0a1744f8d83c2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Reorder / rename some menu items to better match other programs
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index 0c22c4a..9d048c5 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -1399,21 +1399,22 @@
;; menu item name menu action menu hotkey function menu stock icon
;;
'( ("New Window" file-new-window file-new-window #f)
- ("New Page" file-new file-new "gtk-new")
- ("Open Page..." file-open file-open "gtk-open")
- ("Close Page" page-close page-close #f)
- ("Revert Page" page-revert page-revert "gtk-revert-to-saved")
- ("Save Page" file-save file-save "gtk-save")
- ("Save Page As..." file-save-as file-save-as "gtk-save-as")
+ ("New" file-new file-new "gtk-new")
+ ("Open..." file-open file-open "gtk-open")
+;; The entry below will be removed from the menu if glib < 2.6 is detected
+ ("Open Recent" #f #f #f)
+ ("SEPARATOR" #f #f #f)
+ ("Save" file-save file-save "gtk-save")
+ ("Save As..." file-save-as file-save-as "gtk-save-as")
("Save All" file-save-all file-save-all "gtk-save")
+ ("Revert" page-revert page-revert "gtk-revert-to-saved")
+ ("SEPARATOR" #f #f #f)
("Print..." file-print file-print "gtk-print")
("Write image..." file-image file-image #f)
-;; The entry below will be removed from the menu if glib < 2.6 is detected
- ("Recent files" #f #f #f)
("SEPARATOR" #f #f #f)
("Execute Script..." file-script file-script "gtk-execute")
("SEPARATOR" #f #f #f)
- ("Close Window" file-close-window file-close-window "gtk-close")
+ ("Close" file-close-window file-close-window "gtk-close")
("Quit" file-quit file-quit "gtk-quit")))
(define edit-menu-items
@@ -1423,27 +1424,28 @@
'( ("Undo" edit-undo edit-undo "gtk-undo")
("Redo" edit-redo edit-redo "gtk-redo")
("SEPARATOR" #f #f #f)
- ("Select Mode" edit-select edit-select #f)
("Cut" clipboard-cut clipboard-cut "gtk-cut")
("Copy" clipboard-copy clipboard-copy "gtk-copy")
("Paste" clipboard-paste-hotkey clipboard-paste-hotkey "gtk-paste")
+ ("Delete" edit-delete edit-delete "gtk-delete" )
("SEPARATOR" #f #f #f)
- ("Edit..." edit-edit edit-edit #f)
- ("Edit Text..." edit-text edit-text "gtk-edit")
+ ("Select Mode" edit-select edit-select #f)
("Copy Mode" edit-copy edit-copy-hotkey #f)
("Multiple Copy Mode" edit-mcopy edit-mcopy-hotkey #f)
("Move Mode" edit-move edit-move-hotkey #f)
- ("Delete" edit-delete edit-delete "gtk-delete" )
("Rotate 90 Mode" edit-rotate-90 edit-rotate-90-hotkey #f)
("Mirror Mode" edit-mirror edit-mirror-hotkey #f)
("SEPARATOR" #f #f #f)
+ ("Edit..." edit-edit edit-edit #f)
+ ("Edit Text..." edit-text edit-text "gtk-edit")
("Slot..." edit-slot edit-slot #f)
("Color..." edit-color edit-color "gtk-select-color")
- ("Lock" edit-lock edit-lock #f)
- ("Unlock" edit-unlock edit-unlock #f)
("Line Width & Type..." edit-linetype edit-linetype #f)
("Fill Type..." edit-filltype edit-filltype #f)
("Symbol Translate..." edit-translate edit-translate #f)
+ ("Lock" edit-lock edit-lock #f)
+ ("Unlock" edit-unlock edit-unlock #f)
+ ("SEPARATOR" #f #f #f)
("Invoke Macro" edit-invoke-macro edit-invoke-macro #f)
("Embed Component/Picture" edit-embed edit-embed #f)
("Unembed Component/Picture" edit-unembed edit-unembed #f)
@@ -1492,8 +1494,8 @@
;; menu item name menu action menu hotkey action menu stock icon
;;
'( ("Manager..." page-manager page-manager #f)
- ("Next" page-next page-next "gtk-go-forward")
("Previous" page-prev page-prev "gtk-go-back")
+ ("Next" page-next page-next "gtk-go-forward")
("New" page-new page-new "gtk-new")
("Revert" page-revert page-revert "gtk-revert-to-saved")
("Close" page-close page-close "gtk-close")
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index 367122d..f2a625f 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -416,7 +416,7 @@ static void update_recent_files_menus()
recent_menu_item =
(GtkWidget *) gtk_object_get_data(GTK_OBJECT(w_current->menubar),
- "File/Recent files");
+ "File/Open Recent");
if(recent_menu_item == NULL)
return;
@@ -473,7 +473,7 @@ static void recent_file_clicked(GtkMenuItem *menuitem, gpointer user_data)
x_window_set_current_page(w_current, page);
}
-/*! \brief Attach a submenu with filenames to the 'Recent files'
+/*! \brief Attach a submenu with filenames to the 'Open Recent'
* menu item.
*
* Called from x_window_setup().
@@ -485,7 +485,7 @@ void x_menu_attach_recent_files_submenu(GSCHEM_TOPLEVEL *w_current)
GtkWidget *recent_menu_item, *recent_submenu;
recent_menu_item = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(
- w_current->menubar), "File/Recent files");
+ w_current->menubar), "File/Open Recent");
if(recent_menu_item == NULL)
return;
@@ -501,7 +501,7 @@ void x_menu_attach_recent_files_submenu(GSCHEM_TOPLEVEL *w_current)
/* remove 'q' from the menu item string; there has to be a better way to
* create a menu item without a hotkey being assigned to it automatically */
GtkWidget *label = gtk_bin_get_child(GTK_BIN(recent_menu_item));
- gtk_label_set_text(GTK_LABEL(label), _("Recent files"));
+ gtk_label_set_text(GTK_LABEL(label), _("Open Recent"));
recent_submenu = gtk_menu_new();
GList *p = recent_files;
commit c7ed765efa438a9028799cf16cd1b6318c5fc4ec
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Add stock icons to menus as appropriate
Using stock GTK icons as appropriate to help increase the usability
of gschem's menus.
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index 122966d..0c22c4a 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -1396,64 +1396,64 @@
(define file-menu-items
;;
-;; menu item name menu action menu hotkey function
+;; menu item name menu action menu hotkey function menu stock icon
;;
- '( ("New Window" file-new-window file-new-window)
- ("New Page" file-new file-new)
- ("Open Page..." file-open file-open)
- ("Close Page" page-close page-close)
- ("Revert Page" page-revert page-revert)
- ("Save Page" file-save file-save)
- ("Save Page As..." file-save-as file-save-as)
- ("Save All" file-save-all file-save-all)
- ("Print..." file-print file-print)
- ("Write image..." file-image file-image)
+ '( ("New Window" file-new-window file-new-window #f)
+ ("New Page" file-new file-new "gtk-new")
+ ("Open Page..." file-open file-open "gtk-open")
+ ("Close Page" page-close page-close #f)
+ ("Revert Page" page-revert page-revert "gtk-revert-to-saved")
+ ("Save Page" file-save file-save "gtk-save")
+ ("Save Page As..." file-save-as file-save-as "gtk-save-as")
+ ("Save All" file-save-all file-save-all "gtk-save")
+ ("Print..." file-print file-print "gtk-print")
+ ("Write image..." file-image file-image #f)
;; The entry below will be removed from the menu if glib < 2.6 is detected
- ("Recent files" #f #f)
- ("SEPARATOR" #f #f)
- ("Execute Script..." file-script file-script)
- ("SEPARATOR" #f #f)
- ("Close Window" file-close-window file-close-window)
- ("Quit" file-quit file-quit)))
+ ("Recent files" #f #f #f)
+ ("SEPARATOR" #f #f #f)
+ ("Execute Script..." file-script file-script "gtk-execute")
+ ("SEPARATOR" #f #f #f)
+ ("Close Window" file-close-window file-close-window "gtk-close")
+ ("Quit" file-quit file-quit "gtk-quit")))
(define edit-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Undo" edit-undo edit-undo)
- ("Redo" edit-redo edit-redo)
- ("SEPARATOR" #f #f)
- ("Select Mode" edit-select edit-select)
- ("Cut" clipboard-cut clipboard-cut)
- ("Copy" clipboard-copy clipboard-copy)
- ("Paste" clipboard-paste-hotkey clipboard-paste-hotkey)
- ("SEPARATOR" #f #f)
- ("Edit..." edit-edit edit-edit)
- ("Edit Text..." edit-text edit-text)
- ("Copy Mode" edit-copy edit-copy-hotkey)
- ("Multiple Copy Mode" edit-mcopy edit-mcopy-hotkey)
- ("Move Mode" edit-move edit-move-hotkey)
- ("Delete" edit-delete edit-delete)
- ("Rotate 90 Mode" edit-rotate-90 edit-rotate-90-hotkey)
- ("Mirror Mode" edit-mirror edit-mirror-hotkey)
- ("SEPARATOR" #f #f)
- ("Slot..." edit-slot edit-slot)
- ("Color..." edit-color edit-color)
- ("Lock" edit-lock edit-lock)
- ("Unlock" edit-unlock edit-unlock)
- ("Line Width & Type..." edit-linetype edit-linetype)
- ("Fill Type..." edit-filltype edit-filltype)
- ("Symbol Translate..." edit-translate edit-translate)
- ("Invoke Macro" edit-invoke-macro edit-invoke-macro)
- ("Embed Component/Picture" edit-embed edit-embed)
- ("Unembed Component/Picture" edit-unembed edit-unembed)
- ("Update Component" edit-update edit-update)
- ("Show/Hide Inv Text" edit-show-hidden edit-show-hidden)
- ("Make Inv Text Vis" edit-make-text-visible edit-make-text-visible)))
+ '( ("Undo" edit-undo edit-undo "gtk-undo")
+ ("Redo" edit-redo edit-redo "gtk-redo")
+ ("SEPARATOR" #f #f #f)
+ ("Select Mode" edit-select edit-select #f)
+ ("Cut" clipboard-cut clipboard-cut "gtk-cut")
+ ("Copy" clipboard-copy clipboard-copy "gtk-copy")
+ ("Paste" clipboard-paste-hotkey clipboard-paste-hotkey "gtk-paste")
+ ("SEPARATOR" #f #f #f)
+ ("Edit..." edit-edit edit-edit #f)
+ ("Edit Text..." edit-text edit-text "gtk-edit")
+ ("Copy Mode" edit-copy edit-copy-hotkey #f)
+ ("Multiple Copy Mode" edit-mcopy edit-mcopy-hotkey #f)
+ ("Move Mode" edit-move edit-move-hotkey #f)
+ ("Delete" edit-delete edit-delete "gtk-delete" )
+ ("Rotate 90 Mode" edit-rotate-90 edit-rotate-90-hotkey #f)
+ ("Mirror Mode" edit-mirror edit-mirror-hotkey #f)
+ ("SEPARATOR" #f #f #f)
+ ("Slot..." edit-slot edit-slot #f)
+ ("Color..." edit-color edit-color "gtk-select-color")
+ ("Lock" edit-lock edit-lock #f)
+ ("Unlock" edit-unlock edit-unlock #f)
+ ("Line Width & Type..." edit-linetype edit-linetype #f)
+ ("Fill Type..." edit-filltype edit-filltype #f)
+ ("Symbol Translate..." edit-translate edit-translate #f)
+ ("Invoke Macro" edit-invoke-macro edit-invoke-macro #f)
+ ("Embed Component/Picture" edit-embed edit-embed #f)
+ ("Unembed Component/Picture" edit-unembed edit-unembed #f)
+ ("Update Component" edit-update edit-update "gtk-refresh")
+ ("Show/Hide Inv Text" edit-show-hidden edit-show-hidden #f)
+ ("Make Inv Text Vis" edit-make-text-visible edit-make-text-visible #f)))
(define buffer-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
'( ("Copy into 1" buffer-copy1 buffer-copy1)
("Copy into 2" buffer-copy2 buffer-copy2)
@@ -1473,36 +1473,36 @@
(define view-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Redraw" view-redraw view-redraw)
- ("Pan" view-pan view-pan-hotkey)
- ("Zoom Box" view-zoom-box view-zoom-box-hotkey)
- ("Zoom Extents" view-zoom-extents view-zoom-extents)
- ("Zoom In" view-zoom-in view-zoom-in-hotkey)
- ("Zoom Out" view-zoom-out view-zoom-out-hotkey)
- ("Zoom Full" view-zoom-full view-zoom-full)
- ("SEPARATOR" #f #f)
- ("Dark color scheme" view-dark-colors #f)
- ("Light color scheme" view-light-colors #f)
- ))
+ '( ("Redraw" view-redraw view-redraw "gtk-refresh")
+ ("Pan" view-pan view-pan-hotkey #f)
+ ("Zoom Box" view-zoom-box view-zoom-box-hotkey #f)
+ ("Zoom Extents" view-zoom-extents view-zoom-extents "gtk-zoom-fit")
+ ("Zoom In" view-zoom-in view-zoom-in-hotkey "gtk-zoom-in")
+ ("Zoom Out" view-zoom-out view-zoom-out-hotkey "gtk-zoom-out")
+ ("Zoom Full" view-zoom-full view-zoom-full #f)
+ ("SEPARATOR" #f #f #f)
+ ("Dark color scheme" view-dark-colors #f #f)
+ ("Light color scheme" view-light-colors #f #f)
+ ))
(define page-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Manager..." page-manager page-manager)
- ("Next" page-next page-next)
- ("Previous" page-prev page-prev)
- ("New" page-new page-new)
- ("Revert" page-revert page-revert)
- ("Close" page-close page-close)
- ("SEPARATOR" #f #f)
- ("Discard" page-discard page-discard)))
+ '( ("Manager..." page-manager page-manager #f)
+ ("Next" page-next page-next "gtk-go-forward")
+ ("Previous" page-prev page-prev "gtk-go-back")
+ ("New" page-new page-new "gtk-new")
+ ("Revert" page-revert page-revert "gtk-revert-to-saved")
+ ("Close" page-close page-close "gtk-close")
+ ("SEPARATOR" #f #f #f)
+ ("Discard" page-discard page-discard "gtk-discard")))
(define add-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
'( ("Component..." add-component add-component)
("Net" add-net add-net-hotkey)
@@ -1519,36 +1519,32 @@
(define hierarchy-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Down Schematic" hierarchy-down-schematic
- hierarchy-down-schematic)
- ("Down Symbol" hierarchy-down-symbol
- hierarchy-down-symbol)
- ("Up" hierarchy-up
- hierarchy-up)
- ("Documentation..." hierarchy-documentation
- hierarchy-documentation)))
+ '( ("Down Schematic" hierarchy-down-schematic hierarchy-down-schematic "gtk-go-down")
+ ("Down Symbol" hierarchy-down-symbol hierarchy-down-symbol "gtk-goto-bottom")
+ ("Up" hierarchy-up hierarchy-up "gtk-go-up")
+ ("Documentation..." hierarchy-documentation hierarchy-documentation #f)))
(define attributes-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '( ("Attach" attributes-attach attributes-attach)
- ("Detach" attributes-detach attributes-detach)
- ("Show Value" attributes-show-value attributes-show-value)
- ("Show Name" attributes-show-name attributes-show-name)
- ("Show Both" attributes-show-both attributes-show-both)
- ("Toggle Visibility" attributes-visibility-toggle
- attributes-visibility-toggle)
- ("Find Specific Text..." edit-find-text edit-find-text)
- ("Hide Specific Text..." edit-hide-text edit-hide-text)
- ("Show Specific Text..." edit-show-text edit-show-text)
- ("Autonumber Text..." edit-autonumber edit-autonumber)))
+ '( ("Attach" attributes-attach attributes-attach #f)
+ ("Detach" attributes-detach attributes-detach #f)
+ ("Show Value" attributes-show-value attributes-show-value #f)
+ ("Show Name" attributes-show-name attributes-show-name #f)
+ ("Show Both" attributes-show-both attributes-show-both #f)
+ ("Toggle Visibility" attributes-visibility-toggle
+ attributes-visibility-toggle #f)
+ ("Find Specific Text..." edit-find-text edit-find-text "gtk-find")
+ ("Hide Specific Text..." edit-hide-text edit-hide-text #f)
+ ("Show Specific Text..." edit-show-text edit-show-text #f)
+ ("Autonumber Text..." edit-autonumber edit-autonumber #f)))
(define options-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
'( ("Text Size..." options-text-size options-text-size)
("Cycle grid styles" options-grid options-grid)
@@ -1577,18 +1573,17 @@
(define help-menu-items
;;
-;; menu item name menu action menu hotkey action
+;; menu item name menu action menu hotkey action menu stock icon
;;
- '(
- ("gEDA Documentation..." help-manual help-manual)
- ("gschem FAQ..." help-faq help-faq)
- ("gEDA Wiki..." help-wiki help-wiki)
- ("Component Documentation..." hierarchy-documentation
- hierarchy-documentation)
- ("SEPARATOR" #f #f)
- ("Hotkeys..." help-hotkeys help-hotkeys)
- ("About..." help-about help-about)))
-
+ '(
+ ("gEDA Documentation..." help-manual help-manual "gtk-help")
+ ("gschem FAQ..." help-faq help-faq #f)
+ ("gEDA Wiki..." help-wiki help-wiki #f)
+ ("Component Documentation..." hierarchy-documentation hierarchy-documentation #f)
+ ("SEPARATOR" #f #f #f)
+ ("Hotkeys..." help-hotkeys help-hotkeys #f)
+ ("About..." help-about help-about "gtk-about")))
+
;
; Now actually add the menus. The order here defines the order in which
; the menus appear in the top menu bar.
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index a86f036..367122d 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -95,6 +95,7 @@ void get_main_menu(GtkWidget ** menubar)
SCM scm_item_name;
SCM scm_item_func;
SCM scm_item_hotkey_func;
+ SCM scm_item_stock;
SCM scm_index;
SCM scm_keys;
char *menu_name;
@@ -103,6 +104,7 @@ void get_main_menu(GtkWidget ** menubar)
char *raw_menu_item_name;
char *menu_item_func;
char *menu_item_hotkey_func;
+ char *menu_item_stock;
char *menu_item_keys;
int i, j;
@@ -129,6 +131,8 @@ void get_main_menu(GtkWidget ** menubar)
scm_item_name = SCM_CAR (scm_item);
scm_item_func = SCM_CADR (scm_item);
scm_item_hotkey_func = SCM_CADDR (scm_item);
+ scm_item_stock = scm_is_pair (SCM_CDDDR (scm_item)) ?
+ SCM_CADDDR (scm_item) : SCM_BOOL_F;
SCM_ASSERT(scm_is_string(scm_item_name), scm_item_name, SCM_ARGn, "get_main_menu item_name");
SCM_ASSERT(SCM_SYMBOLP (scm_item_func) ||
scm_is_false (scm_item_func),
@@ -136,6 +140,9 @@ void get_main_menu(GtkWidget ** menubar)
SCM_ASSERT (SCM_SYMBOLP (scm_item_hotkey_func) ||
scm_is_false (scm_item_hotkey_func),
scm_item_hotkey_func, SCM_ARGn, "get_main_menu hotkey_func");
+ SCM_ASSERT (SCM_STRINGP (scm_item_stock) ||
+ scm_is_false (scm_item_stock),
+ scm_item_stock, SCM_ARGn, "get_main_menu stock");
raw_menu_item_name = SCM_STRING_CHARS (scm_item_name);
@@ -149,6 +156,11 @@ void get_main_menu(GtkWidget ** menubar)
else
menu_item_hotkey_func = SCM_SYMBOL_CHARS (scm_item_hotkey_func);
+ if (scm_is_false (scm_item_stock))
+ menu_item_stock = NULL;
+ else
+ menu_item_stock = SCM_SYMBOL_CHARS (scm_item_stock);
+
menu_item_name = (char *) gettext(raw_menu_item_name);
if (strcmp(menu_item_name, "SEPARATOR") == 0) {
@@ -175,7 +187,7 @@ void get_main_menu(GtkWidget ** menubar)
action = gschem_action_new (menu_item_func, /* Action name */
menu_item_name, /* Text */
menu_item_name, /* Tooltip */
- NULL, /* Icon stock ID */
+ menu_item_stock, /* Icon stock ID */
menu_item_keys); /* Accelerator string */
menu_item = gtk_action_create_menu_item (GTK_ACTION (action));
gtk_menu_append (GTK_MENU (menu), menu_item);
commit 8adc9d6195c13f6e898d8f9cef6341681a119f46
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Specify menus have no bound actions with #f, rather than no-action
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index d98f7b6..122966d 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -1409,10 +1409,10 @@
("Print..." file-print file-print)
("Write image..." file-image file-image)
;; The entry below will be removed from the menu if glib < 2.6 is detected
- ("Recent files" no-action no-action)
- ("SEPARATOR" no-action no-action)
+ ("Recent files" #f #f)
+ ("SEPARATOR" #f #f)
("Execute Script..." file-script file-script)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Close Window" file-close-window file-close-window)
("Quit" file-quit file-quit)))
@@ -1422,12 +1422,12 @@
;;
'( ("Undo" edit-undo edit-undo)
("Redo" edit-redo edit-redo)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Select Mode" edit-select edit-select)
("Cut" clipboard-cut clipboard-cut)
("Copy" clipboard-copy clipboard-copy)
("Paste" clipboard-paste-hotkey clipboard-paste-hotkey)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Edit..." edit-edit edit-edit)
("Edit Text..." edit-text edit-text)
("Copy Mode" edit-copy edit-copy-hotkey)
@@ -1436,7 +1436,7 @@
("Delete" edit-delete edit-delete)
("Rotate 90 Mode" edit-rotate-90 edit-rotate-90-hotkey)
("Mirror Mode" edit-mirror edit-mirror-hotkey)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Slot..." edit-slot edit-slot)
("Color..." edit-color edit-color)
("Lock" edit-lock edit-lock)
@@ -1482,9 +1482,9 @@
("Zoom In" view-zoom-in view-zoom-in-hotkey)
("Zoom Out" view-zoom-out view-zoom-out-hotkey)
("Zoom Full" view-zoom-full view-zoom-full)
- ("SEPARATOR" no-action no-action)
- ("Dark color scheme" view-dark-colors no-action)
- ("Light color scheme" view-light-colors no-action)
+ ("SEPARATOR" #f #f)
+ ("Dark color scheme" view-dark-colors #f)
+ ("Light color scheme" view-light-colors #f)
))
(define page-menu-items
@@ -1497,7 +1497,7 @@
("New" page-new page-new)
("Revert" page-revert page-revert)
("Close" page-close page-close)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Discard" page-discard page-discard)))
(define add-menu-items
@@ -1509,7 +1509,7 @@
("Bus" add-bus add-bus-hotkey)
("Attribute..." add-attribute add-attribute-hotkey)
("Text..." add-text add-text)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Line" add-line add-line-hotkey)
("Box" add-box add-box-hotkey)
("Circle" add-circle add-circle-hotkey)
@@ -1585,7 +1585,7 @@
("gEDA Wiki..." help-wiki help-wiki)
("Component Documentation..." hierarchy-documentation
hierarchy-documentation)
- ("SEPARATOR" no-action no-action)
+ ("SEPARATOR" #f #f)
("Hotkeys..." help-hotkeys help-hotkeys)
("About..." help-about help-about)))
diff --git a/gschem/scheme/gschem.scm b/gschem/scheme/gschem.scm
index e6d4302..0d37d6b 100644
--- a/gschem/scheme/gschem.scm
+++ b/gschem/scheme/gschem.scm
@@ -29,13 +29,6 @@
(define last-command-sequence #f)
(define current-command-sequence '())
-; no action hotkey
-(define no-action
- (lambda ()
- #f
- )
-)
-
; Doers
(define (press-key key)
(eval-pressed-key current-keymap key))
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index 0aff7ba..a86f036 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -130,12 +130,24 @@ void get_main_menu(GtkWidget ** menubar)
scm_item_func = SCM_CADR (scm_item);
scm_item_hotkey_func = SCM_CADDR (scm_item);
SCM_ASSERT(scm_is_string(scm_item_name), scm_item_name, SCM_ARGn, "get_main_menu item_name");
- SCM_ASSERT(SCM_SYMBOLP(scm_item_func), scm_item_func, SCM_ARGn, "get_main_menu item_func");
- SCM_ASSERT(SCM_SYMBOLP(scm_item_hotkey_func), scm_item_hotkey_func, SCM_ARGn, "get_main_menu hotkey_func");
+ SCM_ASSERT(SCM_SYMBOLP (scm_item_func) ||
+ scm_is_false (scm_item_func),
+ scm_item_func, SCM_ARGn, "get_main_menu item_func");
+ SCM_ASSERT (SCM_SYMBOLP (scm_item_hotkey_func) ||
+ scm_is_false (scm_item_hotkey_func),
+ scm_item_hotkey_func, SCM_ARGn, "get_main_menu hotkey_func");
raw_menu_item_name = SCM_STRING_CHARS (scm_item_name);
- menu_item_func = SCM_SYMBOL_CHARS (scm_item_func);
- menu_item_hotkey_func = SCM_SYMBOL_CHARS (scm_item_hotkey_func);
+
+ if (scm_is_false (scm_item_func))
+ menu_item_func = "no-action";
+ else
+ menu_item_func = SCM_SYMBOL_CHARS (scm_item_func);
+
+ if (scm_is_false (scm_item_hotkey_func))
+ menu_item_hotkey_func = NULL;
+ else
+ menu_item_hotkey_func = SCM_SYMBOL_CHARS (scm_item_hotkey_func);
menu_item_name = (char *) gettext(raw_menu_item_name);
@@ -143,14 +155,21 @@ void get_main_menu(GtkWidget ** menubar)
menu_item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), menu_item);
} else {
- buf = g_strdup_printf("(find-key '%s)", menu_item_hotkey_func);
- scm_keys = g_scm_c_eval_string_protected (buf);
- g_free(buf);
- if (scm_keys == SCM_BOOL_F) {
- menu_item_keys = "";
+ if (menu_item_hotkey_func != NULL) {
+
+ buf = g_strdup_printf ("(find-key '%s)", menu_item_hotkey_func);
+ scm_keys = g_scm_c_eval_string_protected (buf);
+ g_free (buf);
+
+ if (scm_keys == SCM_BOOL_F) {
+ menu_item_keys = "";
+ } else {
+ menu_item_keys = SCM_STRING_CHARS (scm_keys);
+ }
+
} else {
- menu_item_keys = SCM_STRING_CHARS (scm_keys);
+ menu_item_keys = "";
}
action = gschem_action_new (menu_item_func, /* Action name */
@@ -164,6 +183,7 @@ void get_main_menu(GtkWidget ** menubar)
gtk_signal_connect_object (GTK_OBJECT(menu_item), "activate",
GTK_SIGNAL_FUNC(g_menu_execute),
(gpointer) g_strdup (menu_item_func));
+ /* The g_strdup is a memory leak, but this is okay. I think. */
}
gtk_widget_show (menu_item);
commit 8ca990145aee1532c0cde02d329ceba13a1b9b86
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add GschemAction and GschemAccelLabel subclasses of their Gtk equivalents
These subclass are intended to encapsulate information relating to
gschem's multi-key shortcuts. Their code is based on GTK 2.14.5 (LGPL).
For GschemAccelLabel, we have to subclass GtkAccelLabel rather than just
GtkLabel, otherwise the menu doesn't correctly pad the accelerators into
their own column.
To set the accel_width, we have to go poking in a private part of the
GtkAccelLabel widget. The relevant field has been protected with GSEAL,
so this will not work in GTK3.0, or when compiled with GSEAL active.
diff --git a/gschem/include/Makefile.am b/gschem/include/Makefile.am
index ca13ee0..386c2ef 100644
--- a/gschem/include/Makefile.am
+++ b/gschem/include/Makefile.am
@@ -8,6 +8,8 @@ noinst_HEADERS = \
x_compselect.h \
x_log.h x_multiattrib.h x_pagesel.h x_print.h x_preview.h \
gschem.h \
+ gschem_accel_label.h \
+ gschem_action.h \
gschem_defines.h \
gschem_dialog.h \
gschem_struct.h
diff --git a/gschem/include/gschem.h b/gschem/include/gschem.h
index b5180b7..3dabd30 100644
--- a/gschem/include/gschem.h
+++ b/gschem/include/gschem.h
@@ -7,6 +7,8 @@
/* gschem headers */
#include "gschem_defines.h"
#include "gschem_struct.h"
+#include "gschem_accel_label.h"
+#include "gschem_action.h"
#include "gschem_dialog.h"
#include "i_vars.h"
#include "x_preview.h"
diff --git a/gschem/include/gschem_accel_label.h b/gschem/include/gschem_accel_label.h
new file mode 100644
index 0000000..bbd2039
--- /dev/null
+++ b/gschem/include/gschem_accel_label.h
@@ -0,0 +1,83 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2009 gEDA Contributors (see ChangeLog for details)
+ *
+ * Code based on GTK 2.14.5 gtk/gtkaccellabel.h (LGPL)
+ *
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * GschemAccelLabel: GtkLabel with accelerator monitoring facilities.
+ * Copyright (C) 1998 Tim Janik
+ *
+ * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ *
+ * Adapted for gEDA by Peter Clifton <pcjc2@xxxxxxxxx>
+ *
+ * THIS FILE IS LGPL LICENSED, gEDA AS A WHOLE IS GPL LICENSED
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GSCHEM_ACCEL_LABEL_H__
+#define __GSCHEM_ACCEL_LABEL_H__
+
+G_BEGIN_DECLS
+
+#define GSCHEM_TYPE_ACCEL_LABEL (gschem_accel_label_get_type ())
+#define GSCHEM_ACCEL_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSCHEM_TYPE_ACCEL_LABEL, GschemAccelLabel))
+#define GSCHEM_ACCEL_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSCHEM_TYPE_ACCEL_LABEL, GschemAccelLabelClass))
+#define GSCHEM_IS_ACCEL_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSCHEM_TYPE_ACCEL_LABEL))
+#define GSCHEM_IS_ACCEL_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSCHEM_TYPE_ACCEL_LABEL))
+#define GSCHEM_ACCEL_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSCHEM_TYPE_ACCEL_LABEL, GschemAccelLabelClass))
+
+
+typedef struct _GschemAccelLabel GschemAccelLabel;
+typedef struct _GschemAccelLabelClass GschemAccelLabelClass;
+
+struct _GschemAccelLabel
+{
+ GtkAccelLabel label;
+
+ guint accel_padding;
+ gchar *accel_string;
+ guint16 accel_string_width;
+};
+
+struct _GschemAccelLabelClass
+{
+ GtkAccelLabelClass parent_class;
+};
+
+
+GType gschem_accel_label_get_type (void) G_GNUC_CONST;
+GtkWidget* gschem_accel_label_new (const gchar *string);
+guint gschem_accel_label_get_accel_width (GschemAccelLabel *accel_label);
+void gschem_accel_label_set_accel_string (GschemAccelLabel *accel_label,
+ const gchar *accel_string);
+gboolean gschem_accel_label_refetch (GschemAccelLabel *accel_label);
+
+/* private */
+gchar * _gschem_accel_label_class_get_accelerator_label (GschemAccelLabelClass *klass,
+ guint accelerator_key,
+ GdkModifierType accelerator_mods);
+
+G_END_DECLS
+
+#endif /* __GSCHEM_ACCEL_LABEL_H__ */
diff --git a/gschem/include/gschem_action.h b/gschem/include/gschem_action.h
new file mode 100644
index 0000000..04d1380
--- /dev/null
+++ b/gschem/include/gschem_action.h
@@ -0,0 +1,56 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2009 Ales V. Hvezda
+ * Copyright (C) 1998-2009 gEDA Contributors (see ChangeLog for details)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef __GSCHEM_ACTION_H__
+#define __GSCHEM_ACTION_H__
+
+
+#define GSCHEM_TYPE_ACTION (gschem_action_get_type())
+#define GSCHEM_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSCHEM_TYPE_ACTION, GschemAction))
+#define GSCHEM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSCHEM_TYPE_ACTION, GschemActionClass))
+#define GSCHEM_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSCHEM_TYPE_ACTION))
+#define GSCHEM_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSCHEM_TYPE_ACTION, GschemActionClass))
+
+typedef struct _GschemActionClass GschemActionClass;
+typedef struct _GschemAction GschemAction;
+
+
+struct _GschemActionClass {
+ GtkActionClass parent_class;
+
+};
+
+struct _GschemAction {
+ GtkAction parent_instance;
+
+ gchar *multikey_accel;
+};
+
+
+GType gschem_action_get_type (void);
+
+GschemAction *gschem_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id,
+ const gchar *multikey_accel);
+
+#endif /* __GSCHEM_ACTION_H__ */
diff --git a/gschem/src/Makefile.am b/gschem/src/Makefile.am
index 765a1b9..1aabef4 100644
--- a/gschem/src/Makefile.am
+++ b/gschem/src/Makefile.am
@@ -16,6 +16,8 @@ gschem_SOURCES = \
g_register.c \
globals.c \
gschem.c \
+ gschem_accel_label.c \
+ gschem_action.c \
gschem_cairo.c \
gschem_dialog.c \
gschem_toplevel.c \
diff --git a/gschem/src/gschem_accel_label.c b/gschem/src/gschem_accel_label.c
new file mode 100644
index 0000000..ab1419d
--- /dev/null
+++ b/gschem/src/gschem_accel_label.c
@@ -0,0 +1,337 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2009 gEDA Contributors (see ChangeLog for details)
+ *
+ * Code based on GTK 2.14.5 gtk/gtkaccellabel.c (LGPL)
+ *
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * GschemAccelLabel: GtkLabel with accelerator monitoring facilities.
+ * Copyright (C) 1998 Tim Janik
+ *
+ * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ *
+ * Adapted for gEDA by Peter Clifton <pcjc2@xxxxxxxxx>
+ *
+ * THIS FILE IS LGPL LICENSED, gEDA AS A WHOLE IS GPL LICENSED
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gschem.h"
+
+enum {
+ PROP_0,
+ PROP_ACCEL_CLOSURE,
+ PROP_ACCEL_WIDGET,
+ PROP_ACCEL_STRING,
+};
+
+G_DEFINE_TYPE (GschemAccelLabel, gschem_accel_label, GTK_TYPE_ACCEL_LABEL)
+
+
+gboolean
+gschem_accel_label_refetch (GschemAccelLabel *accel_label)
+{
+ gboolean enable_accels;
+
+ g_return_val_if_fail (GSCHEM_IS_ACCEL_LABEL (accel_label), FALSE);
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (accel_label)),
+ "gtk-enable-accels", &enable_accels,
+ NULL);
+
+ if (!enable_accels || accel_label->accel_string == NULL) {
+ if (accel_label->accel_string != NULL)
+ g_free (accel_label->accel_string);
+
+ accel_label->accel_string = g_strdup ("");
+ }
+
+ gtk_widget_queue_resize (GTK_WIDGET (accel_label));
+
+ return FALSE;
+}
+
+
+static const gchar *
+gschem_accel_label_get_string (GschemAccelLabel *accel_label)
+{
+ if (!accel_label->accel_string)
+ gschem_accel_label_refetch (accel_label);
+
+ return accel_label->accel_string;
+}
+
+
+static void
+gschem_accel_label_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GschemAccelLabel *accel_label;
+
+ accel_label = GSCHEM_ACCEL_LABEL (object);
+
+ switch (prop_id) {
+ /* Dummy properties from GtkAccelLabel */
+ case PROP_ACCEL_CLOSURE:
+ case PROP_ACCEL_WIDGET:
+ break;
+
+ case PROP_ACCEL_STRING:
+ gschem_accel_label_set_accel_string (accel_label, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gschem_accel_label_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GschemAccelLabel *accel_label;
+
+ accel_label = GSCHEM_ACCEL_LABEL (object);
+
+ switch (prop_id) {
+ /* Dummy property from GtkAccelLabel */
+ case PROP_ACCEL_CLOSURE:
+ g_value_set_boxed (value, NULL);
+ break;
+
+ /* Dummy property from GtkAccelLabel */
+ case PROP_ACCEL_WIDGET:
+ g_value_set_object (value, NULL);
+ break;
+
+ case PROP_ACCEL_STRING:
+ g_value_set_string (value, accel_label->accel_string);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gschem_accel_label_init (GschemAccelLabel *accel_label)
+{
+ accel_label->accel_padding = 3;
+ accel_label->accel_string = NULL;
+}
+
+static void
+gschem_accel_label_finalize (GObject *object)
+{
+ GschemAccelLabel *accel_label = GSCHEM_ACCEL_LABEL (object);
+
+ g_free (accel_label->accel_string);
+
+ G_OBJECT_CLASS (gschem_accel_label_parent_class)->finalize (object);
+}
+
+guint
+gschem_accel_label_get_accel_width (GschemAccelLabel *accel_label)
+{
+ g_return_val_if_fail (GSCHEM_IS_ACCEL_LABEL (accel_label), 0);
+
+ return (accel_label->accel_string_width +
+ (accel_label->accel_string_width ? accel_label->accel_padding : 0));
+}
+
+static void
+gschem_accel_label_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GschemAccelLabel *accel_label = GSCHEM_ACCEL_LABEL (widget);
+ GtkAccelLabel *gtk_accel_label = GTK_ACCEL_LABEL (widget);
+ PangoLayout *layout;
+ gint width;
+
+ GTK_WIDGET_CLASS (gschem_accel_label_parent_class)->size_request (widget, requisition);
+
+ layout = gtk_widget_create_pango_layout (widget, gschem_accel_label_get_string (accel_label));
+ pango_layout_get_pixel_size (layout, &width, NULL);
+ accel_label->accel_string_width = width;
+ gtk_accel_label->accel_string_width = width; /* HACK: This field is private to GtkAccelLabel */
+ g_object_unref (layout);
+}
+
+static gint
+get_first_baseline (PangoLayout *layout)
+{
+ PangoLayoutIter *iter;
+ gint result;
+
+ iter = pango_layout_get_iter (layout);
+ result = pango_layout_iter_get_baseline (iter);
+ pango_layout_iter_free (iter);
+
+ return PANGO_PIXELS (result);
+}
+
+static gboolean
+gschem_accel_label_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ GschemAccelLabel *accel_label = GSCHEM_ACCEL_LABEL (widget);
+ GtkMisc *misc = GTK_MISC (accel_label);
+ GtkTextDirection direction;
+
+ direction = gtk_widget_get_direction (widget);
+
+ if (GTK_WIDGET_DRAWABLE (accel_label))
+ {
+ guint ac_width;
+
+ ac_width = gschem_accel_label_get_accel_width (accel_label);
+
+ if (widget->allocation.width >= widget->requisition.width + ac_width)
+ {
+ PangoLayout *label_layout;
+ PangoLayout *accel_layout;
+ GtkLabel *label = GTK_LABEL (widget);
+
+ gint x;
+ gint y;
+
+ label_layout = gtk_label_get_layout (GTK_LABEL (accel_label));
+
+ if (direction == GTK_TEXT_DIR_RTL)
+ widget->allocation.x += ac_width;
+ widget->allocation.width -= ac_width;
+ if (gtk_label_get_ellipsize (label))
+ pango_layout_set_width (label_layout,
+ pango_layout_get_width (label_layout)
+ - ac_width * PANGO_SCALE);
+
+ if (GTK_WIDGET_CLASS (gschem_accel_label_parent_class)->expose_event)
+ GTK_WIDGET_CLASS (gschem_accel_label_parent_class)->expose_event (widget, event);
+ if (direction == GTK_TEXT_DIR_RTL)
+ widget->allocation.x -= ac_width;
+ widget->allocation.width += ac_width;
+ if (gtk_label_get_ellipsize (label))
+ pango_layout_set_width (label_layout,
+ pango_layout_get_width (label_layout)
+ + ac_width * PANGO_SCALE);
+
+ if (direction == GTK_TEXT_DIR_RTL)
+ x = widget->allocation.x + misc->xpad;
+ else
+ x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width;
+
+ gtk_label_get_layout_offsets (GTK_LABEL (accel_label), NULL, &y);
+
+ accel_layout = gtk_widget_create_pango_layout (widget, gschem_accel_label_get_string (accel_label));
+
+ y += get_first_baseline (label_layout) - get_first_baseline (accel_layout);
+
+ gtk_paint_layout (widget->style,
+ widget->window,
+ GTK_WIDGET_STATE (widget),
+ FALSE,
+ &event->area,
+ widget,
+ "accellabel",
+ x, y,
+ accel_layout);
+
+ g_object_unref (accel_layout);
+ }
+ else
+ {
+ if (GTK_WIDGET_CLASS (gschem_accel_label_parent_class)->expose_event)
+ GTK_WIDGET_CLASS (gschem_accel_label_parent_class)->expose_event (widget, event);
+ }
+ }
+
+ return FALSE;
+}
+
+
+/**
+ * gschem_accel_label_set_accel_string:
+ * @accel_label: a #GschemAccelLabel
+ * @accel_string: the accelerator string.
+ *
+ * Sets the accelerator string for this accelerator label.
+ **/
+void
+gschem_accel_label_set_accel_string (GschemAccelLabel *accel_label,
+ const gchar *accel_string)
+{
+ g_return_if_fail (GSCHEM_IS_ACCEL_LABEL (accel_label));
+
+ if (accel_label->accel_string)
+ g_free (accel_label->accel_string);
+
+ if (accel_string) {
+ accel_label->accel_string = g_strdup (accel_string);
+ } else {
+ accel_label->accel_string = NULL;
+ }
+
+ g_object_notify (G_OBJECT (accel_label), "accel-string");
+}
+
+static void
+gschem_accel_label_class_init (GschemAccelLabelClass *class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ gobject_class->finalize = gschem_accel_label_finalize;
+ gobject_class->set_property = gschem_accel_label_set_property;
+ gobject_class->get_property = gschem_accel_label_get_property;
+
+ widget_class->size_request = gschem_accel_label_size_request;
+ widget_class->expose_event = gschem_accel_label_expose_event;
+
+ g_object_class_install_property (gobject_class,
+ PROP_ACCEL_CLOSURE,
+ g_param_spec_boxed ("accel-closure",
+ _("Accelerator Closure"),
+ _("The closure to be monitored for accelerator changes"),
+ G_TYPE_CLOSURE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_ACCEL_WIDGET,
+ g_param_spec_object ("accel-widget",
+ _("Accelerator Widget"),
+ _("The widget to be monitored for accelerator changes"),
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_ACCEL_STRING,
+ g_param_spec_string ("accel-string",
+ _("Accelerator String"),
+ _("The accelerator string to be displayed"),
+ NULL,
+ G_PARAM_READWRITE));
+}
diff --git a/gschem/src/gschem_action.c b/gschem/src/gschem_action.c
new file mode 100644
index 0000000..428a831
--- /dev/null
+++ b/gschem/src/gschem_action.c
@@ -0,0 +1,237 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2009 Ales Hvezda
+ * Copyright (C) 1998-2009 gEDA Contributors (see ChangeLog for details)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+ */
+
+#include <config.h>
+
+#include "gschem.h"
+
+
+enum {
+ PROP_MULTIKEY_ACCEL = 1,
+};
+
+
+static GObjectClass *gschem_action_parent_class = NULL;
+
+
+/*! \brief GObject finalise handler
+ *
+ * \par Function Description
+ * Just before the GschemAction GObject is finalized, free our
+ * allocated data, and then chain up to the parent's finalize handler.
+ *
+ * \param [in] widget The GObject being finalized.
+ */
+static void gschem_action_finalize (GObject *object)
+{
+ GschemAction *action = GSCHEM_ACTION (object);
+
+ g_free (action->multikey_accel);
+
+ G_OBJECT_CLASS (gschem_action_parent_class)->finalize (object);
+}
+
+
+/*! \brief GObject property setter function
+ *
+ * \par Function Description
+ * Setter function for GschemAction's GObject properties,
+ * "settings-name" and "toplevel".
+ *
+ * \param [in] object The GObject whose properties we are setting
+ * \param [in] property_id The numeric id. under which the property was
+ * registered with g_object_class_install_property()
+ * \param [in] value The GValue the property is being set from
+ * \param [in] pspec A GParamSpec describing the property being set
+ */
+static void gschem_action_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ GschemAction *action = GSCHEM_ACTION (object);
+
+ switch(property_id) {
+ case PROP_MULTIKEY_ACCEL:
+ g_free (action->multikey_accel);
+ action->multikey_accel = g_strdup (g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+
+/*! \brief GObject property getter function
+ *
+ * \par Function Description
+ * Getter function for GschemAction's GObject properties,
+ * "settings-name" and "toplevel".
+ *
+ * \param [in] object The GObject whose properties we are getting
+ * \param [in] property_id The numeric id. under which the property was
+ * registered with g_object_class_install_property()
+ * \param [out] value The GValue in which to return the value of the property
+ * \param [in] pspec A GParamSpec describing the property being got
+ */
+static void gschem_action_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ GschemAction *action = GSCHEM_ACTION (object);
+
+ switch(property_id) {
+ case PROP_MULTIKEY_ACCEL:
+ g_value_set_string (value, action->multikey_accel);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+
+}
+
+static void
+gschem_action_connect_proxy (GtkAction *action,
+ GtkWidget *proxy)
+{
+ GschemAction *gs_action = GSCHEM_ACTION (action);
+ char *label_string;
+
+ /* Override the type of label widget used with the menu item */
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ GtkWidget *label;
+
+ label = GTK_BIN (proxy)->child;
+
+ /* make sure label is a GschemAccelLabel */
+ if (label && !GSCHEM_IS_ACCEL_LABEL (label)) {
+ gtk_container_remove (GTK_CONTAINER (proxy), label);
+ label = NULL;
+ }
+
+ if (label == NULL) {
+ g_object_get (action, "label", &label_string, NULL);
+ label = g_object_new (GSCHEM_TYPE_ACCEL_LABEL,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ "visible", TRUE,
+ "parent", proxy,
+ "label", label_string,
+ "accel-string", gs_action->multikey_accel,
+ NULL);
+ }
+ }
+
+ /* Let the parent class do its work now we've fiddled with the label */
+ GTK_ACTION_CLASS (gschem_action_parent_class)->connect_proxy (action, proxy);
+}
+
+
+/*! \brief GType class initialiser for GschemAction
+ *
+ * \par Function Description
+ * GType class initialiser for GschemAction. We override our parent
+ * virtual class methods as needed and register our GObject properties.
+ *
+ * \param [in] klass The GschemActionClass we are initialising
+ */
+static void gschem_action_class_init (GschemActionClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkActionClass *gtkaction_class = GTK_ACTION_CLASS (klass);
+
+ gtkaction_class->connect_proxy = gschem_action_connect_proxy;
+
+ gobject_class->finalize = gschem_action_finalize;
+ gobject_class->set_property = gschem_action_set_property;
+ gobject_class->get_property = gschem_action_get_property;
+
+ gschem_action_parent_class = g_type_class_peek_parent (klass);
+
+ g_object_class_install_property (
+ gobject_class, PROP_MULTIKEY_ACCEL,
+ g_param_spec_string ("multikey-accel",
+ "",
+ "",
+ NULL,
+ G_PARAM_READWRITE));
+}
+
+
+/*! \brief Function to retrieve GschemAction's GType identifier.
+ *
+ * \par Function Description
+ * Function to retrieve GschemAction's GType identifier.
+ * Upon first call, this registers the GschemAction in the GType system.
+ * Subsequently it returns the saved value from its first execution.
+ *
+ * \return the GType identifier associated with GschemAction.
+ */
+GType gschem_action_get_type ()
+{
+ static GType gschem_action_type = 0;
+
+ if (!gschem_action_type) {
+ static const GTypeInfo gschem_action_info = {
+ sizeof(GschemActionClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gschem_action_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof(GschemAction),
+ 0, /* n_preallocs */
+ NULL, /* instance_init */
+ };
+
+ gschem_action_type = g_type_register_static (GTK_TYPE_ACTION,
+ "GschemAction",
+ &gschem_action_info, 0);
+ }
+
+ return gschem_action_type;
+}
+
+
+/*! /brief Creates a new GschemAction object
+ *
+ * /par Function Descriptions
+ *
+ * Creates a new GschemAction object.
+ *
+ * /param [in] name A unique name for the action
+ * /param [in] label The label displayed in menu items and on buttons, or NULL
+ * /param [in] tooltip A tooltip for the action, or NULL
+ * /param [in] stock_id The stock icon to display in widgets representing the action, or NULL
+ * /param [in] multikey_accel The (potentially) multi-key accelerator used for this action
+ *
+ * /returns A new GschemAction
+ */
+GschemAction *gschem_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id,
+ const gchar *multikey_accel)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_object_new (GSCHEM_TYPE_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ "multikey-accel", multikey_accel,
+ NULL);
+}
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index 926246c..0aff7ba 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -84,6 +84,7 @@ static void g_menu_execute(char *func)
void get_main_menu(GtkWidget ** menubar)
{
char *buf;
+ GschemAction *action;
GtkWidget *menu_item;
GtkWidget *root_menu;
GtkWidget *menu_bar;
@@ -103,12 +104,7 @@ void get_main_menu(GtkWidget ** menubar)
char *menu_item_func;
char *menu_item_hotkey_func;
char *menu_item_keys;
- char *spaces;
int i, j;
- int pad;
- int sum, diff, max_size, space_size;
- PangoLayout *layout;
- int name_width, keys_width;
menu_bar = gtk_menu_bar_new ();
for (i = 0 ; i < s_menu_return_num(); i++) {
@@ -125,15 +121,6 @@ void get_main_menu(GtkWidget ** menubar)
gtk_menu_append(GTK_MENU(menu), menu_item);
gtk_widget_show(menu_item);
- layout = gtk_widget_create_pango_layout(menu, " ");
- pango_layout_get_pixel_size(layout, &space_size, NULL);
- g_object_unref(layout);
-
- layout = gtk_widget_create_pango_layout(menu,
- "123456789012345678901234567890");
- pango_layout_get_pixel_size(layout, &max_size, NULL);
- g_object_unref(layout);
-
scm_items_len = (int) scm_ilength (scm_items);
for (j = 0 ; j < scm_items_len; j++) {
@@ -155,47 +142,31 @@ void get_main_menu(GtkWidget ** menubar)
if (strcmp(menu_item_name, "SEPARATOR") == 0) {
menu_item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), menu_item);
- } else {
+ } else {
buf = g_strdup_printf("(find-key '%s)", menu_item_hotkey_func);
scm_keys = g_scm_c_eval_string_protected (buf);
- g_free(buf);
+ g_free(buf);
+
if (scm_keys == SCM_BOOL_F) {
- menu_item_keys = g_strdup (" ");
+ menu_item_keys = "";
} else {
- menu_item_keys = g_strdup (SCM_STRING_CHARS (scm_keys));
- }
-
- layout = gtk_widget_create_pango_layout(menu, menu_item_name);
- pango_layout_get_pixel_size(layout, &name_width, NULL);
- g_object_unref(layout);
-
- layout = gtk_widget_create_pango_layout(menu, menu_item_keys);
- pango_layout_get_pixel_size(layout, &keys_width, NULL);
- g_object_unref(layout);
-
- sum = name_width + keys_width;
-
- diff = max_size - sum;
- pad = diff/space_size;
- if (pad < 0) {
- pad = 1;
- }
-
- spaces = g_strnfill (pad, ' ');
- buf = g_strdup_printf("%s%s%s", menu_item_name, spaces, menu_item_keys);
-
- menu_item = gtk_menu_item_new_with_label(buf);
- g_free(buf);
- gtk_menu_append(GTK_MENU(menu), menu_item);
- gtk_signal_connect_object(GTK_OBJECT(menu_item), "activate",
- GTK_SIGNAL_FUNC(g_menu_execute),
- (gpointer) g_strdup (menu_item_func));
- /* The g_strdup is a memory leak, but this is okay. I think. */
- g_free(spaces);
- g_free(menu_item_keys);
+ menu_item_keys = SCM_STRING_CHARS (scm_keys);
+ }
+
+ action = gschem_action_new (menu_item_func, /* Action name */
+ menu_item_name, /* Text */
+ menu_item_name, /* Tooltip */
+ NULL, /* Icon stock ID */
+ menu_item_keys); /* Accelerator string */
+ menu_item = gtk_action_create_menu_item (GTK_ACTION (action));
+ gtk_menu_append (GTK_MENU (menu), menu_item);
+
+ gtk_signal_connect_object (GTK_OBJECT(menu_item), "activate",
+ GTK_SIGNAL_FUNC(g_menu_execute),
+ (gpointer) g_strdup (menu_item_func));
}
-
- gtk_widget_show(menu_item);
+
+ gtk_widget_show (menu_item);
/* add a handle to the menu_bar object to get access to widget objects */
/* This string should NOT be internationalized */
@@ -215,7 +186,7 @@ void get_main_menu(GtkWidget ** menubar)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), root_menu);
}
-
+
g_free(raw_menu_name);
*menubar = menu_bar;
}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs