static void pluma_notebook_switch_page_cb (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data) { PlumaNotebook *nb = PLUMA_NOTEBOOK (notebook); GtkWidget *child; PlumaView *view; child = gtk_notebook_get_nth_page (notebook, page_num); /* Remove the old page, we dont want to grow unnecessarily * the list */ if (nb->priv->focused_pages) { nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages, child); } nb->priv->focused_pages = g_list_append (nb->priv->focused_pages, child); /* give focus to the view */ view = pluma_tab_get_view (PLUMA_TAB (child)); gtk_widget_grab_focus (GTK_WIDGET (view)); }
static PlumaNotebook * find_notebook_at_pointer (gint abs_x, gint abs_y) { GdkWindow *win_at_pointer; GdkWindow *toplevel_win; gpointer toplevel = NULL; gint x, y; /* FIXME multi-head */ win_at_pointer = gdk_window_at_pointer (&x, &y); if (win_at_pointer == NULL) { /* We are outside all windows of the same application */ return NULL; } toplevel_win = gdk_window_get_toplevel (win_at_pointer); /* get the GtkWidget which owns the toplevel GdkWindow */ gdk_window_get_user_data (toplevel_win, &toplevel); /* toplevel should be an PlumaWindow */ if ((toplevel != NULL) && PLUMA_IS_WINDOW (toplevel)) { return PLUMA_NOTEBOOK (_pluma_window_get_notebook (PLUMA_WINDOW (toplevel))); } /* We are outside all windows containing a notebook */ return NULL; }
static void pluma_notebook_finalize (GObject *object) { PlumaNotebook *notebook = PLUMA_NOTEBOOK (object); g_list_free (notebook->priv->focused_pages); G_OBJECT_CLASS (pluma_notebook_parent_class)->finalize (object); }
void _pluma_cmd_documents_move_to_new_window (GtkAction *action, PlumaWindow *window) { PlumaNotebook *old_notebook; PlumaTab *tab; pluma_debug (DEBUG_COMMANDS); tab = pluma_window_get_active_tab (window); if (tab == NULL) return; old_notebook = PLUMA_NOTEBOOK (_pluma_window_get_notebook (window)); g_return_if_fail (gtk_notebook_get_n_pages (GTK_NOTEBOOK (old_notebook)) > 1); _pluma_window_move_tab_to_new_window (window, tab); }
/* This function is only called during dnd, we don't need to emit TABS_REORDERED * here, instead we do it on drag_stop */ static void move_current_tab (PlumaNotebook *notebook, gint dest_position) { gint cur_page_num; cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); if (dest_position != cur_page_num) { GtkWidget *cur_tab; cur_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), cur_page_num); pluma_notebook_reorder_tab (PLUMA_NOTEBOOK (notebook), PLUMA_TAB (cur_tab), dest_position); } }
static void treeview_row_inserted (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, PlumaDocumentsPanel *panel) { PlumaTab *tab; gint *indeces; GtkWidget *nb; gint old_position; gint new_position; if (panel->priv->adding_tab) return; tab = pluma_window_get_active_tab (panel->priv->window); g_return_if_fail (tab != NULL); panel->priv->is_reodering = TRUE; indeces = gtk_tree_path_get_indices (path); /* g_debug ("New Index: %d (path: %s)", indeces[0], gtk_tree_path_to_string (path));*/ nb = _pluma_window_get_notebook (panel->priv->window); new_position = indeces[0]; old_position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab)); if (new_position > old_position) new_position = MAX (0, new_position - 1); pluma_notebook_reorder_tab (PLUMA_NOTEBOOK (nb), tab, new_position); panel->priv->is_reodering = FALSE; }
static void pluma_notebook_destroy (GtkObject *object) { PlumaNotebook *notebook = PLUMA_NOTEBOOK (object); if (!notebook->priv->destroy_has_run) { GList *children, *l; children = gtk_container_get_children (GTK_CONTAINER (notebook)); for (l = children; l != NULL; l = g_list_next (l)) { pluma_notebook_remove_tab (notebook, PLUMA_TAB (l->data)); } g_list_free (children); notebook->priv->destroy_has_run = TRUE; } GTK_OBJECT_CLASS (pluma_notebook_parent_class)->destroy (object); }