コード例 #1
0
static gint
find_tab_num_at_pos (NautilusNotebook *notebook, gint abs_x, gint abs_y)
{
	GtkPositionType tab_pos;
	int page_num = 0;
	GtkNotebook *nb = GTK_NOTEBOOK (notebook);
	GtkWidget *page;

	tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));

	if (GTK_NOTEBOOK (notebook)->first_tab == NULL)
	{
		return AFTER_ALL_TABS;
	}

	/* For some reason unfullscreen + quick click can
	   cause a wrong click event to be reported to the tab */
	if (!is_in_notebook_window(notebook, abs_x, abs_y))
	{
		return NOT_IN_APP_WINDOWS;
	}

	while ((page = gtk_notebook_get_nth_page (nb, page_num)))
	{
		GtkWidget *tab;
		gint max_x, max_y;
		gint x_root, y_root;

		tab = gtk_notebook_get_tab_label (nb, page);
		g_return_val_if_fail (tab != NULL, -1);

		if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab)))
		{
			page_num++;
			continue;
		}

		gdk_window_get_origin (GDK_WINDOW (tab->window),
				       &x_root, &y_root);

		max_x = x_root + tab->allocation.x + tab->allocation.width;
		max_y = y_root + tab->allocation.y + tab->allocation.height;

		if (((tab_pos == GTK_POS_TOP)
		     || (tab_pos == GTK_POS_BOTTOM))
		    &&(abs_x<=max_x))
		{
			return page_num;
		}
		else if (((tab_pos == GTK_POS_LEFT)
			  || (tab_pos == GTK_POS_RIGHT))
			 && (abs_y<=max_y))
		{
			return page_num;
		}

		page_num++;
	}
	return AFTER_ALL_TABS;
}
コード例 #2
0
ファイル: notebook.c プロジェクト: amery/clip-itk
int
clip_GTK_NOTEBOOKGETTABPOS(ClipMachine * cm)
{
	C_widget     *cntb = _fetch_cw_arg(cm);

	CHECKCWID(cntb,GTK_IS_NOTEBOOK);
	_clip_retni(cm, (int)gtk_notebook_get_tab_pos(GTK_NOTEBOOK(cntb->widget)));
	return 0;
err:
	return 1;
}
コード例 #3
0
ファイル: nautilus-notebook.c プロジェクト: fanyui/nautilus
static gint
find_tab_num_at_pos (NautilusNotebook *notebook, gint abs_x, gint abs_y)
{
	GtkPositionType tab_pos;
	int page_num = 0;
	GtkNotebook *nb = GTK_NOTEBOOK (notebook);
	GtkWidget *page;
	GtkAllocation allocation;

	tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));

	while ((page = gtk_notebook_get_nth_page (nb, page_num)))
	{
		GtkWidget *tab;
		gint max_x, max_y;
		gint x_root, y_root;

		tab = gtk_notebook_get_tab_label (nb, page);
		g_return_val_if_fail (tab != NULL, -1);

		if (!gtk_widget_get_mapped (GTK_WIDGET (tab)))
		{
			page_num++;
			continue;
		}

		gdk_window_get_origin (gtk_widget_get_window (tab),
				       &x_root, &y_root);
		gtk_widget_get_allocation (tab, &allocation);

		max_x = x_root + allocation.x + allocation.width;
		max_y = y_root + allocation.y + allocation.height;

		if (((tab_pos == GTK_POS_TOP)
		     || (tab_pos == GTK_POS_BOTTOM))
		    &&(abs_x<=max_x))
		{
			return page_num;
		}
		else if (((tab_pos == GTK_POS_LEFT)
			  || (tab_pos == GTK_POS_RIGHT))
			 && (abs_y<=max_y))
		{
			return page_num;
		}

		page_num++;
	}
	return AFTER_ALL_TABS;
}
コード例 #4
0
ファイル: gedit-notebook.c プロジェクト: jaseemabid/gedit
static gint
find_tab_num_at_pos (GtkNotebook *notebook,
                     gint         screen_x,
                     gint         screen_y)
{
	GtkNotebook *nb = GTK_NOTEBOOK (notebook);
	GtkPositionType tab_pos;
	GtkWidget *page;
	GtkAllocation tab_allocation;
	gint page_num = 0;

	tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));

	while ((page = gtk_notebook_get_nth_page (nb, page_num)))
	{
		GtkWidget *tab;
		gint max_x, max_y, x_root, y_root;

		tab = gtk_notebook_get_tab_label (nb, page);
		g_return_val_if_fail (tab != NULL, -1);

		if (!gtk_widget_get_mapped (GTK_WIDGET (tab)))
		{
			page_num++;
			continue;
		}

		gdk_window_get_origin (gtk_widget_get_window (tab), &x_root, &y_root);

		gtk_widget_get_allocation (tab, &tab_allocation);
		max_x = x_root + tab_allocation.x + tab_allocation.width;
		max_y = y_root + tab_allocation.y + tab_allocation.height;

		if ((tab_pos == GTK_POS_TOP || tab_pos == GTK_POS_BOTTOM) && screen_x <= max_x)
		{
			return page_num;
		}

		if ((tab_pos == GTK_POS_LEFT || tab_pos == GTK_POS_RIGHT) && screen_y <= max_y)
		{
			return page_num;
		}

		page_num++;
	}

	return -1;
}
コード例 #5
0
ファイル: mainwindow.c プロジェクト: ashang/stjerm
/* This code adapted from gnome-terminal */
static gint mainwindow_tab_at_xy(GtkNotebook *notebook, gint x, gint y)
{
    GtkPositionType tab_pos;
    int page_num = 0;
    GtkWidget *page;
    
    tab_pos = gtk_notebook_get_tab_pos(notebook);
    
    if(notebook->first_tab == NULL)
        return -1;

    while((page = gtk_notebook_get_nth_page(notebook, page_num)))
    {
        GtkWidget *screen;
        gint max_x, max_y;

        screen = gtk_notebook_get_tab_label(notebook, page);
        g_return_val_if_fail(screen != NULL, -1);

        if(!GTK_WIDGET_MAPPED(GTK_WIDGET(screen)))
        {
            page_num++;
            continue;
        }

        max_x = screen->allocation.x + screen->allocation.width;
        max_y = screen->allocation.y + screen->allocation.height;

        if(((tab_pos == GTK_POS_TOP) || (tab_pos == GTK_POS_BOTTOM)) && (x <= max_x))
            return page_num;
        else if(((tab_pos == GTK_POS_LEFT) || (tab_pos == GTK_POS_RIGHT)) && (y <= max_y))
            return page_num;
        
        page_num++;
    }

    return -1;
}
コード例 #6
0
   */
  window = TERMINAL_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (label),
                                                     TERMINAL_TYPE_WINDOW));
  if (window != NULL)
    terminal_window_update_size (window);
}

static void
notify_tab_pos_cb (GtkNotebook *notebook,
                   GParamSpec *pspec G_GNUC_UNUSED,
                   TerminalTabLabel *label)
{
  TerminalTabLabelPrivate *priv = label->priv;
  GtkPositionType pos;

  pos = gtk_notebook_get_tab_pos (notebook);
  if (pos == priv->tab_pos)
    return;

  priv->tab_pos = pos;

  switch (pos) {
    case GTK_POS_LEFT:
    case GTK_POS_RIGHT:
      gtk_widget_hide (priv->close_button);
      break;
    case GTK_POS_TOP:
    case GTK_POS_BOTTOM:
      gtk_widget_show (priv->close_button);
      break;
  }
コード例 #7
0
ファイル: cedit-notebook.c プロジェクト: cranes-bill/cedit
static gint
find_tab_num_at_pos (CeditNotebook *notebook, 
		     gint           abs_x, 
		     gint           abs_y)
{
	GtkPositionType tab_pos;
	int page_num = 0;
	GtkNotebook *nb = GTK_NOTEBOOK (notebook);
	GtkWidget *page;

	tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));

	/* For some reason unfullscreen + quick click can
	   cause a wrong click event to be reported to the tab */
	if (!is_in_notebook_window (notebook, abs_x, abs_y))
	{
		return NOT_IN_APP_WINDOWS;
	}

	while ((page = gtk_notebook_get_nth_page (nb, page_num)) != NULL)
	{
		GtkAllocation allocation;
		GtkWidget *tab;
		gint max_x, max_y;
		gint x_root, y_root;

		tab = gtk_notebook_get_tab_label (nb, page);
		g_return_val_if_fail (tab != NULL, AFTER_ALL_TABS);

		if (!gtk_widget_get_mapped (tab))
		{
			++page_num;
			continue;
		}

		gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window (tab)),
				       &x_root, &y_root);

		gtk_widget_get_allocation(tab, &allocation);

		max_x = x_root + allocation.x + allocation.width;
		max_y = y_root + allocation.y + allocation.height;

		if (((tab_pos == GTK_POS_TOP) || 
		     (tab_pos == GTK_POS_BOTTOM)) &&
		    (abs_x <= max_x))
		{
			return page_num;
		}
		else if (((tab_pos == GTK_POS_LEFT) || 
		          (tab_pos == GTK_POS_RIGHT)) && 
		         (abs_y <= max_y))
		{
			return page_num;
		}

		++page_num;
	}
	
	return AFTER_ALL_TABS;
}
コード例 #8
0
/* Tab scrolling was removed from GtkNotebook in gtk 3, so reimplement it here */
static gboolean
scroll_event_cb (GtkWidget      *widget,
                 GdkEventScroll *event,
                 gpointer        user_data)
{
  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
  GtkWidget *child, *event_widget, *action_widget;

  if ((event->state & gtk_accelerator_get_default_mod_mask ()) != 0)
    return FALSE;

  child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
  if (child == NULL)
    return FALSE;

  event_widget = gtk_get_event_widget ((GdkEvent *) event);

  /* Ignore scroll events from the content of the page */
  if (event_widget == NULL ||
      event_widget == child ||
      gtk_widget_is_ancestor (event_widget, child))
    return FALSE;

  /* And also from the action widgets */
  action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
  if (event_widget == action_widget ||
      (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
    return FALSE;
  action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
  if (event_widget == action_widget ||
      (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
    return FALSE;

  switch (event->direction) {
    case GDK_SCROLL_RIGHT:
    case GDK_SCROLL_DOWN:
      gtk_notebook_next_page (notebook);
      return TRUE;
    case GDK_SCROLL_LEFT:
    case GDK_SCROLL_UP:
      gtk_notebook_prev_page (notebook);
      return TRUE;
    case GDK_SCROLL_SMOOTH:
      switch (gtk_notebook_get_tab_pos (notebook)) {
        case GTK_POS_LEFT:
        case GTK_POS_RIGHT:
          if (event->delta_y > 0)
            gtk_notebook_next_page (notebook);
          else if (event->delta_y < 0)
            gtk_notebook_prev_page (notebook);
          break;
        case GTK_POS_TOP:
        case GTK_POS_BOTTOM:
          if (event->delta_x > 0)
            gtk_notebook_next_page (notebook);
          else if (event->delta_x < 0)
            gtk_notebook_prev_page (notebook);
          break;
      }
      return TRUE;
  }

  return FALSE;
}
static gint
find_tab_num_at_pos (EphyNotebook *notebook,
                     gint abs_x,
                     gint abs_y)
{
    GtkPositionType tab_pos;
    int page_num = 0;
    GtkNotebook *nb = GTK_NOTEBOOK (notebook);
    GtkWidget *page;

    /* For some reason unfullscreen + quick click can
       cause a wrong click event to be reported to the tab */
    if (!is_in_notebook_window (notebook, abs_x, abs_y))
    {
        return -1;
    }

    tab_pos = gtk_notebook_get_tab_pos (nb);

    while ((page = gtk_notebook_get_nth_page (nb, page_num)))
    {
        GtkWidget *tab;
        GtkAllocation allocation;
        gint max_x, max_y;
        gint x_root, y_root;

        tab = gtk_notebook_get_tab_label (nb, page);
        g_return_val_if_fail (tab != NULL, -1);

        if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab)))
        {
            page_num++;
            continue;
        }

        gdk_window_get_origin (gtk_widget_get_window (tab),
                               &x_root, &y_root);

        gtk_widget_get_allocation (tab, &allocation);
        max_x = x_root + allocation.x + allocation.width;
        max_y = y_root + allocation.y + allocation.height;

        if ((tab_pos == GTK_POS_TOP
                || tab_pos == GTK_POS_BOTTOM)
                && abs_x <= max_x
                && abs_y <= max_y)
        {
            return page_num;
        }
        else if ((tab_pos == GTK_POS_LEFT
                  || tab_pos == GTK_POS_RIGHT)
                 && abs_x <= max_x
                 && abs_y <= max_y)
        {
            return page_num;
        }

        page_num++;
    }
    return -1;
}