Source code for functions related to notebook management. More...
#include <gtk/gtk.h>
#include "application-data.h"
#include "notebook.h"
Go to the source code of this file.
Functions | |
void | notebook_on_page_switch (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data) |
void | notebook_remove_page (GtkToolButton *donotuse, gpointer user_data) |
const gchar * | notebook_get_tab_label (GtkNotebook *notebook, GtkWidget *child) |
frame_table_t * | _notebook_add_page (GtkWidget *frame_box, const gchar *tablabel) |
void | notebook_add_page (GtkToolButton *addbutton, gpointer user_data) |
void | notebook_on_page_added (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) |
void | notebook_on_page_removed (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) |
void | notebook_remove_all () |
Source code for functions related to notebook management.
This file contains the source code of all the functions related to the frame table notebook.
Definition in file notebook.c.
frame_table_t* _notebook_add_page | ( | GtkWidget * | frame_box, | |
const gchar * | tablabel | |||
) |
Definition at line 145 of file notebook.c.
00146 { 00147 synema_instance_t *inst = synema_instance (); 00148 frame_table_t *tmptab = frame_table_new (); 00149 GtkWidget *button = gtk_button_new (); 00150 GtkWidget *eventbox = gtk_event_box_new (); 00151 GtkWidget *hbox = gtk_hbox_new (FALSE, 0); 00152 GtkWidget *icon = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); 00153 GtkWidget *label = NULL; 00154 00155 // Making sure to have a label 00156 inst->labelcount++; 00157 label = (tablabel==NULL) ? notebook_new_page_label () : gtk_label_new (tablabel); 00158 00159 // Adding the label to the box and connecting it to click signals 00160 gtk_container_add (GTK_CONTAINER (eventbox), label); 00161 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eventbox), FALSE); 00162 gtk_widget_set_events (eventbox, GDK_BUTTON_PRESS_MASK); 00163 g_signal_connect (eventbox, "button_press_event", G_CALLBACK (notebook_edit_tab_label), label); 00164 00165 // Setting the button up 00166 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); 00167 gtk_container_add (GTK_CONTAINER (button), icon); 00168 g_signal_connect (button, "clicked", G_CALLBACK (notebook_remove_page), tmptab); 00169 00170 // Putting the widgets in the hbox 00171 gtk_box_pack_start (GTK_BOX (hbox), eventbox, TRUE, TRUE, 0); 00172 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); 00173 gtk_widget_show_all (hbox); 00174 gtk_widget_show_all (tmptab->table_box); 00175 00176 // Adding the page and tab to the notebook 00177 gtk_notebook_append_page (GTK_NOTEBOOK (frame_box), tmptab->table_box, hbox); 00178 gtk_notebook_set_current_page (GTK_NOTEBOOK (frame_box), -1); 00179 tmptab->position = gtk_notebook_get_current_page (GTK_NOTEBOOK (frame_box)); 00180 gtk_widget_show (frame_box); 00181 inst->tables_list = g_list_prepend (inst->tables_list, tmptab); 00182 frame_table_hide_frames (inst->current_table); 00183 inst->current_table = tmptab; 00184 00185 return tmptab; 00186 }
void notebook_add_page | ( | GtkToolButton * | addbutton, | |
gpointer | user_data | |||
) |
Definition at line 190 of file notebook.c.
00191 { 00192 _notebook_add_page (user_data, NULL); 00193 }
const gchar* notebook_get_tab_label | ( | GtkNotebook * | notebook, | |
GtkWidget * | child | |||
) |
Definition at line 74 of file notebook.c.
00075 { 00076 const gchar *buffer = NULL; 00077 GtkWidget *box = gtk_notebook_get_tab_label (notebook, child); 00078 GList *children = gtk_container_get_children (GTK_CONTAINER (box)); 00079 GList *iter = children; 00080 00081 if (iter) { 00082 do { 00083 if (GTK_IS_EVENT_BOX (iter->data)) { 00084 iter = gtk_container_get_children (GTK_CONTAINER (iter->data)); 00085 buffer = gtk_label_get_text (GTK_LABEL (iter->data)); 00086 g_list_free (iter); 00087 g_list_free (children); 00088 return buffer; 00089 } 00090 } while ((iter = g_list_next (iter)) != NULL); 00091 } 00092 00093 g_list_free (children); 00094 return NULL; 00095 }
void notebook_on_page_added | ( | GtkNotebook * | notebook, | |
GtkWidget * | child, | |||
guint | page_num, | |||
gpointer | user_data | |||
) |
Definition at line 197 of file notebook.c.
void notebook_on_page_removed | ( | GtkNotebook * | notebook, | |
GtkWidget * | child, | |||
guint | page_num, | |||
gpointer | user_data | |||
) |
Definition at line 208 of file notebook.c.
void notebook_on_page_switch | ( | GtkNotebook * | notebook, | |
GtkNotebookPage * | page, | |||
guint | page_num, | |||
gpointer | user_data | |||
) |
Definition at line 39 of file notebook.c.
00040 { 00041 synema_instance_t *inst = synema_instance (); 00042 GList *item = g_list_find_custom (inst->tables_list, 00043 gtk_notebook_get_nth_page (notebook, page_num), 00044 frame_table_cmp_func); 00045 if (item) { 00046 frame_table_hide_frames (inst->current_table); 00047 inst->current_table = item->data; 00048 frame_table_show_frames (inst->current_table); 00049 } 00050 }
void notebook_remove_all | ( | ) |
Definition at line 219 of file notebook.c.
00220 { 00221 synema_instance_t *inst = synema_instance (); 00222 00223 while (inst->tables_list) 00224 notebook_remove_page (NULL, inst->tables_list->data); 00225 }
void notebook_remove_page | ( | GtkToolButton * | donotuse, | |
gpointer | user_data | |||
) |
Definition at line 54 of file notebook.c.
00055 { 00056 // Beware, don't change the order of these declarations 00057 synema_instance_t *inst = synema_instance (); 00058 frame_table_t *tab = (frame_table_t *) user_data; 00059 GtkWidget *frame_box = (GtkWidget *) gtk_builder_get_object (inst->builder, "notebook"); 00060 gint index = gtk_notebook_page_num (GTK_NOTEBOOK (frame_box), tab->table_box); 00061 00062 if (tab == inst->current_table) 00063 notebook_on_page_switch (GTK_NOTEBOOK (frame_box), NULL, 0, NULL); 00064 00065 gtk_notebook_remove_page (GTK_NOTEBOOK (frame_box), index); 00066 inst->tables_list = g_list_remove (inst->tables_list, tab); 00067 if (!inst->tables_list) 00068 inst->current_table = NULL; 00069 frame_table_free (tab); 00070 }