This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
cygutils - mkshortcut - Patch for --desc option for description/tooltiptext - Needed for new Cygwin/X package
- From: Harold L Hunt II <huntharo at msu dot edu>
- To: cygapps <cygwin-apps at cygwin dot com>
- Date: Wed, 10 Mar 2004 13:49:11 -0500
- Subject: cygutils - mkshortcut - Patch for --desc option for description/tooltiptext - Needed for new Cygwin/X package
Attached is a patch to mkshortcut to allow it to take a [-d|--desc] DESC
option that specifies the text of the description (tooltip text) for the
shortcut. If -d|--desc is not specified, then the previous behavior of
setting the description to the POSIX path to the application is used.
I have build tested and run tested the attached patch.
I need this patch for a replacement for the XFree86-bin-icons package.
I already have the new package in hand, but I need this new
functionality in order for the shortcuts to have meaningful names and
descriptions.
Harold
Index: mkshortcut/mkshortcut.1
===================================================================
RCS file: /cvs/cygwin-apps/cygutils/src/mkshortcut/mkshortcut.1,v
retrieving revision 1.5
diff -u -r1.5 mkshortcut.1
--- mkshortcut/mkshortcut.1 14 Feb 2004 23:34:57 -0000 1.5
+++ mkshortcut/mkshortcut.1 10 Mar 2004 18:43:03 -0000
@@ -1,6 +1,6 @@
.\"{{{}}}
.\"{{{ Title
-.TH MKSHORTCUT 1 "21 Oct 03" "mkshortcut 1.5 (cygutils)" "Cygutils"
+.TH MKSHORTCUT 1 "10 Mar 04" "mkshortcut 1.6 (cygutils)" "Cygutils"
.\"}}}
.\"{{{ Name
.SH NAME
@@ -10,7 +10,8 @@
.SH SYNOPSIS
.B mkshorcut
.RB "[\-\fBa\fP \fIARGS\fP]"
-.RB "[\-\fBi\fP \fIiconfile\fP [\-\fBj\fP \fIINT\fP] ]"
+.RB "[\-\fBd\fP \fIDESC\fP]"
+.RB "[\-\fBi\fP \fIICONFILE\fP [\-\fBj\fP \fIINT\fP] ]"
.RB "[\-\fBn\fP \fINAME\fP ]"
.RB "[\-\fBs\fP \fInorm|min|max\fP ]"
.RB "[\-\fBw\fP \fIPATH\fP ]"
@@ -23,6 +24,10 @@
.TP
\fB\-a\fR, \fB\-\-arguments\fP=\fIARGS\fP
Arguments to use (see example below).
+
+.TP
+\fB\-d\fR, \fB\-\-desc\fR=\fI"DESC"\fP
+Text for description/tooltip (defaults to POSIX path of TARGET). Note that \fI"DESC"\fP can contain spaces, but in that case must be enclosed in quotes.
.TP
\fB\-h\fR, \fB\-\-help\fR
Index: mkshortcut/mkshortcut.c
===================================================================
RCS file: /cvs/cygwin-apps/cygutils/src/mkshortcut/mkshortcut.c,v
retrieving revision 1.6
diff -u -r1.6 mkshortcut.c
--- mkshortcut/mkshortcut.c 14 Feb 2004 23:34:57 -0000 1.6
+++ mkshortcut/mkshortcut.c 10 Mar 2004 18:43:03 -0000
@@ -61,6 +61,7 @@
int show_flag;
int offset;
char * name_arg;
+ char * desc_arg;
char * dir_name_arg;
char * argument_arg;
char * target_arg;
@@ -93,7 +94,7 @@
const char * arg;
struct poptOption helpOptionsTable[] = {
- { "help", 'h', POPT_ARG_NONE, NULL, '?', \
+ { "help", 'h', POPT_ARG_NONE, NULL, '?', \
"Show this help message", NULL},
{ "usage", '\0', POPT_ARG_NONE, NULL, 'u', \
"Display brief usage message", NULL},
@@ -105,24 +106,26 @@
};
struct poptOption generalOptionsTable[] = {
- { "arguments", 'a', POPT_ARG_STRING, NULL, 'a', \
+ { "arguments", 'a', POPT_ARG_STRING, NULL, 'a', \
"Use arguments ARGS", "ARGS"},
+ { "desc", 'd', POPT_ARG_STRING, NULL, 'd', \
+ "Text for description/tooltip (defaults to POSIX path of TARGET)", "DESC"},
{ "icon", 'i', POPT_ARG_STRING, NULL, 'i', \
- "icon file for link to use", "iconfile"},
+ "Icon file for link to use", "ICONFILE"},
{ "iconoffset", 'j', POPT_ARG_INT, &(opts.offset), 'j', \
- "offset of icon in icon file (default is 0)", NULL},
+ "Offset of icon in icon file (default is 0)", NULL},
{ "name", 'n', POPT_ARG_STRING, NULL, 'n', \
- "name for link (defaults to TARGET)", "NAME"},
+ "Name for link (defaults to TARGET)", "NAME"},
{ "show", 's', POPT_ARG_STRING, NULL, 's', \
- "window to show: normal, minimized, maximized", "norm|min|max"},
+ "Window to show: normal, minimized, maximized", "norm|min|max"},
{ "workingdir", 'w', POPT_ARG_STRING, NULL, 'w', \
- "set working directory (defaults to directory path of TARGET)", "PATH"},
+ "Set working directory (defaults to directory path of TARGET)", "PATH"},
{ "allusers", 'A', POPT_ARG_VAL, &(opts.allusers_flag), 1, \
- "use 'All Users' instead of current user for -D,-P", NULL},
+ "Use 'All Users' instead of current user for -D,-P", NULL},
{ "desktop", 'D', POPT_ARG_VAL, &(opts.desktop_flag), 1, \
- "create link relative to 'Desktop' directory", NULL},
+ "Create link relative to 'Desktop' directory", NULL},
{ "smprograms", 'P', POPT_ARG_VAL, &(opts.smprograms_flag), 1, \
- "create link relative to Start Menu 'Programs' directory", NULL},
+ "Create link relative to Start Menu 'Programs' directory", NULL},
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
};
@@ -161,6 +164,7 @@
opts.target_arg = NULL;
opts.argument_arg = NULL;
opts.name_arg = NULL;
+ opts.desc_arg = NULL;
opts.dir_name_arg = NULL;
opts.icon_name_arg = NULL;
@@ -177,6 +181,14 @@
goto exit;
case 'l': license(optCon, stderr, program_name);
goto exit;
+ case 'd': if (arg = poptGetOptArg(optCon)) {
+ if ((opts.desc_arg = strdup(arg)) == NULL ) {
+ fprintf(stderr, "%s: memory allocation error\n", program_name);
+ ec=2;
+ goto exit;
+ }
+ }
+ break;
case 'i': opts.icon_flag = 1;
if (arg = poptGetOptArg(optCon)) {
cygwin_conv_to_full_win32_path (arg, icon_name);
@@ -279,7 +291,7 @@
} else {
// THE MEAT GOES HERE
ec = mkshortcut(opts, optCon);
- }
+ }
} else {
fprintf(stderr, "%s: TARGET not specified\n", program_name);
usage(optCon, stderr, program_name);
@@ -290,6 +302,7 @@
poptFreeContext(optCon);
if (opts.target_arg) { free(opts.target_arg); }
if (opts.name_arg) { free(opts.name_arg); }
+ if (opts.desc_arg) { free(opts.desc_arg); }
if (opts.dir_name_arg) { free(opts.dir_name_arg); }
if (opts.argument_arg) { free(opts.argument_arg); }
if (opts.icon_name_arg) { free(opts.icon_name_arg); }
@@ -302,6 +315,7 @@
char link_name[MAX_PATH];
char exe_name[MAX_PATH];
char dir_name[MAX_PATH];
+ char desc[MAX_PATH];
char *buf_str, *tmp_str;
int tmp;
@@ -450,6 +464,20 @@
strcat (link_name, buf_str);
}
+ /* Setup description text */
+ if (opts.desc_arg != NULL)
+ {
+ strncpy (desc, opts.desc_arg, MAX_PATH);
+
+ /* There won't be a null terminated if strlen(desc_arg)>MAX_PATH */
+ desc[MAX_PATH] = '\0';
+ }
+ else
+ {
+ /* Put the POSIX path in the "Description", just to be nice */
+ cygwin_conv_to_full_posix_path (exe_name, desc);
+ }
+
/* Beginning of Windows interface */
hres = OleInitialize (NULL);
if (hres != S_FALSE && hres != S_OK)
@@ -470,9 +498,7 @@
if (SUCCEEDED (hres))
{
shell_link->lpVtbl->SetPath (shell_link, exe_name);
- /* Put the POSIX path in the "Description", just to be nice */
- cygwin_conv_to_full_posix_path (exe_name, buf_str);
- shell_link->lpVtbl->SetDescription (shell_link, buf_str);
+ shell_link->lpVtbl->SetDescription (shell_link, desc);
shell_link->lpVtbl->SetWorkingDirectory (shell_link, dir_name);
if (opts.argument_arg)
shell_link->lpVtbl->SetArguments (shell_link, opts.argument_arg);