static void gedit_notebook_page_removed (GtkNotebook *notebook, GtkWidget *page, guint page_num) { GeditNotebook *nb = GEDIT_NOTEBOOK (notebook); gint curr; GtkWidget *tab_label; tab_label = get_tab_label (GEDIT_TAB (page)); if (tab_label != NULL) { g_signal_handlers_disconnect_by_func (tab_label, G_CALLBACK (on_tab_label_destroyed), page); g_signal_handlers_disconnect_by_func (tab_label, G_CALLBACK (close_button_clicked_cb), nb); } /* Remove the page from the focused pages list */ nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages, page); curr = gtk_notebook_get_current_page (notebook); if (page_num == curr) { smart_tab_switching_on_closure (nb, GEDIT_TAB (page)); } }
static void refresh_notebook (GeditDocumentsPanel *panel, GeditNotebook *notebook, GtkTreeIter *parent) { GList *tabs; GList *l; GtkTreeStore *tree_store; GeditTab *active_tab; gedit_debug (DEBUG_PANEL); tree_store = GTK_TREE_STORE (panel->priv->model); active_tab = gedit_window_get_active_tab (panel->priv->window); tabs = gtk_container_get_children (GTK_CONTAINER (notebook)); for (l = tabs; l != NULL; l = g_list_next (l)) { GdkPixbuf *pixbuf; gchar *name; GtkTreeIter iter; name = tab_get_name (GEDIT_TAB (l->data)); pixbuf = _gedit_tab_get_icon (GEDIT_TAB (l->data)); /* Add a new row to the model */ gtk_tree_store_append (tree_store, &iter, parent); gtk_tree_store_set (tree_store, &iter, PIXBUF_COLUMN, pixbuf, NAME_COLUMN, name, NOTEBOOK_COLUMN, notebook, TAB_COLUMN, l->data, -1); g_free (name); if (pixbuf != NULL) { g_object_unref (pixbuf); } if (l->data == active_tab) { select_iter (panel, &iter); } } g_list_free (tabs); }
static void get_network_available (GNetworkMonitor *monitor, gboolean available, GeditApp *app) { gboolean enable; GList *windows, *w; enable = g_network_monitor_get_network_available (monitor); windows = gtk_application_get_windows (GTK_APPLICATION (app)); for (w = windows; w != NULL; w = w->next) { GeditWindow *window = GEDIT_WINDOW (w->data); if (GEDIT_IS_WINDOW (window)) { GList *tabs, *t; tabs = _gedit_window_get_all_tabs (window); for (t = tabs; t != NULL; t = t->next) { _gedit_tab_set_network_available (GEDIT_TAB (t->data), enable); } g_list_free (tabs); } } }
/** * srm_trainer_tab_add_to_window: * @tab: a #SrmTrainerTab instance * @window: the #GeditWindow to add a tab to * @jump_to: true if the newly added tab should be activated after its added * * Adds the tab to the supplied #GeditWindow instance's active #GeditNotebook. */ void srm_trainer_tab_add_to_window ( GeditTab * tab , GeditWindow * window , gboolean jump_to ) { GtkWidget * notebook; if (window == NULL || tab == NULL) { return; } g_return_if_fail (GEDIT_IS_WINDOW (window)); g_return_if_fail (GEDIT_IS_TAB (tab)); notebook = _gedit_window_get_notebook (window); gtk_widget_show (GTK_WIDGET (tab)); gedit_notebook_add_tab (GEDIT_NOTEBOOK (notebook), GEDIT_TAB (tab), -1, jump_to); if (!gtk_widget_get_visible (GTK_WIDGET (window))) { gtk_window_present (GTK_WINDOW (window)); } }
void gedit_multi_notebook_add_new_notebook (GeditMultiNotebook *mnb) { GtkWidget *notebook; GeditTab *tab; g_return_if_fail (GEDIT_IS_MULTI_NOTEBOOK (mnb)); notebook = gedit_notebook_new (); add_notebook (mnb, notebook, FALSE); tab = GEDIT_TAB (_gedit_tab_new ()); gtk_widget_show (GTK_WIDGET (tab)); /* When gtk_notebook_insert_page is called the focus is set in the notebook, we don't want this to happen until the page is added. Also we don't want to call switch_page when we add the tab but when we switch the notebook. */ g_signal_handlers_block_by_func (notebook, notebook_set_focus, mnb); g_signal_handlers_block_by_func (notebook, notebook_switch_page, mnb); gedit_notebook_add_tab (GEDIT_NOTEBOOK (notebook), tab, -1, TRUE); g_signal_handlers_unblock_by_func (notebook, notebook_switch_page, mnb); g_signal_handlers_unblock_by_func (notebook, notebook_set_focus, mnb); notebook_set_focus (GTK_CONTAINER (notebook), NULL, mnb); }
void gedit_multi_notebook_set_active_tab (GeditMultiNotebook *mnb, GeditTab *tab) { GList *l; gint page_num; g_return_if_fail (GEDIT_IS_MULTI_NOTEBOOK (mnb)); g_return_if_fail (GEDIT_IS_TAB (tab)); if (tab == GEDIT_TAB (mnb->priv->active_tab)) return; l = mnb->priv->notebooks; do { page_num = gtk_notebook_page_num (GTK_NOTEBOOK (l->data), GTK_WIDGET (tab)); if (page_num != -1) break; l = g_list_next (l); } while (l != NULL && page_num == -1); g_return_if_fail (page_num != -1); gtk_notebook_set_current_page (GTK_NOTEBOOK (l->data), page_num); if (GTK_WIDGET (l->data) != mnb->priv->active_notebook) { gtk_widget_grab_focus (GTK_WIDGET (l->data)); } }
static void notebook_switch_page (GtkNotebook *book, GtkWidget *pg, gint page_num, GeditMultiNotebook *mnb) { GeditTab *tab; /* When we switch a tab from a notebook that it is not the active one the switch page is emitted before the set focus, so we do this check and we avoid to call switch page twice */ if (GTK_WIDGET (book) != mnb->priv->active_notebook) return; /* CHECK: I don't know why but it seems notebook_switch_page is called two times every time the user change the active tab */ tab = GEDIT_TAB (gtk_notebook_get_nth_page (book, page_num)); if (tab != mnb->priv->active_tab) { GeditTab *old_tab; old_tab = mnb->priv->active_tab; /* set the active tab */ mnb->priv->active_tab = tab; g_object_notify (G_OBJECT (mnb), "active-tab"); g_signal_emit (G_OBJECT (mnb), signals[SWITCH_TAB], 0, mnb->priv->active_notebook, old_tab, book, tab); } }
static void notebook_page_removed (GtkNotebook *notebook, GtkWidget *child, guint page_num, GeditMultiNotebook *mnb) { GeditTab *tab = GEDIT_TAB (child); guint num_tabs; gboolean last_notebook; --mnb->priv->total_tabs; num_tabs = gtk_notebook_get_n_pages (notebook); last_notebook = (mnb->priv->notebooks->next == NULL); if (mnb->priv->total_tabs == 0) { mnb->priv->active_tab = NULL; g_object_notify (G_OBJECT (mnb), "active-tab"); } g_signal_emit (G_OBJECT (mnb), signals[TAB_REMOVED], 0, notebook, tab); /* Not last notebook but last tab of the notebook, this means we have to remove the current notebook */ if (num_tabs == 0 && !mnb->priv->removing_notebook && !last_notebook) { remove_notebook (mnb, GTK_WIDGET (notebook)); } }
GeditTab * gedit_multi_notebook_get_active_tab (GeditMultiNotebook *mnb) { g_return_val_if_fail (GEDIT_IS_MULTI_NOTEBOOK (mnb), NULL); return (mnb->priv->active_tab == NULL) ? NULL : GEDIT_TAB (mnb->priv->active_tab); }
static void gedit_notebook_page_removed (GtkNotebook *notebook, GtkWidget *page, guint page_num) { GeditNotebook *nb = GEDIT_NOTEBOOK (notebook); gint num_pages; gint curr; GtkWidget *tab_label; tab_label = get_tab_label (GEDIT_TAB (page)); if (tab_label != NULL) { g_signal_handlers_disconnect_by_func (tab_label, G_CALLBACK (on_tab_label_destroyed), page); g_signal_handlers_disconnect_by_func (tab_label, G_CALLBACK (close_button_clicked_cb), nb); } /* Remove the page from the focused pages list */ nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages, page); curr = gtk_notebook_get_current_page (notebook); if (page_num == curr) { smart_tab_switching_on_closure (nb, GEDIT_TAB (page)); } num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb)); /* If there is no tabs, calling this is pointless */ if (num_pages > 0) { update_tabs_visibility (nb, FALSE); } }
static void notebook_page_added (GtkNotebook *notebook, GtkWidget *child, guint page_num, GeditMultiNotebook *mnb) { GeditTab *tab = GEDIT_TAB (child); ++mnb->priv->total_tabs; g_signal_emit (G_OBJECT (mnb), signals[TAB_ADDED], 0, notebook, tab); }
static void gedit_notebook_page_added (GtkNotebook *notebook, GtkWidget *page, guint page_num) { GeditNotebook *nb = GEDIT_NOTEBOOK (notebook); GtkWidget *tab_label; tab_label = get_tab_label (GEDIT_TAB (page)); g_signal_connect (tab_label, "destroy", G_CALLBACK (on_tab_label_destroyed), page); g_signal_connect (tab_label, "close-clicked", G_CALLBACK (close_button_clicked_cb), nb); }