home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / old / 5.6.029 < prev    next >
Encoding:
Internet Message Format  |  2000-03-24  |  4.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.029
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.029 
  8. Problem:    GTK GUI: Shortcut keys cannot be used for a dialog. (Johannes
  9.             Zellner)
  10. Solution:   Add support for shortcut keys. (Marcin Dalecki)
  11. Files:      src/gui_gtk.c
  12.  
  13.  
  14. *** ../vim-5.6.28/src/gui_gtk.c    Fri Jan 21 11:10:27 2000
  15. --- src/gui_gtk.c    Sat Mar 25 21:08:19 2000
  16. ***************
  17. *** 947,952 ****
  18. --- 947,953 ----
  19.   {
  20.       char_u *names;
  21.       char_u *p;
  22. +     int i;
  23.       int butcount;
  24.       int dialog_status = -1;
  25.   
  26. ***************
  27. *** 959,964 ****
  28. --- 960,966 ----
  29.       GtkWidget *action_area;
  30.       GtkWidget *sub_area;
  31.       GtkWidget *separator;
  32. +     GtkAccelGroup *accel_group;
  33.   
  34.       GdkPixmap *icon = NULL;
  35.       GdkBitmap *mask = NULL;
  36. ***************
  37. *** 1057,1086 ****
  38.       gtk_box_pack_start(GTK_BOX(action_area), sub_area, FALSE, TRUE, 0);
  39.       gtk_widget_show(sub_area);
  40.   
  41. -     /* make a copy, so that we can insert NULs */
  42. -     names = vim_strsave(buttons);
  43. -     if (names == NULL)
  44. -     return -1;
  45.       /*
  46.        * Create the buttons.
  47.        */
  48.       p = names;
  49.       for (butcount = 0; butcount < MAXBUT; ++butcount) {
  50.       char_u *next;
  51.   
  52.       for (next = p; *next; ++next) {
  53. -         if (*next == DLG_HOTKEY_CHAR)
  54. -         mch_memmove(next, next + 1, STRLEN(next));
  55.           if (*next == DLG_BUTTON_SEP) {
  56.           *next++ = NUL;
  57.           break;
  58.           }
  59.       }
  60.   
  61. !     button[butcount] = gtk_button_new_with_label((const gchar *)p);
  62.       GTK_WIDGET_SET_FLAGS(button[butcount], GTK_CAN_DEFAULT);
  63. !     gtk_widget_show(button[butcount]);
  64.   
  65.       data[butcount].status = &dialog_status;
  66.       data[butcount].index = butcount;
  67. --- 1059,1135 ----
  68.       gtk_box_pack_start(GTK_BOX(action_area), sub_area, FALSE, TRUE, 0);
  69.       gtk_widget_show(sub_area);
  70.   
  71.       /*
  72.        * Create the buttons.
  73.        */
  74. +     /*
  75. +      * Translate the Vim accelerator character into an underscore for GTK+.
  76. +      * Double underscores to keep them in the label.
  77. +      */
  78. +     /* count the number of underscores */
  79. +     i = 1;
  80. +     for (p = buttons; *p; ++p)
  81. +     if (*p == '_')
  82. +         ++i;
  83. +     /* make a copy of "buttons" with the translated characters */
  84. +     names = alloc(STRLEN(buttons) + i);
  85. +     if (names == NULL)
  86. +     return -1;
  87. +     p = names;
  88. +     for (i = 0; buttons[i]; ++i)
  89. +     {
  90. +     if (buttons[i] == DLG_HOTKEY_CHAR)
  91. +         *p++ = '_';
  92. +     else
  93. +     {
  94. +         if (buttons[i] == '_')
  95. +         *p++ = '_';
  96. +         *p++ = buttons[i];
  97. +     }
  98. +     }
  99. +     *p = NUL;
  100. +     /* Attach the new accelerator group to the window. */
  101. +     accel_group = gtk_accel_group_new();
  102. +     gtk_accel_group_attach(accel_group, GTK_OBJECT(dialog));
  103.       p = names;
  104.       for (butcount = 0; butcount < MAXBUT; ++butcount) {
  105.       char_u *next;
  106. +     GtkWidget *label;
  107. +     guint accel_key;
  108.   
  109. +     /* Chunk out this single button. */
  110.       for (next = p; *next; ++next) {
  111.           if (*next == DLG_BUTTON_SEP) {
  112.           *next++ = NUL;
  113.           break;
  114.           }
  115.       }
  116.   
  117. !     button[butcount] = gtk_button_new();
  118.       GTK_WIDGET_SET_FLAGS(button[butcount], GTK_CAN_DEFAULT);
  119. !     label = gtk_accel_label_new("");
  120. !         gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), dialog);
  121. !     accel_key = gtk_label_parse_uline(GTK_LABEL(label), p);
  122. ! # ifdef GTK_USE_ACCEL
  123. !     /* Don't add accelator if 'winaltkeys' is "no". */
  124. !     if (accel_key != GDK_VoidSymbol) {
  125. !         gtk_widget_add_accelerator(button[butcount],
  126. !             "clicked",
  127. !             accel_group,
  128. !             accel_key, 0,
  129. !             0);
  130. !     }
  131. ! # endif
  132. !     gtk_container_add(GTK_CONTAINER(button[butcount]), label);
  133. !     gtk_widget_show_all(button[butcount]);
  134.   
  135.       data[butcount].status = &dialog_status;
  136.       data[butcount].index = butcount;
  137. ***************
  138. *** 1100,1105 ****
  139. --- 1149,1155 ----
  140.       }
  141.       p = next;
  142.       }
  143.       vim_free(names);
  144.   
  145.       --def_but;        /* 1 is first button */
  146. ***************
  147. *** 1124,1129 ****
  148. --- 1174,1183 ----
  149.   
  150.       if (dialog_status < 0)
  151.       dialog_status = 0;
  152. +     /* let the garbage collector know that we don't need it anylonger */
  153. +     gtk_accel_group_unref(accel_group);
  154.       return dialog_status;
  155.   }
  156.   
  157. *** ../vim-5.6.28/src/version.c    Sat Mar 25 20:39:12 2000
  158. --- src/version.c    Sat Mar 25 21:19:02 2000
  159. ***************
  160. *** 420,421 ****
  161. --- 420,423 ----
  162.   {   /* Add new patch number below this line */
  163. + /**/
  164. +     29,
  165.   /**/
  166.  
  167. -- 
  168. TALL KNIGHT OF NI: Ni!
  169.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  170.  
  171. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  172. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  173.