Exemplo n.º 1
0
/**
 * pluma_notebook_reorder_tab:
 * @src: a #PlumaNotebook
 * @tab: a #PlumaTab
 * @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
pluma_notebook_reorder_tab (PlumaNotebook *src,
			    PlumaTab      *tab,
			    gint           dest_position)
{
	gint old_position;
	
	g_return_if_fail (PLUMA_IS_NOTEBOOK (src));	
	g_return_if_fail (PLUMA_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);
	}
}
Exemplo n.º 2
0
static gchar *
tab_get_name (PlumaTab *tab)
{
	PlumaDocument *doc;
	gchar *name;
	gchar *docname;
	gchar *tab_name;

	g_return_val_if_fail (PLUMA_IS_TAB (tab), NULL);

	doc = pluma_tab_get_document (tab);

	name = pluma_document_get_short_name_for_display (doc);

	/* Truncate the name so it doesn't get insanely wide. */
	docname = pluma_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);

	if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
	{
		if (pluma_document_get_readonly (doc))
		{
			tab_name = g_markup_printf_escaped ("<i>%s</i> [<i>%s</i>]",
							    docname,
							    _("Read-Only"));
		}
		else
		{
			tab_name = g_markup_printf_escaped ("<i>%s</i>", 
							    docname);
		}
	}
	else
	{
		if (pluma_document_get_readonly (doc))
		{
			tab_name = g_markup_printf_escaped ("%s [<i>%s</i>]",
							    docname,
							    _("Read-Only"));
		}
		else
		{
			tab_name = g_markup_escape_text (docname, -1);
		}
	}

	g_free (docname);
	g_free (name);

	return tab_name;
}
Exemplo n.º 3
0
/**
 * pluma_notebook_move_tab:
 * @src: a #PlumaNotebook
 * @dest: a #PlumaNotebook
 * @tab: a #PlumaTab
 * @dest_position: the position for @tab
 *
 * Moves @tab from @src to @dest.
 * If dest_position is greater than or equal to the number of tabs 
 * of the destination nootebook or negative, tab will be moved to the 
 * end of the tabs.
 */
void
pluma_notebook_move_tab (PlumaNotebook *src,
			 PlumaNotebook *dest,
			 PlumaTab      *tab,
			 gint           dest_position)
{
	g_return_if_fail (PLUMA_IS_NOTEBOOK (src));	
	g_return_if_fail (PLUMA_IS_NOTEBOOK (dest));
	g_return_if_fail (src != dest);
	g_return_if_fail (PLUMA_IS_TAB (tab));

	/* make sure the tab isn't destroyed while we move it */
	g_object_ref (tab);
	pluma_notebook_remove_tab (src, tab);
	pluma_notebook_add_tab (dest, tab, dest_position, TRUE);
	g_object_unref (tab);
}
Exemplo n.º 4
0
/**
 * pluma_notebook_remove_tab:
 * @nb: a #PlumaNotebook
 * @tab: a #PlumaTab
 *
 * Removes @tab from @nb.
 */
void
pluma_notebook_remove_tab (PlumaNotebook *nb,
			   PlumaTab      *tab)
{
	gint position, curr;

	g_return_if_fail (PLUMA_IS_NOTEBOOK (nb));
	g_return_if_fail (PLUMA_IS_TAB (tab));

	/* Remove the page from the focused pages list */
	nb->priv->focused_pages =  g_list_remove (nb->priv->focused_pages,
						  tab);

	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
	curr = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));

	if (position == curr)
	{
		smart_tab_switching_on_closure (nb, tab);
	}

	remove_tab (tab, nb);
}
Exemplo n.º 5
0
/**
 * pluma_notebook_add_tab:
 * @nb: a #PlumaNotebook
 * @tab: a #PlumaTab
 * @position: the position where the @tab should be added
 * @jump_to: %TRUE to set the @tab as active
 *
 * Adds the specified @tab to the @nb.
 */
void
pluma_notebook_add_tab (PlumaNotebook *nb,
		        PlumaTab      *tab,
		        gint           position,
		        gboolean       jump_to)
{
	GtkWidget *tab_label;

	g_return_if_fail (PLUMA_IS_NOTEBOOK (nb));
	g_return_if_fail (PLUMA_IS_TAB (tab));

	tab_label = create_tab_label (nb, tab);
	gtk_notebook_insert_page (GTK_NOTEBOOK (nb), 
				  GTK_WIDGET (tab),
				  tab_label,
				  position);
	update_tabs_visibility (nb, TRUE);

	g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);

	/* The signal handler may have reordered the tabs */
	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), 
					  GTK_WIDGET (tab));

	if (jump_to)
	{
		PlumaView *view;
		
		gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), position);
		g_object_set_data (G_OBJECT (tab), 
				   "jump_to",
				   GINT_TO_POINTER (jump_to));
		view = pluma_tab_get_view (tab);
		
		gtk_widget_grab_focus (GTK_WIDGET (view));
	}
}