void
nautilus_notebook_sync_loading (NautilusNotebook *notebook,
				NautilusWindowSlot *slot)
{
	GtkWidget *tab_label, *spinner, *icon;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));

	tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), slot->content_box);
	g_return_if_fail (GTK_IS_WIDGET (tab_label));

	spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "spinner"));
	icon = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "icon"));
	g_return_if_fail (spinner != NULL && icon != NULL);

	if (ephy_spinner_get_spinning (EPHY_SPINNER (spinner)) == slot->allow_stop) {
		return;
	}

	if (slot->allow_stop)
	{
		gtk_widget_hide (icon);
		gtk_widget_show (spinner);
		ephy_spinner_start (EPHY_SPINNER (spinner));
	}
	else
	{
		ephy_spinner_stop (EPHY_SPINNER (spinner));
		gtk_widget_hide (spinner);
		gtk_widget_show (icon);
	}
}
void
nautilus_notebook_sync_tab_label (NautilusNotebook *notebook,
				  NautilusWindowSlot *slot)
{
	GtkWidget *hbox, *label;
	char *location_name;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
	g_return_if_fail (GTK_IS_WIDGET (slot->content_box));

	hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), slot->content_box);
	g_return_if_fail (GTK_IS_WIDGET (hbox));

	label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
	g_return_if_fail (GTK_IS_WIDGET (label));

	gtk_label_set_text (GTK_LABEL (label), slot->title);

	if (slot->location != NULL) {
		/* Set the tooltip on the label's parent (the tab label hbox),
		 * so it covers all of the tab label.
		 */
		location_name = g_file_get_parse_name (slot->location);
		gtk_widget_set_tooltip_text (label->parent, location_name);
		g_free (location_name);
	} else {
		gtk_widget_set_tooltip_text (label->parent, NULL);
	}
}
Ejemplo n.º 3
0
int
nautilus_notebook_add_tab (NautilusNotebook *notebook,
			   NautilusWindowSlot *slot,
			   int position,
			   gboolean jump_to)
{
	GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
	GtkWidget *tab_label;

	g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), -1);
	g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot), -1);

	tab_label = build_tab_label (notebook, slot);

	position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
					     GTK_WIDGET (slot),
					     tab_label,
					     position);

	gtk_container_child_set (GTK_CONTAINER (notebook),
				 GTK_WIDGET (slot),
				 "tab-expand", TRUE,
				 NULL);

	nautilus_notebook_sync_tab_label (notebook, slot);
	nautilus_notebook_sync_loading (notebook, slot);

	if (jump_to) {
		gtk_notebook_set_current_page (gnotebook, position);
	}

	return position;
}
Ejemplo n.º 4
0
void
nautilus_notebook_sync_loading (NautilusNotebook *notebook,
				NautilusWindowSlot *slot)
{
	GtkWidget *tab_label, *spinner, *icon;
	gboolean active;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));

	tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), 
						GTK_WIDGET (slot));
	g_return_if_fail (GTK_IS_WIDGET (tab_label));

	spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "spinner"));
	icon = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "icon"));
	g_return_if_fail (spinner != NULL && icon != NULL);

	active = FALSE;
	g_object_get (spinner, "active", &active, NULL);
	if (active == slot->allow_stop)	{
		return;
	}

	if (slot->allow_stop) {
		gtk_widget_hide (icon);
		gtk_widget_show (spinner);
		gtk_spinner_start (GTK_SPINNER (spinner));
	} else {
		gtk_spinner_stop (GTK_SPINNER (spinner));
		gtk_widget_hide (spinner);
		gtk_widget_show (icon);
	}
}
Ejemplo n.º 5
0
gboolean
nautilus_notebook_can_set_current_page_relative (NautilusNotebook *notebook,
						 int offset)
{
	g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), FALSE);

	return nautilus_notebook_is_valid_relative_position (notebook, offset);
}
Ejemplo n.º 6
0
void
nautilus_notebook_set_current_page_relative (NautilusNotebook *notebook,
					     int offset)
{
	GtkNotebook *gnotebook;
	int page;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));

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

	gnotebook = GTK_NOTEBOOK (notebook);

	page = gtk_notebook_get_current_page (gnotebook);
	gtk_notebook_set_current_page (gnotebook, page + offset);

}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
0
int
nautilus_notebook_add_tab (NautilusNotebook *notebook,
			   NautilusWindowSlot *slot,
			   int position,
			   gboolean jump_to)
{
	GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
	GtkWidget *tab_label;

	g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), -1);
	g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot), -1);

	tab_label = build_tab_label (notebook, slot);

	position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
					     slot->content_box,
					     tab_label,
					     position);

	gtk_container_child_set (GTK_CONTAINER (notebook),
				 slot->content_box,
				 "tab-expand", TRUE,
				 NULL);

	nautilus_notebook_sync_tab_label (notebook, slot);
	nautilus_notebook_sync_loading (notebook, slot);


	/* FIXME gtk bug! */
	/* FIXME: this should be fixed in gtk 2.12; check & remove this! */
	/* The signal handler may have reordered the tabs */
	position = gtk_notebook_page_num (gnotebook, slot->content_box);

	if (jump_to)
	{
		gtk_notebook_set_current_page (gnotebook, position);

	}

	return position;
}
Ejemplo n.º 9
0
void
nautilus_notebook_prev_page (NautilusNotebook *notebook)
{
	gint current_page;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));

	current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));

	if (current_page > 0)
		gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
	else {
		gboolean  wrap_around;

		g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
			      "gtk-keynav-wrap-around", &wrap_around,
			      NULL);

		if (wrap_around)
			gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1);
	}
}
Ejemplo n.º 10
0
void
nautilus_notebook_sync_tab_label (NautilusNotebook *notebook,
				  NautilusWindowSlot *slot)
{
	GtkWidget *hbox, *label;
	char *location_name;
	GFile *location;
	const gchar *title_name;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));

	hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), GTK_WIDGET (slot));
	g_return_if_fail (GTK_IS_WIDGET (hbox));

	label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
	g_return_if_fail (GTK_IS_WIDGET (label));

	gtk_label_set_text (GTK_LABEL (label), nautilus_window_slot_get_title (slot));
	location = nautilus_window_slot_get_location (slot);

	if (location != NULL) {
		/* Set the tooltip on the label's parent (the tab label hbox),
		 * so it covers all of the tab label.
		 */
		location_name = g_file_get_parse_name (location);
		title_name = nautilus_window_slot_get_title (slot);
		if (g_str_has_prefix (location_name, EEL_SEARCH_URI)) {
			gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), title_name);
		} else {
			gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), location_name);
		}
		g_free (location_name);
	} else {
		gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), NULL);
	}
}