summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>2007-01-14 07:58:02 +0000
committerYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>2007-01-14 07:58:02 +0000
commit28c96b4d924055b20ca2fe827118f9a13224eed0 (patch)
tree95194ef2013d937fac972b112350f4657541e0cc /src
parentde529e210ce8519617bf371f39c677bc974e7d67 (diff)
downloademacs-28c96b4d924055b20ca2fe827118f9a13224eed0.tar.gz
[TARGET_API_MAC_CARBON] (create_and_show_dialog): Use
DisableControl for disabled items. Set default button to first enabled one. Use icon of application in execution.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/macmenu.c47
2 files changed, 42 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3842c3c5824..f30f2a66572 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macmenu.c [TARGET_API_MAC_CARBON] (create_and_show_dialog): Use
+ DisableControl for disabled items. Set default button to first
+ enabled one. Use icon of application in execution.
+
2007-01-13 Eli Zaretskii <eliz@gnu.org>
* process.c (Fdelete_process, Fprocess_id, sigchld_handler): Copy
diff --git a/src/macmenu.c b/src/macmenu.c
index 34e38eb2f47..b412429d696 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -2447,7 +2447,7 @@ create_and_show_dialog (f, first_wv)
short buttons_height, text_height, inner_width, inner_height;
Rect empty_rect, *rects;
WindowRef window = NULL;
- ControlRef *buttons, text;
+ ControlRef *buttons, default_button = NULL, text;
dialog_name = first_wv->name;
nb_buttons = dialog_name[1] - '0';
@@ -2490,6 +2490,13 @@ create_and_show_dialog (f, first_wv)
}
if (err == noErr)
{
+ if (!wv->enabled)
+ err = DisableControl (buttons[i]);
+ else if (default_button == NULL)
+ default_button = buttons[i];
+ }
+ if (err == noErr)
+ {
SInt16 unused;
rects[i] = empty_rect;
@@ -2617,30 +2624,48 @@ create_and_show_dialog (f, first_wv)
/* Create the application icon at the upper-left corner. */
if (err == noErr)
{
- ControlButtonContentInfo button_info;
- IconRef icon_ref;
+ ControlButtonContentInfo content;
ControlRef icon;
+ static const ProcessSerialNumber psn = {0, kCurrentProcess};
+#ifdef MAC_OSX
+ FSRef app_location;
+#else
+ ProcessInfoRec pinfo;
+ FSSpec app_spec;
+#endif
+ SInt16 unused;
- button_info.contentType = kControlContentIconRef;
- err = GetIconRef (kOnAppropriateDisk, MAC_EMACS_CREATOR_CODE,
- kGenericApplicationIcon, &icon_ref);
+ content.contentType = kControlContentIconRef;
+#ifdef MAC_OSX
+ err = GetProcessBundleLocation (&psn, &app_location);
+ if (err == noErr)
+ err = GetIconRefFromFileInfo (&app_location, 0, NULL, 0, NULL,
+ kIconServicesNormalUsageFlag,
+ &content.u.iconRef, &unused);
+#else
+ bzero (&pinfo, sizeof (ProcessInfoRec));
+ pinfo.processInfoLength = sizeof (ProcessInfoRec);
+ pinfo.processAppSpec = &app_spec;
+ err = GetProcessInformation (&psn, &pinfo);
+ if (err == noErr)
+ err = GetIconRefFromFile (&app_spec, &content.u.iconRef, &unused);
+#endif
if (err == noErr)
{
Rect bounds;
- button_info.u.iconRef = icon_ref;
SetRect (&bounds, DIALOG_ICON_LEFT_MARGIN, DIALOG_ICON_TOP_MARGIN,
DIALOG_ICON_LEFT_MARGIN + DIALOG_ICON_WIDTH,
DIALOG_ICON_TOP_MARGIN + DIALOG_ICON_HEIGHT);
- err = CreateIconControl (window, &bounds, &button_info,
- true, &icon);
- ReleaseIconRef (icon_ref);
+ err = CreateIconControl (window, &bounds, &content, true, &icon);
+ ReleaseIconRef (content.u.iconRef);
}
}
/* Show the dialog window and run event loop. */
if (err == noErr)
- err = SetWindowDefaultButton (window, buttons[0]);
+ if (default_button)
+ err = SetWindowDefaultButton (window, default_button);
if (err == noErr)
err = install_dialog_event_handler (window);
if (err == noErr)