glade-popup.c 21.1 KB
Newer Older
Jose Maria Celorio's avatar
Jose Maria Celorio committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (C) 2001 Ximian, Inc.
 *
 * 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
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jose Maria Celorio's avatar
Jose Maria Celorio committed
17 18 19
 *
 * Authors:
 *   Chema Celorio <chema@celorio.com>
20
 *   Tristan Van Berkom <tvb@gnome.org>
Jose Maria Celorio's avatar
Jose Maria Celorio committed
21 22
 */

23 24 25 26 27 28
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib/gi18n-lib.h>

Jose Maria Celorio's avatar
Jose Maria Celorio committed
29 30
#include "glade.h"
#include "glade-widget.h"
31
#include "glade-widget-adaptor.h"
Jose Maria Celorio's avatar
Jose Maria Celorio committed
32
#include "glade-popup.h"
33
#include "glade-placeholder.h"
34 35
#include "glade-clipboard.h"
#include "glade-command.h"
Joaquín Cuenca Abela's avatar
Joaquín Cuenca Abela committed
36
#include "glade-project.h"
37
#include "glade-app.h"
38

39
static void
40
glade_popup_docs_cb (GtkMenuItem *item, GladeWidgetAdaptor *adaptor)
41 42 43
{
  g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));

44
  glade_app_search_docs (glade_widget_adaptor_get_book (adaptor),
45
                         glade_widget_adaptor_get_display_name (adaptor),
46
                         NULL);
47 48
}

49 50 51
/********************************************************
                      WIDGET POPUP
 *******************************************************/
Jose Maria Celorio's avatar
Jose Maria Celorio committed
52
static void
53
glade_popup_select_cb (GtkMenuItem *item, GladeWidget *widget)
Jose Maria Celorio's avatar
Jose Maria Celorio committed
54
{
55
  glade_project_selection_set (glade_widget_get_project (widget),
56
                               glade_widget_get_object (widget), TRUE);
57
}
58

59
typedef struct {
60
  GladeWidgetAdaptor *adaptor;
61 62 63 64
  GladeProject       *project;
  GladeWidget        *parent;
  GladePlaceholder   *placeholder;
} RootAddData;
65

66 67 68 69
static void
glade_popup_widget_add_cb (GtkMenuItem *item, RootAddData *data)
{
  g_return_if_fail (data->adaptor != NULL);
70

71 72
  if (glade_command_create (data->adaptor, data->parent,
                            data->placeholder, data->project))
73

74
    glade_project_set_add_item (data->project, NULL);
75 76 77
}

static void
78
glade_popup_root_add_cb (GtkMenuItem *item, RootAddData *data)
79
{
80
  glade_command_create (data->adaptor, NULL, NULL, data->project);
81 82
}

83
static void
84
glade_popup_cut_cb (GtkMenuItem *item, GladeWidget *widget)
85
{
86
  GladeProject *project = glade_widget_get_project (widget);
87

88 89 90 91 92 93
  /* Assign selection first only if its not already assigned (it may be a delete
   * of multiple widgets) */
  if (!glade_project_is_selected (project, glade_widget_get_object (widget)))
    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);

  glade_project_command_cut (project);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
94 95 96
}

static void
97
glade_popup_copy_cb (GtkMenuItem *item, GladeWidget *widget)
Jose Maria Celorio's avatar
Jose Maria Celorio committed
98
{
99
  GladeProject *project = glade_widget_get_project (widget);
100

101
  /* Assign selection first */
102
  if (!glade_project_is_selected (project, glade_widget_get_object (widget)))
103
    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
104

105
  glade_project_copy_selection (project);
106
}
Jose Maria Celorio's avatar
Jose Maria Celorio committed
107

108
static void
109
glade_popup_paste_cb (GtkMenuItem *item, gpointer data)
110
{
111 112 113 114 115 116 117 118 119 120 121 122 123
  GladeWidget  *widget = NULL;
  GladeProject *project;

  if (GLADE_IS_WIDGET (data))
    {
      widget  = GLADE_WIDGET (data);
      project = glade_widget_get_project (widget);
    }
  else if (GLADE_IS_PROJECT (data))
    project = GLADE_PROJECT (data);
  else
    g_return_if_reached ();

124 125
  /* The selected widget is the paste destination */
  if (widget)
126
    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
127
  else
128
    glade_project_selection_clear (project, FALSE);
129

130
  glade_project_command_paste (project, NULL);
131
}
Jose Maria Celorio's avatar
Jose Maria Celorio committed
132

133
static void
134
glade_popup_delete_cb (GtkMenuItem *item, GladeWidget *widget)
135
{
136
  GladeProject *project = glade_widget_get_project (widget);
137

138 139 140
  /* Assign selection first */
  if (glade_project_is_selected
      (project, glade_widget_get_object (widget)) == FALSE)
141
    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
142

143
  glade_project_command_delete (project);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
144
}
145

146 147 148
/********************************************************
                  PLACEHOLDER POPUP
 *******************************************************/
149
static void
150
glade_popup_placeholder_paste_cb (GtkMenuItem      *item, 
151
                                  GladePlaceholder *placeholder)
152
{
153
  GladeProject *project;
154

155
  project = glade_placeholder_get_project (placeholder);
156

157
  glade_project_selection_clear (project, FALSE);
158

159
  glade_project_command_paste (project, placeholder);
160 161
}

162 163 164
/********************************************************
                    POPUP BUILDING
 *******************************************************/
165
static GtkWidget *
166
glade_popup_append_item (GtkWidget   *popup_menu,
167
                         const gchar *label,
168 169 170
                         gboolean     sensitive,
                         gpointer     callback,
                         gpointer     data)
Jose Maria Celorio's avatar
Jose Maria Celorio committed
171
{
172
  GtkWidget *menu_item = gtk_menu_item_new_with_mnemonic (label);
173 174 175 176 177 178 179 180 181 182

  if (callback)
    g_signal_connect (G_OBJECT (menu_item), "activate",
                      G_CALLBACK (callback), data);

  gtk_widget_set_sensitive (menu_item, sensitive);
  gtk_widget_show (menu_item);
  gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item);

  return menu_item;
Jose Maria Celorio's avatar
Jose Maria Celorio committed
183 184
}

185

186
static void
187
glade_popup_menuitem_activated (GtkMenuItem *item, const gchar *action_path)
188
{
189 190 191
  GladeWidget *widget;

  if ((widget = g_object_get_data (G_OBJECT (item), "gwa-data")))
192 193
    glade_widget_adaptor_action_activate (glade_widget_get_adaptor (widget),
                                          glade_widget_get_object (widget), action_path);
194 195
}

196
static void
197 198
glade_popup_menuitem_packing_activated (GtkMenuItem *item,
                                        const gchar *action_path)
199
{
200
  GladeWidget *widget, *parent;
201 202

  if ((widget = g_object_get_data (G_OBJECT (item), "gwa-data")))
203 204 205
    {
      parent = glade_widget_get_parent (widget);
      glade_widget_adaptor_child_action_activate (glade_widget_get_adaptor (parent),
206 207
                                                  glade_widget_get_object (parent),
                                                  glade_widget_get_object (widget), action_path);
208
    }
209 210
}

211
static void
212 213
glade_popup_menuitem_ph_packing_activated (GtkMenuItem *item,
                                           const gchar *action_path)
214
{
215 216 217 218 219 220
  GladePlaceholder *ph;
  GladeWidget *parent;

  if ((ph = g_object_get_data (G_OBJECT (item), "gwa-data")))
    {
      parent = glade_placeholder_get_parent (ph);
221 222
      glade_widget_adaptor_child_action_activate (glade_widget_get_adaptor (parent),
                                                  glade_widget_get_object (parent),
223 224
                                                  G_OBJECT (ph), action_path);
    }
225 226
}

227
static gint
228
glade_popup_action_populate_menu_real (GtkWidget   *menu,
229
                                       GladeWidget *gwidget,
230 231 232
                                       GList       *actions,
                                       GCallback    callback,
                                       gpointer     data)
233
{
234 235 236 237 238 239
  GtkWidget *item;
  GList *list;
  gint n = 0;

  for (list = actions; list; list = g_list_next (list))
    {
240 241 242 243
      GladeWidgetAction *action = list->data;
      GWActionClass     *aclass = glade_widget_action_get_class (action);
      GList             *children = glade_widget_action_get_children (action);
      GtkWidget         *submenu = NULL;
244

245
      if (!glade_widget_action_get_visible (action))
246
        continue;
247 248

      if (children)
249 250 251 252
        {
          submenu = gtk_menu_new ();
          n += glade_popup_action_populate_menu_real (submenu,
                                                      gwidget,
253
                                                      children,
254 255 256
                                                      callback, data);
        }
      else
257 258
        submenu = glade_widget_adaptor_action_submenu (glade_widget_get_adaptor (gwidget),
                                                       glade_widget_get_object (gwidget),
259
                                                       aclass->path);
260 261


262
      item = glade_popup_append_item (menu, aclass->label, TRUE,
263 264
                                      (children) ? NULL : callback,
                                      (children) ? NULL : aclass->path);
265 266 267

      g_object_set_data (G_OBJECT (item), "gwa-data", data);

268
      gtk_widget_set_sensitive (item, glade_widget_action_get_sensitive (action));
269 270 271 272 273 274 275 276

      if (submenu)
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);

      n++;
    }

  return n;
277 278
}

279 280 281 282 283
/*
 * glade_popup_action_populate_menu:
 * @menu: a GtkMenu to put the actions menu items.
 * @widget: A #GladeWidget
 * @action: a @widget subaction or NULL to include all actions.
284
 * @packing: TRUE to include packing actions
285 286 287 288 289 290
 *
 * Populate a GtkMenu with widget's actions
 *
 * Returns the number of action appended to the menu.
 */
gint
291 292
glade_popup_action_populate_menu (GtkWidget         *menu,
                                  GladeWidget       *widget,
293
                                  GladeWidgetAction *action,
294
                                  gboolean           packing)
295
{
296 297 298 299 300
  gint n;

  g_return_val_if_fail (GTK_IS_MENU (menu), 0);
  g_return_val_if_fail (GLADE_IS_WIDGET (widget), 0);

301 302
  g_return_val_if_fail (action == NULL || GLADE_IS_WIDGET_ACTION (action), 0);

303 304
  if (action)
    {
305 306 307 308
      GWActionClass *aclass = glade_widget_action_get_class (action);
      GList         *children = glade_widget_action_get_children (action);
      
      if (glade_widget_get_action (widget, aclass->path) &&
309
          glade_widget_action_get_visible (action))
310 311
        return glade_popup_action_populate_menu_real (menu,
                                                      widget,
312
                                                      children,
313 314 315 316
                                                      G_CALLBACK
                                                      (glade_popup_menuitem_activated),
                                                      widget);

317
      if (glade_widget_get_pack_action (widget, aclass->path) &&
318
          glade_widget_action_get_visible (action))
319 320
        return glade_popup_action_populate_menu_real (menu,
                                                      glade_widget_get_parent
321
                                                      (widget), children,
322 323 324 325 326 327 328 329 330
                                                      G_CALLBACK
                                                      (glade_popup_menuitem_packing_activated),
                                                      widget);

      return 0;
    }

  n = glade_popup_action_populate_menu_real (menu,
                                             widget,
331
                                             glade_widget_get_actions (widget),
332 333 334 335
                                             G_CALLBACK
                                             (glade_popup_menuitem_activated),
                                             widget);

336
  if (packing && glade_widget_get_pack_actions (widget))
337 338 339
    {
      if (n)
        {
340
          GtkWidget *separator = gtk_separator_menu_item_new ();
341 342 343
          gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
          gtk_widget_show (separator);
        }
344

345
      n += glade_popup_action_populate_menu_real 
346 347 348
        (menu, glade_widget_get_parent (widget),
         glade_widget_get_pack_actions (widget),
         G_CALLBACK (glade_popup_menuitem_packing_activated), widget);
349 350 351
    }

  return n;
352
}
353

354
static GtkWidget *
355 356
glade_popup_create_menu (GladeWidget      *widget,
                         GladePlaceholder *placeholder, 
357 358
                         GladeProject     *project,
                         gboolean          packing)
Jose Maria Celorio's avatar
Jose Maria Celorio committed
359
{
360 361 362 363
  GtkWidget          *popup_menu;
  GtkWidget          *separator;
  gboolean            sensitive;
  GladeWidgetAdaptor *adaptor;
364 365 366

  popup_menu = gtk_menu_new ();

367 368 369
  adaptor = glade_project_get_add_item (project);

  if (adaptor)
370
    {
371
      RootAddData *data = g_new (RootAddData, 1);
372
      
373 374
      data->adaptor = adaptor;
      data->project = project;
375 376 377
      data->parent = placeholder ? glade_placeholder_get_parent (placeholder) : widget;
      data->placeholder = placeholder;
      
378
      g_object_set_data_full (G_OBJECT (popup_menu), "root-data-destroy-me", 
379
                              data, (GDestroyNotify)g_free);
380

381 382
      glade_popup_append_item (popup_menu, _("_Add widget here"),
                               data->parent != NULL,
383 384
                               glade_popup_widget_add_cb,
                               data);
385

386 387
      glade_popup_append_item (popup_menu, _("Add widget as _toplevel"), TRUE,
                               glade_popup_root_add_cb, data);
388

389
      separator = gtk_separator_menu_item_new ();
390 391 392 393 394 395
      gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
      gtk_widget_show (separator);
    }

  sensitive = (widget != NULL);

396
  glade_popup_append_item (popup_menu, _("_Select"), sensitive,
397
                           glade_popup_select_cb, widget);
398
  glade_popup_append_item (popup_menu, _("Cu_t"), sensitive,
399
                           glade_popup_cut_cb, widget);
400
  glade_popup_append_item (popup_menu, _("_Copy"), sensitive,
401 402 403 404 405 406
                           glade_popup_copy_cb, widget);

  /* paste is placholder specific when the popup is on a placeholder */
  sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());

  if (placeholder)
407
    glade_popup_append_item (popup_menu, _("_Paste"), sensitive,
408 409
                             glade_popup_placeholder_paste_cb, placeholder);
  else if (widget)
410
    glade_popup_append_item (popup_menu, _("_Paste"), sensitive,
411 412
                             glade_popup_paste_cb, widget);
  else
413
    glade_popup_append_item (popup_menu, _("_Paste"), sensitive,
414 415 416
                             glade_popup_paste_cb, NULL);


417 418
  glade_popup_append_item (popup_menu, _("_Delete"), (widget != NULL),
                           glade_popup_delete_cb, widget);
419 420 421 422 423


  /* packing actions are a little different on placholders */
  if (placeholder)
    {
424
      if (widget && glade_widget_get_actions (widget))
425
        {
426
          GtkWidget *separator = gtk_separator_menu_item_new ();
427 428 429 430 431 432
          gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
          gtk_widget_show (separator);

          glade_popup_action_populate_menu_real
              (popup_menu,
               widget,
433
               glade_widget_get_actions (widget),
434 435 436
               G_CALLBACK (glade_popup_menuitem_activated), widget);
        }

437
      if (glade_placeholder_packing_actions (placeholder))
438
        {
439
          GtkWidget *separator = gtk_separator_menu_item_new ();
440 441 442 443 444 445
          gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
          gtk_widget_show (separator);

          glade_popup_action_populate_menu_real
              (popup_menu,
               widget,
446
               glade_placeholder_packing_actions (placeholder),
447 448 449 450
               G_CALLBACK (glade_popup_menuitem_ph_packing_activated),
               placeholder);
        }
    }
451
  else if (widget && (glade_widget_get_actions (widget) || 
452
                      (packing && glade_widget_get_pack_actions (widget))))
453
    {
454
      GtkWidget *separator = gtk_separator_menu_item_new ();
455 456 457 458 459 460 461
      gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
      gtk_widget_show (separator);

      glade_popup_action_populate_menu (popup_menu, widget, NULL, packing);
    }

  return popup_menu;
Jose Maria Celorio's avatar
Jose Maria Celorio committed
462 463 464
}

void
465
glade_popup_widget_pop (GladeWidget    *widget,
466
                        GdkEventButton *event,
467
                        gboolean        packing)
Jose Maria Celorio's avatar
Jose Maria Celorio committed
468
{
469 470 471 472 473 474
  GtkWidget *popup_menu;
  gint button;
  gint event_time;

  g_return_if_fail (GLADE_IS_WIDGET (widget) || widget == NULL);

475
  popup_menu = glade_popup_create_menu (widget, NULL, glade_widget_get_project (widget), packing);
476 477 478 479 480 481 482 483 484 485 486 487 488

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }
  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
                  NULL, NULL, button, event_time);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
489
}
490 491

void
492
glade_popup_placeholder_pop (GladePlaceholder *placeholder,
493
                             GdkEventButton   *event)
494
{
495 496 497 498 499 500 501 502 503
  GladeWidget *widget;
  GtkWidget *popup_menu;
  gint button;
  gint event_time;

  g_return_if_fail (GLADE_IS_PLACEHOLDER (placeholder));

  widget = glade_placeholder_get_parent (placeholder);

504
  popup_menu = glade_popup_create_menu (widget, placeholder, 
505
                                        glade_widget_get_project (widget), TRUE);
506 507 508 509 510 511 512 513 514 515 516 517 518 519

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }

  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
                  NULL, NULL, button, event_time);
520
}
521

522
void
523
glade_popup_palette_pop (GladePalette       *palette, 
524 525
                         GladeWidgetAdaptor *adaptor, 
                         GdkEventButton     *event)
526
{
527 528 529 530
  GladeProject *project;
  GtkWidget *popup_menu;
  gint button;
  gint event_time;
531
  RootAddData *data;
532 533 534 535 536

  g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));

  popup_menu = gtk_menu_new ();

537
  project = glade_palette_get_project (palette);
538

539 540 541 542
  data = g_new (RootAddData, 1);
  data->adaptor = adaptor;
  data->project = project;
  g_object_set_data_full (G_OBJECT (popup_menu), "root-data-destroy-me", 
543
                          data, (GDestroyNotify)g_free);
544

545 546
  glade_popup_append_item (popup_menu, _("Add widget as _toplevel"), TRUE,
                           glade_popup_root_add_cb, data);
547

548
  if (glade_widget_adaptor_get_book (adaptor) && glade_util_have_devhelp ())
549 550
    glade_popup_append_item (popup_menu, _("Read _documentation"), TRUE,
                             glade_popup_docs_cb, adaptor);
551 552 553 554 555 556 557 558 559 560 561 562 563 564

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }

  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
                  NULL, NULL, button, event_time);
565 566
}

567
static void
568
glade_popup_clear_property_cb (GtkMenuItem *item, GladeProperty *property)
569
{
570
  GValue value = { 0, };
571

572 573 574
  glade_property_get_default (property, &value);
  glade_command_set_property_value (property, &value);
  g_value_unset (&value);
575 576 577
}

static void
578
glade_popup_property_docs_cb (GtkMenuItem *item, GladeProperty *property)
579
{
580
  GladeWidgetAdaptor *adaptor, *prop_adaptor;
581
  GladePropertyClass *pclass;
582
  GParamSpec         *pspec;
583
  gchar              *search;
584

585
  pclass       = glade_property_get_class (property);
586 587 588
  pspec        = glade_property_class_get_pspec (pclass);
  prop_adaptor = glade_property_class_get_adaptor (pclass);
  adaptor      = glade_widget_adaptor_from_pspec (prop_adaptor, pspec);
589
  search       = g_strdup_printf ("The \"%s\" property", glade_property_class_id (pclass));
590

591 592
  glade_app_search_docs (glade_widget_adaptor_get_book (adaptor),
                         g_type_name (pspec->owner_type), search);
593

594
  g_free (search);
595 596 597
}

void
598
glade_popup_property_pop (GladeProperty *property, GdkEventButton *event)
599 600
{

601
  GladeWidgetAdaptor *adaptor, *prop_adaptor;
602
  GladePropertyClass *pclass;
603
  GParamSpec         *pspec;
604 605 606 607
  GtkWidget *popup_menu;
  gint button;
  gint event_time;

608
  pclass       = glade_property_get_class (property);
609 610 611
  pspec        = glade_property_class_get_pspec (pclass);
  prop_adaptor = glade_property_class_get_adaptor (pclass);
  adaptor      = glade_widget_adaptor_from_pspec (prop_adaptor, pspec);
612 613 614 615 616

  g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));

  popup_menu = gtk_menu_new ();

617 618
  glade_popup_append_item (popup_menu, _("Set default value"), TRUE,
                           glade_popup_clear_property_cb, property);
619

620
  if (!glade_property_class_get_virtual (pclass) &&
621 622
      glade_widget_adaptor_get_book (adaptor) &&
      glade_util_have_devhelp ())
623
    {
624 625
      glade_popup_append_item (popup_menu, _("Read _documentation"), TRUE,
                               glade_popup_property_docs_cb, property);
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
    }

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }

  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
                  NULL, NULL, button, event_time);
641 642
}

643
void
644
glade_popup_simple_pop (GladeProject *project, GdkEventButton *event)
645
{
646 647 648 649
  GtkWidget *popup_menu;
  gint button;
  gint event_time;

650
  popup_menu = glade_popup_create_menu (NULL, NULL, project, FALSE);
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
  if (!popup_menu)
    return;

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }
  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
                  NULL, NULL, button, event_time);
666 667
}

668
gboolean
669
glade_popup_is_popup_event (GdkEventButton *event)
670
{
671
  g_return_val_if_fail (event, FALSE);
672 673

#ifdef MAC_INTEGRATION
674 675
  return (event->type == GDK_BUTTON_PRESS && event->button == 1 &&
          ((event->state & GDK_MOD1_MASK) != 0));
676
#else
677
  return (event->type == GDK_BUTTON_PRESS && event->button == 3);
678 679
#endif
}