static void sync_name_and_icon (PlumaTab *tab, GParamSpec *pspec, PlumaDocumentsPanel *panel) { GdkPixbuf *pixbuf; gchar *name; GtkTreeIter iter; get_iter_from_tab (panel, tab, &iter); name = tab_get_name (tab); pixbuf = _pluma_tab_get_icon (tab); gtk_list_store_set (GTK_LIST_STORE (panel->priv->model), &iter, PIXBUF_COLUMN, pixbuf, NAME_COLUMN, name, TAB_COLUMN, tab, -1); g_free (name); if (pixbuf != NULL) g_object_unref (pixbuf); }
static void sync_name_and_icon (GeditTab *tab, GParamSpec *pspec, GeditDocumentsPanel *panel) { GtkTreeIter iter; gedit_debug (DEBUG_PANEL); if (get_iter_from_tab (panel, gedit_multi_notebook_get_active_notebook (panel->priv->mnb), tab, &iter)) { gchar *name; GdkPixbuf *pixbuf; name = tab_get_name (tab); pixbuf = _gedit_tab_get_icon (tab); gtk_tree_store_set (GTK_TREE_STORE (panel->priv->model), &iter, PIXBUF_COLUMN, pixbuf, NAME_COLUMN, name, -1); g_free (name); if (pixbuf != NULL) { g_object_unref (pixbuf); } } }
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 window_tab_added (PlumaWindow *window, PlumaTab *tab, PlumaDocumentsPanel *panel) { GtkTreeIter iter; GtkTreeIter sibling; GdkPixbuf *pixbuf; gchar *name; g_signal_connect (tab, "notify::name", G_CALLBACK (sync_name_and_icon), panel); g_signal_connect (tab, "notify::state", G_CALLBACK (sync_name_and_icon), panel); get_iter_from_tab (panel, tab, &sibling); panel->priv->adding_tab = TRUE; if (gtk_list_store_iter_is_valid (GTK_LIST_STORE (panel->priv->model), &sibling)) { gtk_list_store_insert_after (GTK_LIST_STORE (panel->priv->model), &iter, &sibling); } else { PlumaTab *active_tab; gtk_list_store_append (GTK_LIST_STORE (panel->priv->model), &iter); active_tab = pluma_window_get_active_tab (panel->priv->window); if (tab == active_tab) { GtkTreeSelection *selection; selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (panel->priv->treeview)); gtk_tree_selection_select_iter (selection, &iter); } } name = tab_get_name (tab); pixbuf = _pluma_tab_get_icon (tab); gtk_list_store_set (GTK_LIST_STORE (panel->priv->model), &iter, PIXBUF_COLUMN, pixbuf, NAME_COLUMN, name, TAB_COLUMN, tab, -1); g_free (name); if (pixbuf != NULL) g_object_unref (pixbuf); panel->priv->adding_tab = FALSE; }
static void refresh_list (PlumaDocumentsPanel *panel) { /* TODO: refresh the list only if the panel is visible */ GList *tabs; GList *l; GtkWidget *nb; GtkListStore *list_store; PlumaTab *active_tab; /* g_debug ("refresh_list"); */ list_store = GTK_LIST_STORE (panel->priv->model); gtk_list_store_clear (list_store); active_tab = pluma_window_get_active_tab (panel->priv->window); nb = _pluma_window_get_notebook (panel->priv->window); tabs = gtk_container_get_children (GTK_CONTAINER (nb)); l = tabs; panel->priv->adding_tab = TRUE; while (l != NULL) { GdkPixbuf *pixbuf; gchar *name; GtkTreeIter iter; name = tab_get_name (PLUMA_TAB (l->data)); pixbuf = _pluma_tab_get_icon (PLUMA_TAB (l->data)); /* Add a new row to the model */ gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, PIXBUF_COLUMN, pixbuf, NAME_COLUMN, name, TAB_COLUMN, l->data, -1); g_free (name); if (pixbuf != NULL) g_object_unref (pixbuf); if (l->data == active_tab) { GtkTreeSelection *selection; selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (panel->priv->treeview)); gtk_tree_selection_select_iter (selection, &iter); } l = g_list_next (l); } panel->priv->adding_tab = FALSE; g_list_free (tabs); }