示例#1
0
static void reorder_tabs(PurpleConversation *purpleConv) {
	PidginConversation *pidginConv;
	PidginWindow *win;

	if (!purpleConv) {
		return;
	}

	pidginConv = PIDGIN_CONVERSATION(purpleConv);

	if (!pidginConv || !pidginConv->tab_cont) {
		return;
	}

	win = pidgin_conv_get_window(pidginConv);

	if (!win || !win->notebook) {
		return;
	}

	int count_tabs = gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook));

	const char* tablist[count_tabs];

	for (int i = 0; i < count_tabs; i++) {
		tablist[i] = get_tab_title(i, win);
	}

	qsort(tablist, sizeof(tablist)/sizeof(char *), sizeof(char *), compare);

	for (int i = 0; i < count_tabs; i++) {
		//printf("Sorted: %s\n", tablist[i]);
		gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), get_tab_by_title(tablist[i], win), i);
	}
}
示例#2
0
/**
 * cedit_notebook_reorder_tab:
 * @src: a #CeditNotebook
 * @tab: a #CeditTab
 * @dest_position: the position for @tab
 *
 * Reorders the page containing @tab, so that it appears in @dest_position position.
 * If dest_position is greater than or equal to the number of tabs 
 * of the destination notebook or negative, tab will be moved to the 
 * end of the tabs.
 */
void
cedit_notebook_reorder_tab (CeditNotebook *src,
			    CeditTab      *tab,
			    gint           dest_position)
{
	gint old_position;
	
	g_return_if_fail (CEDIT_IS_NOTEBOOK (src));	
	g_return_if_fail (CEDIT_IS_TAB (tab));

	old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src), 
				    	      GTK_WIDGET (tab));
				    	      
	if (old_position == dest_position)
		return;

	gtk_notebook_reorder_child (GTK_NOTEBOOK (src), 
				    GTK_WIDGET (tab),
				    dest_position);
		
	if (!src->priv->drag_in_progress)
	{
		g_signal_emit (G_OBJECT (src), 
			       signals[TABS_REORDERED], 
			       0);
	}
}
示例#3
0
static void
on_notebook_switch_page (GtkNotebook *notebook,
						 GtkWidget *notebook_page,
						 gint page_num, AnjutaDocman *docman)
{
	if (!docman->priv->shutingdown)
	{
		AnjutaDocmanPage *page;

		page = anjuta_docman_get_nth_page (docman, page_num);
		g_signal_handlers_block_by_func (G_OBJECT (docman),
										 (gpointer) on_notebook_switch_page,
										 (gpointer) docman);
		anjuta_docman_set_current_document (docman, page->doc);
		g_signal_handlers_unblock_by_func (G_OBJECT (docman),
										   (gpointer) on_notebook_switch_page,
										   (gpointer) docman);
		/* TTimo: reorder so that the most recently used files are
		 * at the beginning of the tab list
		 */
		if (!docman->priv->tab_pressed	/* after a tab-click, sorting is done upon release */
			&& !g_tabbing
			&& !g_settings_get_boolean (docman->priv->settings, EDITOR_TABS_ORDERING)
			&& g_settings_get_boolean (docman->priv->settings, EDITOR_TABS_RECENT_FIRST))
		{
			gtk_notebook_reorder_child (notebook, page->widget, 0);
		}
		/* activate the right item in the documents menu */
		anjuta_docman_update_documents_menu_status (docman);
		g_signal_emit_by_name (G_OBJECT (docman), "document-changed", page->doc);
	}
}
示例#4
0
static VALUE
rg_reorder_child(VALUE self, VALUE child, VALUE pos)
{
    gtk_notebook_reorder_child(_SELF(self), RVAL2WIDGET(child),
                               NUM2INT(pos));
    return self;
}
/* "group-minimized-tabs" has changed */
static void _interface_tweaks_on_group_minimized_tabs_changed(InterfaceTweaks *self, gboolean inValue)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));

	InterfaceTweaksPrivate	*priv=self->priv;
	GList					*browsers, *browsersIter;
	GList					*tabs, *tabsIter;
	MidoriBrowser			*browser;
	GtkNotebook				*notebook;
	MidoriView				*view;
	gboolean				minimized;

	/* If value changed set it and emit notification of property change */
	if(priv->groupMinimizedTabs!=inValue || !priv->inited)
	{
		/* Change property */
		priv->groupMinimizedTabs=inValue;
		if(priv->inited) midori_extension_set_boolean(priv->extension, "group-minimized-tabs", priv->groupMinimizedTabs);

		/* Move minimized tabs in all browsers to front if activated */
		if(priv->groupMinimizedTabs)
		{
			browsers=midori_app_get_browsers(priv->application);
			for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter))
			{
				browser=MIDORI_BROWSER(browsersIter->data);
				if(browser)
				{
					notebook=NULL;
					g_object_get(browser, "notebook", &notebook, NULL);
					if(notebook)
					{
						tabs=midori_browser_get_tabs(MIDORI_BROWSER(browsersIter->data));
						for(tabsIter=tabs; tabsIter; tabsIter=g_list_next(tabsIter))
						{
							view=MIDORI_VIEW(tabsIter->data);
							if(view)
							{
								g_signal_handlers_block_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);

								minimized=FALSE;
								g_object_get(view, "minimized", &minimized, NULL);
								if(minimized) gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook), GTK_WIDGET(view), 0);

								g_signal_handlers_unblock_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);
							}
						}
						g_list_free(tabs);

						g_object_unref(notebook);
					}
				}
			}
			g_list_free(browsers);
		}

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), InterfaceTweaksProperties[PROP_GROUP_MINIMIZED_TABS]);
	}
}
示例#6
0
static void
temu_reorder (terms_t *terms)
{
	int i, j;

	for (i = j = 0; i < terms->n_active && j < terms->alive; i++)
		if (terms->active[i])
			gtk_notebook_reorder_child (terms->notebook, terms->active[i], j++);
}
示例#7
0
文件: wins.c 项目: UIKit0/picogui
void
wins_move_leftorright (GtkWidget *win, int left)
{
	int pos;
	xchatwin *xw;

	xw = (xchatwin *) gtk_object_get_user_data (GTK_OBJECT (win));

	pos = gtk_notebook_get_current_page (GTK_NOTEBOOK (main_book));

	if (left)
	{
		if (pos > 0)
			gtk_notebook_reorder_child (GTK_NOTEBOOK (main_book), xw->child, pos - 1);
	} else
	{
		gtk_notebook_reorder_child (GTK_NOTEBOOK (main_book), xw->child, pos + 1);
	}
}
示例#8
0
void
girara_tab_position_set(girara_session_t* session, girara_tab_t* tab, unsigned int position)
{
    if (session == NULL || session->gtk.tabs == NULL
            || tab == NULL || tab->widget == NULL) {
        return;
    }

    gtk_notebook_reorder_child(session->gtk.tabs, tab->widget, position);
}
示例#9
0
static gint
luaH_notebook_reorder(lua_State *L)
{
    widget_t *w = luaH_checkwidget(L, 1);
    widget_t *child = luaH_checkwidget(L, 2);
    gint i = luaL_checknumber(L, 3);
    /* correct lua index */
    if (i != -1) i--;
    gtk_notebook_reorder_child(GTK_NOTEBOOK(w->widget), child->widget, i);
    lua_pushnumber(L, gtk_notebook_page_num(GTK_NOTEBOOK(w->widget), child->widget));
    return 1;
}
示例#10
0
文件: notebook.c 项目: amery/clip-itk
/* Moves the page child, so that it appears in position position.
 * Out of bounds position will be clamped. */
int
clip_GTK_NOTEBOOKREORDERCHILD(ClipMachine * cm)
{
	C_widget   *cntb = _fetch_cw_arg(cm);
	C_widget *cchild = _fetch_cwidget(cm,_clip_spar(cm,2));
	gint    position = _clip_parni(cm,3);
	CHECKCWID(cntb,GTK_IS_NOTEBOOK);
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cchild,GTK_IS_WIDGET);
	CHECKOPT(3,NUMERIC_t);
	if (_clip_parinfo(cm,2)==UNDEF_t) position = 1;
	gtk_notebook_reorder_child(GTK_NOTEBOOK(cntb->widget), cchild->widget, position);
	return 0;
err:
	return 1;
}
示例#11
0
/* {EV_NOTEBOOK_IMP}.gtk_insert_i_th */
void F1106_14794 (EIF_REFERENCE Current, EIF_POINTER arg1, EIF_POINTER arg2, EIF_INTEGER_32 arg3)
{
	GTCX
	RTLD;
	
	RTLI(1);
	RTLR(0,Current);
	
	RTGC;
	gtk_container_add((GtkContainer*) arg1, (GtkWidget*) arg2);
	if ((EIF_BOOLEAN) (arg3 < F1058_13827(Current))) {
		gtk_notebook_reorder_child((GtkNotebook*) arg1, (GtkWidget*) arg2, (gint) arg3);
	}
	RTLE;
}
/* A tab of a browser was reordered */
static void _interface_tweaks_on_tab_reordered(InterfaceTweaks *self,
												GtkWidget *inChild,
												guint inPageNumber,
												gpointer inUserData)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));
	g_return_if_fail(MIDORI_IS_VIEW(inChild));
	g_return_if_fail(GTK_IS_NOTEBOOK(inUserData));

	InterfaceTweaksPrivate	*priv=self->priv;
	MidoriView				*view=MIDORI_VIEW(inChild);
	GtkNotebook				*notebook=GTK_NOTEBOOK(inUserData);
	MidoriBrowser			*browser;
	gboolean				minimized;
	gint					firstMaximizedPosition;

	/* Check if tab we should group minimized tabs to front */
	if(!priv->groupMinimizedTabs) return;

	/* Check if tab was minimized */
	minimized=FALSE;
	g_object_get(view, "minimized", &minimized, NULL);

	/* Get browser of tab */
	browser=midori_browser_get_for_widget(GTK_WIDGET(view));
	if(!browser) return;

	/* Find position of first maximized tab */
	firstMaximizedPosition=_interface_tweak_get_browser_first_maximized_tab_position(browser, view);

	/* If tab is maximized then it moves away from front and
	 * the position must be decreased by one to get the first maximized tab
	 */
	if(!minimized) firstMaximizedPosition--;

	/* Reorder tab now */
	if(firstMaximizedPosition<0) firstMaximizedPosition=0;
	if((minimized==TRUE && inPageNumber>=firstMaximizedPosition) ||
		(minimized==FALSE && inPageNumber<firstMaximizedPosition))
	{
		g_signal_handlers_block_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);

		gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook), GTK_WIDGET(view), firstMaximizedPosition);

		g_signal_handlers_unblock_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);
	}
}
/* A tab was minimized (pinned) or maximized (unpinned) - Check for grouping tabs */
static void _interface_tweaks_on_notify_minimized_tab_for_group_tabs(InterfaceTweaks *self, GParamSpec *inSpec, gpointer inUserData)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));
	g_return_if_fail(MIDORI_IS_VIEW(inUserData));

	InterfaceTweaksPrivate	*priv=self->priv;
	MidoriView				*view=MIDORI_VIEW(inUserData);
	gboolean				minimized;
	MidoriBrowser			*browser;
	GtkContainer			*notebook;
	gint					firstMaximizedPosition;

	/* Check if tab was minimized */
	minimized=FALSE;
	g_object_get(view, "minimized", &minimized, NULL);

	/* Check if tab we should group minimized tabs to front */
	if(!priv->groupMinimizedTabs) return;
	
	/* Get browser of tab */
	browser=midori_browser_get_for_widget(GTK_WIDGET(view));
	if(!browser) return;

	/* Get notebook containing tabs of browser */
	notebook=NULL;
	g_object_get(browser, "notebook", &notebook, NULL);
	if(!notebook) return;

	/* Find position of first maximized tab */
	firstMaximizedPosition=_interface_tweak_get_browser_first_maximized_tab_position(browser, view);

	/* If tab is maximized then it moves away from front and
	 * the position must be decreased by one to get the first maximized tab
	 */
	if(!minimized) firstMaximizedPosition--;

	/* Reorder tab now */
	g_signal_handlers_block_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);

	if(firstMaximizedPosition<0) firstMaximizedPosition=0;
	gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook), GTK_WIDGET(view), firstMaximizedPosition);

	g_signal_handlers_unblock_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);

	g_object_unref(notebook);
}
示例#14
0
static void
chat_window_tabs_right_activate_cb (GtkWidget        *menuitem,
				    EmpathyChatWindow *window)
{
	EmpathyChatWindowPriv *priv;
	EmpathyChat           *chat;
	gint                  index;

	priv = GET_PRIV (window);

	chat = priv->current_chat;
	index = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));

	gtk_notebook_reorder_child (GTK_NOTEBOOK (priv->notebook),
				    GTK_WIDGET (chat),
				    index + 1);
}
示例#15
0
void
nemo_notebook_reorder_child_relative (NemoNotebook *notebook,
				      int    	    page_num,
				      int 	    offset)
{
	GtkNotebook *gnotebook;
	GtkWidget *page;

	g_return_if_fail (NEMO_IS_NOTEBOOK (notebook));
	g_return_if_fail (page_num != -1);
	if (!nemo_notebook_can_reorder_child_relative (
		notebook, page_num, offset)) {
		return;
	}

	gnotebook = GTK_NOTEBOOK (notebook);
	page = gtk_notebook_get_nth_page (gnotebook, page_num);
	g_return_if_fail (page != NULL);
	gtk_notebook_reorder_child (gnotebook, page, page_num + offset);
}
示例#16
0
void
nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook,
						  int offset)
{
	GtkNotebook *gnotebook;
	GtkWidget *child;
	int page;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));

	if (!nautilus_notebook_can_reorder_current_child_relative (notebook, offset)) {
		return;
	}

	gnotebook = GTK_NOTEBOOK (notebook);

	page = gtk_notebook_get_current_page (gnotebook);
	child = gtk_notebook_get_nth_page (gnotebook, page);
	gtk_notebook_reorder_child (gnotebook, child, page + offset);
}
示例#17
0
static void
gnc_prefs_sort_pages (GtkNotebook *notebook)
{
    gint n_pages, i;
    GList *tabs = NULL, *iter = NULL;

    g_return_if_fail (GTK_IS_NOTEBOOK (notebook));

    /* gather tabs */
    n_pages = gtk_notebook_get_n_pages (notebook);
    for (i = n_pages - 1; i >= 0; i--)
        tabs = g_list_prepend (tabs, gtk_notebook_get_nth_page (notebook, i));

    /* sort in local copy */
    tabs = g_list_sort_with_data (tabs, (GCompareDataFunc) tab_cmp, notebook);

    /* reorder tabs */
    for (i = 0, iter = tabs; iter; i++, iter = iter->next)
        gtk_notebook_reorder_child (notebook, GTK_WIDGET (iter->data), i);

    g_list_free (tabs);
}
示例#18
0
void
ephy_notebook_tab_set_pinned (EphyNotebook *notebook,
                              GtkWidget    *embed,
                              gboolean      is_pinned)
{
  GtkWidget *tab_label;
  gboolean expanded;

  if (is_pinned) {
    gtk_notebook_reorder_child (GTK_NOTEBOOK (notebook), embed, 0);
    expanded = FALSE;
  } else {
    expanded = g_settings_get_boolean (EPHY_SETTINGS_UI, EPHY_PREFS_UI_EXPAND_TABS_BAR);
  }

  gtk_container_child_set (GTK_CONTAINER (notebook), embed, "tab-expand", expanded, NULL);

  gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), embed, !is_pinned);

  tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), embed);
  ephy_tab_label_set_pinned (tab_label, is_pinned);
}
示例#19
0
static void
anjuta_docman_order_tabs (AnjutaDocman *docman)
{
	gint i, num_pages;
	GList *node;
	AnjutaDocmanPage *page;
	order_struct *tab_labels;
	GtkNotebook *notebook;

	notebook = GTK_NOTEBOOK (docman);

	num_pages = gtk_notebook_get_n_pages (notebook);
	if (num_pages < 2)
		return;
	tab_labels = g_new0 (order_struct, num_pages);
	node = docman->priv->pages;
	for (i = 0; i < num_pages; i++)
	{
		if (node != NULL && node->data != NULL)
		{
			page = node->data;
			tab_labels[i].m_widget = page->widget; /* CHECKME needed ? */
			tab_labels[i].m_label = ianjuta_document_get_filename (page->doc, NULL);
			node = g_list_next (node);
		}
	}
	qsort (tab_labels, num_pages, sizeof(order_struct), do_ordertab1);
	g_signal_handlers_block_by_func (G_OBJECT (notebook),
									(gpointer) on_notebook_page_reordered,
									(gpointer) docman);
	for (i = 0; i < num_pages; i++)
		gtk_notebook_reorder_child (notebook, tab_labels[i].m_widget, i);
	g_signal_handlers_unblock_by_func (G_OBJECT (notebook),
									  (gpointer) on_notebook_page_reordered,
									  (gpointer) docman);
	g_free (tab_labels);
	anjuta_docman_update_documents_menu(docman);
}
示例#20
0
static gboolean
on_notebook_tab_btnrelease (GtkWidget *widget, GdkEventButton *event, AnjutaDocman* docman)
{
	docman->priv->tab_pressed = FALSE;

	if (anjuta_preferences_get_bool (docman->priv->preferences, EDITOR_TABS_RECENT_FIRST))
	{
		GList *node;

		for (node = docman->priv->pages; node != NULL; node = g_list_next (node))
		{
			AnjutaDocmanPage *page;

			page = (AnjutaDocmanPage *)node->data;
			if (page->box == widget)
			{
				gtk_notebook_reorder_child (GTK_NOTEBOOK (docman), page->widget, 0);
				break;
			}
		}
	}

	return FALSE;
}
static void add_remove_pages (void)
{
    gint lists = aud_playlist_count ();
    gint pages = gtk_notebook_get_n_pages ((GtkNotebook *) notebook);

    /* scan through existing treeviews */
    for (gint i = 0; i < pages; )
    {
        GtkWidget * page = gtk_notebook_get_nth_page ((GtkNotebook *) notebook, i);
        GtkWidget * tree = g_object_get_data ((GObject *) page, "treeview");
        gint tree_id = GPOINTER_TO_INT (g_object_get_data ((GObject *) tree, "playlist-id"));

        /* do we have an orphaned treeview? */
        if (aud_playlist_by_unique_id (tree_id) < 0)
        {
            g_signal_handlers_block_by_func (notebook, (void *) tab_changed, NULL);
            gtk_notebook_remove_page ((GtkNotebook *) notebook, i);
            g_signal_handlers_unblock_by_func (notebook, (void *) tab_changed, NULL);
            pages --;
            continue;
        }

        /* do we have the right treeview? */
        gint list_id = aud_playlist_get_unique_id (i);

        if (tree_id == list_id)
        {
            ui_playlist_widget_set_playlist (tree, i);
            i ++;
            continue;
        }

        /* look for the right treeview */
        gint found = FALSE;

        for (gint j = i + 1; j < pages; j ++)
        {
            page = gtk_notebook_get_nth_page ((GtkNotebook *) notebook, j);
            tree = g_object_get_data ((GObject *) page, "treeview");
            tree_id = GPOINTER_TO_INT (g_object_get_data ((GObject *) tree, "playlist-id"));

            /* found it? move it to the right place */
            if (tree_id == list_id)
            {
                g_signal_handlers_block_by_func (notebook, (void *) tab_reordered, NULL);
                gtk_notebook_reorder_child ((GtkNotebook *) notebook, page, i);
                g_signal_handlers_unblock_by_func (notebook, (void *) tab_reordered, NULL);
                found = TRUE;
                break;
            }
        }

        /* didn't find it? create it */
        if (! found)
        {
            ui_playlist_notebook_create_tab (i);
            pages ++;
            continue;
        }
    }

    /* create new treeviews */
    while (pages < lists)
    {
        ui_playlist_notebook_create_tab (pages);
        pages ++;
    }
}
示例#22
0
void
gnm_notebook_move_tab (GnmNotebook *nb, GtkWidget *label, int newpos)
{
	GtkWidget *child = g_object_get_data (G_OBJECT (label), DUMMY_KEY);
	gtk_notebook_reorder_child (GTK_NOTEBOOK (nb), child, newpos);
}
示例#23
0
static gboolean
on_notebook_tab_btnrelease (GtkWidget *widget, GdkEventButton *event, AnjutaDocman* docman)
{
	AnjutaDocmanPage *page;
	AnjutaDocmanPage *curr_page = NULL;

	docman->priv->tab_pressed = FALSE;

	/* close on middle click */
	if (event->button == 2)
	{
		/* the close function works only on the current document */
		GList* node;
		for (node = docman->priv->pages; node != NULL; node = g_list_next (node))
		{
			page = (AnjutaDocmanPage *) node->data;
			if (page->box == widget)
			{
				/* we've found the page that user wants to close. Save the current
				 * page for a later setup
				 */
				curr_page = anjuta_docman_get_current_page (docman);
				anjuta_docman_set_current_document (docman, page->doc);
				break;
			}
		}
		if (node == NULL)
			return FALSE;

		if (page != NULL)
		{
			on_close_file_activate (NULL, docman->priv->plugin);

			if (curr_page != NULL)
			{
				/* set the old current page */
				anjuta_docman_set_current_document (docman, curr_page->doc);
			}
		}

		return FALSE;
	}

	/* normal button click close */
	if (g_settings_get_boolean (docman->priv->settings, EDITOR_TABS_RECENT_FIRST))
	{
		GList *node;

		for (node = docman->priv->pages; node != NULL; node = g_list_next (node))
		{
			AnjutaDocmanPage *page;

			page = (AnjutaDocmanPage *)node->data;
			if (page->box == widget)
			{
				gtk_notebook_reorder_child (GTK_NOTEBOOK (docman), page->widget, 0);
				break;
			}
		}
	}

	return FALSE;
}