Пример #1
0
static gboolean
swatch_button_press (GtkWidget      *widget,
                     GdkEventButton *event)
{
  GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);

  gtk_widget_grab_focus (widget);

  if (gdk_event_triggers_context_menu ((GdkEvent *) event) &&
      swatch->priv->has_color)
    {
      do_popup (widget, event);
      return TRUE;
    }
  else if (event->type == GDK_2BUTTON_PRESS &&
           event->button == GDK_BUTTON_PRIMARY)
    {
      g_signal_emit (swatch, signals[ACTIVATE], 0);
      return TRUE;
    }
  else if (event->button == GDK_BUTTON_PRIMARY)
    {
      return TRUE;
    }

  return FALSE;
}
Пример #2
0
gboolean
gimp_display_shell_quick_mask_button_press (GtkWidget        *widget,
                                            GdkEventButton   *bevent,
                                            GimpDisplayShell *shell)
{
  if (! gimp_display_get_image (shell->display))
    return TRUE;

  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
    {
      GimpImageWindow *window = gimp_display_shell_get_window (shell);

      if (window)
        {
          GimpUIManager *manager = gimp_image_window_get_ui_manager (window);

          gimp_ui_manager_ui_popup (manager,
                                    "/quick-mask-popup",
                                    GTK_WIDGET (shell),
                                    NULL, NULL, NULL, NULL);
        }

      return TRUE;
    }

  return FALSE;
}
Пример #3
0
static gboolean
view_button_press (GtkWidget      *widget,
                   GdkEventButton *event)
{
  if (gdk_event_triggers_context_menu ((GdkEvent *) event))
    return view_popup_menu (widget, event);

  return FALSE;
}
Пример #4
0
static gboolean
gimp_color_panel_button_press (GtkWidget      *widget,
                               GdkEventButton *bevent)
{
  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
    {
      GimpColorButton *color_button;
      GimpColorPanel  *color_panel;
      GtkUIManager    *ui_manager;
      GtkActionGroup  *group;
      GtkAction       *action;
      GimpRGB          color;

      color_button = GIMP_COLOR_BUTTON (widget);
      color_panel  = GIMP_COLOR_PANEL (widget);
      ui_manager   = GTK_UI_MANAGER (color_button->popup_menu);

      group = gtk_ui_manager_get_action_groups (ui_manager)->data;

      action = gtk_action_group_get_action (group,
                                            "color-button-use-foreground");
      gtk_action_set_visible (action, color_panel->context != NULL);

      action = gtk_action_group_get_action (group,
                                            "color-button-use-background");
      gtk_action_set_visible (action, color_panel->context != NULL);

      if (color_panel->context)
        {
          action = gtk_action_group_get_action (group,
                                                "color-button-use-foreground");
          gimp_context_get_foreground (color_panel->context, &color);
          g_object_set (action, "color", &color, NULL);

          action = gtk_action_group_get_action (group,
                                                "color-button-use-background");
          gimp_context_get_background (color_panel->context, &color);
          g_object_set (action, "color", &color, NULL);
        }

      action = gtk_action_group_get_action (group, "color-button-use-black");
      gimp_rgba_set (&color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
      g_object_set (action, "color", &color, NULL);

      action = gtk_action_group_get_action (group, "color-button-use-white");
      gimp_rgba_set (&color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
      g_object_set (action, "color", &color, NULL);
    }

  if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
    return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);

  return FALSE;
}
Пример #5
0
static gboolean
gimp_error_console_button_press (GtkWidget        *widget,
                                 GdkEventButton   *bevent,
                                 GimpErrorConsole *console)
{
  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
    {
      return gimp_editor_popup_menu (GIMP_EDITOR (console), NULL, NULL);
    }

  return FALSE;
}
Пример #6
0
static gboolean
gimp_palette_view_button_press (GtkWidget      *widget,
                                GdkEventButton *bevent)
{
  GimpPaletteView  *view = GIMP_PALETTE_VIEW (widget);
  GimpPaletteEntry *entry;

  if (gtk_widget_get_can_focus (widget) && ! gtk_widget_has_focus (widget))
    gtk_widget_grab_focus (widget);

  entry = gimp_palette_view_find_entry (view, bevent->x, bevent->y);

  view->dnd_entry = entry;

  if (! entry || bevent->button == 2)
    return TRUE;

  if (bevent->type == GDK_BUTTON_PRESS)
    g_signal_emit (view, view_signals[ENTRY_CLICKED], 0,
                   entry, bevent->state);

  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
    {
      if (entry != view->selected)
        gimp_palette_view_select_entry (view, entry);

      g_signal_emit (view, view_signals[ENTRY_CONTEXT], 0, entry);
    }
  else if (bevent->button == 1)
    {
      if (bevent->type == GDK_BUTTON_PRESS)
        {
          gimp_palette_view_select_entry (view, entry);
        }
      else if (bevent->type == GDK_2BUTTON_PRESS && entry == view->selected)
        {
          g_signal_emit (view, view_signals[ENTRY_ACTIVATED], 0, entry);
        }
    }

  return TRUE;
}
Пример #7
0
static gboolean
gimp_color_button_button_press (GtkWidget      *widget,
                                GdkEventButton *bevent)
{
  GimpColorButton *button = GIMP_COLOR_BUTTON (widget);

  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
    {
      GtkWidget *menu = gtk_ui_manager_get_widget (button->popup_menu,
                                                   "/color-button-popup");

      gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));

      gtk_menu_popup (GTK_MENU (menu),
                      NULL, NULL, NULL, NULL,
                      bevent->button, bevent->time);
    }

  if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
    return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);

  return FALSE;
}
Пример #8
0
static gboolean
panel_button_press_event (GtkTreeView         *treeview,
			  GdkEventButton      *event,
			  GeditDocumentsPanel *panel)
{
	gboolean ret = FALSE;

	gedit_debug (DEBUG_PANEL);

	if ((event->type == GDK_BUTTON_PRESS) &&
	    (gdk_event_triggers_context_menu ((GdkEvent *) event)) &&
	    (event->window == gtk_tree_view_get_bin_window (treeview)))
	{
		GtkTreePath *path = NULL;

		/* Change the cursor position */
		if (gtk_tree_view_get_path_at_pos (treeview,
						   event->x,
						   event->y,
						   &path,
						   NULL,
						   NULL,
						   NULL))
		{
			GtkTreeIter iter;
			gchar *path_string;

			path_string = gtk_tree_path_to_string (path);

			if (gtk_tree_model_get_iter_from_string (panel->priv->model,
								 &iter,
								 path_string))
			{
				GeditTab *tab;

				gtk_tree_model_get (panel->priv->model,
						    &iter,
						    TAB_COLUMN, &tab,
						    -1);

				if (tab != NULL)
				{
					gtk_tree_view_set_cursor (treeview,
								  path,
								  NULL,
								  FALSE);

					/* A row exists at the mouse position */
					ret = show_tab_popup_menu (panel, tab, event);

					g_object_unref (tab);
				}
			}

			g_free (path_string);
			gtk_tree_path_free (path);
		}
	}

	return ret;
}
Пример #9
0
static gboolean
gimp_view_button_press_event (GtkWidget      *widget,
                              GdkEventButton *bevent)
{
    GimpView *view = GIMP_VIEW (widget);

#ifdef DEBUG_MEMSIZE
    if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 2)
    {
        gimp_debug_memsize = TRUE;

        gimp_object_get_memsize (GIMP_OBJECT (view->viewable), NULL);

        gimp_debug_memsize = FALSE;
    }
#endif /* DEBUG_MEMSIZE */

    if (! view->clickable &&
            ! view->show_popup)
        return FALSE;

    if (! gtk_widget_get_realized (widget))
        return FALSE;

    if (bevent->type == GDK_BUTTON_PRESS)
    {
        if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
        {
            view->press_state = 0;

            g_signal_emit (widget, view_signals[CONTEXT], 0);
        }
        else if (bevent->button == 1)
        {
            gtk_grab_add (widget);

            view->has_grab    = TRUE;
            view->press_state = bevent->state;

            if (view->show_popup && view->viewable)
            {
                gimp_view_popup_show (widget, bevent,
                                      view->renderer->context,
                                      view->viewable,
                                      view->renderer->width,
                                      view->renderer->height,
                                      view->renderer->dot_for_dot);
            }
        }
        else
        {
            view->press_state = 0;

            if (bevent->button == 2)
                gimp_view_popup_show (widget, bevent,
                                      view->renderer->context,
                                      view->viewable,
                                      view->renderer->width,
                                      view->renderer->height,
                                      view->renderer->dot_for_dot);

            return FALSE;
        }
    }
    else if (bevent->type == GDK_2BUTTON_PRESS)
    {
        if (bevent->button == 1)
            g_signal_emit (widget, view_signals[DOUBLE_CLICKED], 0);
    }

    return view->eat_button_events ? TRUE : FALSE;
}