~ubuntu-branches/ubuntu/saucy/gimp/saucy-security

« back to all changes in this revision

Viewing changes to plug-ins/help-browser/dialog.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-05-20 19:21:01 UTC
  • mfrom: (1.1.26) (0.4.16 sid)
  • Revision ID: package-import@ubuntu.com-20120520192101-bs7zetx8ffoq2nfv
Tags: 2.8.0-2ubuntu1
* Merge from Debian unstable (LP: #908472). Remaining Changes:
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    + Update some strings for Ubuntu
  - debian/control:
    + Update description
  - debian/rules:
    + Set gettext domain and update translation templates
* Drop the following patches that were applied upstream:
  - debian/patches/ghost-cursor.patch: fix Wacom tablet cursor events
  - debian/patches/embed-page-setup-dialog.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 * dialog.c
10
10
 *
11
 
 * This program is free software; you can redistribute it and/or modify
 
11
 * This program is free software: you can redistribute it and/or modify
12
12
 * it under the terms of the GNU General Public License as published by
13
 
 * the Free Software Foundation; either version 2 of the License, or
 
13
 * the Free Software Foundation; either version 3 of the License, or
14
14
 * (at your option) any later version.
15
15
 *
16
16
 * This program is distributed in the hope that it will be useful,
19
19
 * GNU General Public License for more details.
20
20
 *
21
21
 * You should have received a copy of the GNU General Public License
22
 
 * along with this program; if not, write to the Free Software
23
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
23
 */
25
24
 
26
25
#include "config.h"
172
171
  GtkWidget   *toolbar;
173
172
  GtkWidget   *paned;
174
173
  GtkWidget   *scrolled;
175
 
  GtkWidget   *button;
176
174
  GtkToolItem *item;
177
175
  GtkAction   *action;
178
176
  DialogData   data = { 720, 560, 240, TRUE, 1.0 };
194
192
 
195
193
  window_set_icons (window);
196
194
 
197
 
  vbox = gtk_vbox_new (FALSE, 2);
 
195
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
198
196
  gtk_container_add (GTK_CONTAINER (window), vbox);
199
197
  gtk_widget_show (vbox);
200
198
 
211
209
 
212
210
  action = gtk_ui_manager_get_action (ui_manager,
213
211
                                      "/ui/help-browser-popup/forward");
214
 
  gtk_action_connect_proxy (action, GTK_WIDGET (item));
 
212
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
215
213
  g_object_notify (G_OBJECT (action), "tooltip");
216
214
  button_next = GTK_WIDGET (item);
217
215
 
221
219
 
222
220
  action = gtk_ui_manager_get_action (ui_manager,
223
221
                                      "/ui/help-browser-popup/back");
224
 
  gtk_action_connect_proxy (action, GTK_WIDGET (item));
 
222
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
225
223
  g_object_notify (G_OBJECT (action), "tooltip");
226
224
  button_prev = GTK_WIDGET (item);
227
225
 
231
229
  gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
232
230
  gtk_tool_item_set_expand (item, TRUE);
233
231
 
234
 
  button = gtk_ui_manager_get_widget (ui_manager,
235
 
                                      "/help-browser-toolbar/website");
236
 
 
237
232
  /*  the horizontal paned  */
238
 
  paned = gtk_hpaned_new ();
 
233
  paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
239
234
  gtk_box_pack_start (GTK_BOX (vbox), paned, TRUE, TRUE, 0);
240
235
  gtk_widget_show (paned);
241
236
 
266
261
                    NULL);
267
262
 
268
263
  /*  HTML view  */
269
 
  main_vbox = gtk_vbox_new (FALSE, 0);
 
264
  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
270
265
  gtk_widget_show (main_vbox);
271
266
  gtk_paned_pack2 (GTK_PANED (paned), main_vbox, TRUE, TRUE);
272
267
 
356
351
                                                   sizes[i], NULL));
357
352
 
358
353
  gtk_window_set_icon_list (GTK_WINDOW (window), list);
359
 
  g_list_foreach (list, (GFunc) g_object_unref, NULL);
360
 
  g_list_free (list);
 
354
 
 
355
  g_list_free_full (list, (GDestroyNotify) g_object_unref);
361
356
}
362
357
 
363
358
static void
365
360
                                   GimpHelpItem   *item,
366
361
                                   GimpHelpLocale *locale)
367
362
{
368
 
#if 0
 
363
  gchar *sort_key = item->title;
 
364
 
 
365
#if DEBUG_SORT_HELP_ITEMS
369
366
  g_printerr ("%s: processing %s (parent %s)\n",
370
367
              G_STRFUNC,
371
368
              item->title  ? item->title  : "NULL",
372
369
              item->parent ? item->parent : "NULL");
373
370
#endif
374
371
 
375
 
  if (item->title)
376
 
    {
377
 
      gchar **indices = g_strsplit (item->title, ".", -1);
 
372
  if (item->sort &&
 
373
      g_regex_match_simple ("^[0-9]+([.][0-9]+)*$", item->sort, 0, 0))
 
374
    {
 
375
      sort_key = item->sort;
 
376
 
 
377
#if DEBUG_SORT_HELP_ITEMS
 
378
      g_printerr ("%s: sort key = %s\n", G_STRFUNC, sort_key);
 
379
#endif
 
380
    }
 
381
 
 
382
  item->index = 0;
 
383
 
 
384
  if (sort_key)
 
385
    {
 
386
      const gint max_tokens = GIMP_HELP_BROWSER_INDEX_MAX_DEPTH;
 
387
      gchar* *indices = g_strsplit (sort_key, ".", max_tokens + 1);
378
388
      gint    i;
379
389
 
380
 
      for (i = 0; i < 5; i++)
 
390
      for (i = 0; i < max_tokens; i++)
381
391
        {
382
392
          gunichar c;
383
393
 
384
394
          if (! indices[i])
385
 
            break;
 
395
            {
 
396
              /* make sure that all item->index's are comparable */
 
397
              item->index <<= (8 * (max_tokens - i));
 
398
              break;
 
399
            }
386
400
 
 
401
          item->index <<= 8;  /* NOP if i = 0 */
387
402
          c = g_utf8_get_char (indices[i]);
388
 
 
389
403
          if (g_unichar_isdigit (c))
390
404
            {
391
 
              item->index += atoi (indices[i]) << (8 * (5 - i));
 
405
              item->index += atoi (indices[i]);
392
406
            }
393
407
          else if (g_utf8_strlen (indices[i], -1) == 1)
394
408
            {
395
 
              item->index += (c & 0xFF) << (8 * (5 - i));
 
409
              item->index += (c & 0xFF);
396
410
            }
397
411
        }
398
412
 
399
413
      g_strfreev (indices);
 
414
 
 
415
#if DEBUG_SORT_HELP_ITEMS
 
416
      g_printerr ("%s: index = %lu\n", G_STRFUNC, item->index);
 
417
#endif
400
418
    }
401
419
 
402
420
  if (item->parent && strlen (item->parent))
839
857
show_index_callback (GtkAction *action,
840
858
                     gpointer   data)
841
859
{
842
 
  if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
843
 
    {
844
 
      gtk_widget_show (sidebar);
845
 
    }
846
 
  else
847
 
    {
848
 
      gtk_widget_hide (sidebar);
849
 
    }
 
860
  gtk_widget_set_visible (sidebar,
 
861
                          gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
850
862
}
851
863
 
852
864
static void
985
997
  action = gtk_ui_manager_get_action (ui_manager,
986
998
                                      "/ui/help-browser-popup/show-index");
987
999
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
988
 
                                GTK_WIDGET_VISIBLE (sidebar));
 
1000
                                gtk_widget_get_visible (sidebar));
989
1001
}
990
1002
 
991
1003
static void
1028
1040
  gtk_window_get_size (GTK_WINDOW (window), &data.width, &data.height);
1029
1041
 
1030
1042
  data.paned_position = gtk_paned_get_position (GTK_PANED (paned));
1031
 
  data.show_index     = GTK_WIDGET_VISIBLE (sidebar);
 
1043
  data.show_index     = gtk_widget_get_visible (sidebar);
1032
1044
 
1033
1045
  data.zoom = (view ?
1034
1046
               webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW (view)) : 1.0);
1084
1096
view_button_press (GtkWidget      *widget,
1085
1097
                   GdkEventButton *event)
1086
1098
{
1087
 
  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
 
1099
  if (gdk_event_triggers_context_menu ((GdkEvent *) event))
1088
1100
    return view_popup_menu (widget, event);
1089
1101
 
1090
1102
  return FALSE;
1094
1106
view_key_press (GtkWidget   *widget,
1095
1107
                GdkEventKey *event)
1096
1108
{
1097
 
  if (event->keyval == GDK_slash)
 
1109
  if (event->keyval == GDK_KEY_slash)
1098
1110
    {
1099
1111
      GtkAction *action;
1100
1112
 
1157
1169
  GtkWidget *hbox;
1158
1170
  GtkWidget *label;
1159
1171
 
1160
 
  hbox = gtk_hbox_new (FALSE, 6);
 
1172
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
1161
1173
 
1162
1174
  label = gtk_label_new (_("Find:"));
1163
1175
  gtk_widget_show (label);
1229
1241
{
1230
1242
  switch (event->keyval)
1231
1243
    {
1232
 
    case GDK_Escape:
 
1244
    case GDK_KEY_Escape:
1233
1245
      gtk_widget_hide (searchbar);
1234
1246
      webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
1235
1247
      return TRUE;
1236
1248
 
1237
 
    case GDK_Return:
1238
 
    case GDK_KP_Enter:
1239
 
    case GDK_ISO_Enter:
 
1249
    case GDK_KEY_Return:
 
1250
    case GDK_KEY_KP_Enter:
 
1251
    case GDK_KEY_ISO_Enter:
1240
1252
      search (gtk_entry_get_text (GTK_ENTRY (entry)), TRUE);
1241
1253
      return TRUE;
1242
1254
    }