Ejemplo n.º 1
0
static gboolean
button_press_cb (NautilusNotebook *notebook,
		 GdkEventButton *event,
		 gpointer data)
{
	int tab_clicked;

	tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);

	if (event->type == GDK_BUTTON_PRESS &&
	    event->button == 3 &&
		   (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
	{
		if (tab_clicked == -1)
		{
			/* consume event, so that we don't pop up the context menu when
			 * the mouse if not over a tab label
			 */
			return TRUE;
		}

		/* switch to the page the mouse is over, but don't consume the event */
		gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
	}

	return FALSE;
}
Ejemplo n.º 2
0
static gboolean
gedit_notebook_button_press (GtkWidget      *widget,
                             GdkEventButton *event)
{
	GtkNotebook *nb = GTK_NOTEBOOK (widget);

	if (event->type == GDK_BUTTON_PRESS &&
	    event->button == GDK_BUTTON_SECONDARY &&
	    (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
	{
		gint tab_clicked;

		tab_clicked = find_tab_num_at_pos (nb, event->x_root, event->y_root);
		if (tab_clicked >= 0)
		{
			GtkWidget *tab;

			tab = gtk_notebook_get_nth_page (nb, tab_clicked);

			g_signal_emit (G_OBJECT (widget), signals[SHOW_POPUP_MENU], 0, event, tab);

			return TRUE;
		}
	}

	return GTK_WIDGET_CLASS (gedit_notebook_parent_class)->button_press_event (widget, event);
}
Ejemplo n.º 3
0
static gboolean
button_press_cb (EphyNotebook   *notebook,
                 GdkEventButton *event,
                 gpointer        data)
{
  int tab_clicked;

  tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);

  if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_MIDDLE) {
    GtkWidget *tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), tab_clicked);
    g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
    return GDK_EVENT_STOP;
  }

  if (event->type == GDK_BUTTON_PRESS &&
      event->button == GDK_BUTTON_SECONDARY &&
      (event->state & gtk_accelerator_get_default_mod_mask ()) == 0) {
    if (tab_clicked == -1) {
      /* Consume event so that we don't pop up the context
       * menu when the mouse is not over a tab label.
       */
      return GDK_EVENT_STOP;
    }

    /* Switch to the page where the mouse is over, but don't consume the
     * event. */
    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
  }

  return GDK_EVENT_PROPAGATE;
}
static gboolean
button_press_event_cb (GtkWidget *widget,
                       GdkEventButton *event,
                       EphyWindow *window)
{
    gint tab_number;
    EphyEmbed *embed;

    if (event->button != 2 || event->type != GDK_BUTTON_PRESS)
        return FALSE;

    /* I wish this wasn't so gash and copy-pasty... Connecting
     * to button-press-event on the tab doesn't ever get called.*/
    tab_number = find_tab_num_at_pos (EPHY_NOTEBOOK (widget),
                                      event->x_root, event->y_root);

    if (tab_number < 0)
        return FALSE;

    embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (widget),
                        tab_number));

    if (embed == NULL)
        return FALSE;

    ephy_embed_container_remove_child (EPHY_EMBED_CONTAINER (window), embed);

    return TRUE;
}
Ejemplo n.º 5
0
static gboolean
button_press_cb (CeditNotebook  *notebook,
		 GdkEventButton *event,
		 gpointer        data)
{
	gint tab_clicked;

	if (notebook->priv->drag_in_progress)
		return TRUE;

	tab_clicked = find_tab_num_at_pos (notebook,
					   event->x_root,
					   event->y_root);
					   
	if ((event->button == 1) && 
	    (event->type == GDK_BUTTON_PRESS) && 
	    (tab_clicked >= 0))
	{
		notebook->priv->x_start = event->x_root;
		notebook->priv->y_start = event->y_root;
		
		notebook->priv->motion_notify_handler_id =
			g_signal_connect (G_OBJECT (notebook),
					  "motion-notify-event",
					  G_CALLBACK (motion_notify_cb), 
					  NULL);
	}
	else if ((event->type == GDK_BUTTON_PRESS) && 
		 (event->button == 3 || event->button == 2))
	{
		if (tab_clicked == -1)
		{
			// CHECK: do we really need it?
			
			/* consume event, so that we don't pop up the context menu when
			 * the mouse if not over a tab label
			 */
			return TRUE;
		}
		else
		{
			/* Switch to the page the mouse is over, but don't consume the event */
			gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 
						       tab_clicked);
		}
	}

	return FALSE;
}
Ejemplo n.º 6
0
static gint 
find_notebook_and_tab_at_pos (gint            abs_x, 
			      gint            abs_y,
			      CeditNotebook **notebook,
			      gint           *page_num)
{
	*notebook = find_notebook_at_pointer (abs_x, abs_y);
	if (*notebook == NULL)
	{
		return NOT_IN_APP_WINDOWS;
	}
	
	*page_num = find_tab_num_at_pos (*notebook, abs_x, abs_y);

	if (*page_num < 0)
	{
		return *page_num;
	}
	else
	{
		return 0;
	}
}