Header for the tables containing frames. More...
#include <gtk/gtk.h>
#include "frame-common.h"
Go to the source code of this file.
Data Structures | |
struct | frame_table_t |
Data structure representing a table and the frames it contains. More... | |
Functions | |
gboolean | hidden_bar_add_frame (frame_table_t *, frame_t *) |
Adds a tool item to the hidden frames bar representing a frame. | |
gboolean | hidden_bar_remove_frame (frame_table_t *, frame_t *) |
Removes a given frame from the hidden frames bar. | |
gint | frame_table_list_cmp_by_position (gconstpointer, gconstpointer) |
Compares two frame tables' position. | |
void | frame_table_hide_frames (frame_table_t *) |
Hides the frames of a frame table. | |
void | frame_table_show_frames (frame_table_t *) |
Shows the frames of a frame table. | |
int | frame_table_add (frame_table_t *, frame_t *) |
Adds a frame to the frames list. | |
int | frame_table_add_with_coords (frame_table_t *, frame_t *, guint, guint) |
Adds a frame to the frames list with fixed coordinates. | |
int | frame_table_remove (frame_table_t *, frame_t *) |
Removes a frame from the frames list. | |
void | frame_list_free (GList *) |
Frees a list of frames and it's content. | |
void | frame_table_free (frame_table_t *) |
Frees a frame table, it's list of frames and it's internal data. | |
frame_table_t * | frame_table_new () |
Creates a frame table with an empty GtkTable. |
Header for the tables containing frames.
This header file describes the frame table and it's associated data, as well as table related functions.
Definition in file frame-table.h.
void frame_list_free | ( | GList * | list | ) |
Frees a list of frames and it's content.
This function frees all the frames in a list and frees the list too.
[out] | list | the pointer to the list |
Definition at line 198 of file frame-table.c.
int frame_table_add | ( | frame_table_t * | tab, | |
frame_t * | newelem | |||
) |
Adds a frame to the frames list.
This function adds a frame to a frames list, and puts it in the table linked to this list.
[in,out] | tab | the frame table struct containing the table and frames list |
[in] | newelem | a pointer to the new frame |
Definition at line 132 of file frame-table.c.
00133 { 00134 g_return_val_if_fail (tab != NULL, -1); 00135 g_return_val_if_fail (newelem != NULL, -2); 00136 00137 frame_set_id (newelem, tab->frames_list); 00138 tab->frames_list = g_list_prepend (tab->frames_list, newelem); 00139 newelem->parent = tab; 00140 00141 return table_add (tab, newelem); 00142 }
int frame_table_add_with_coords | ( | frame_table_t * | tab, | |
frame_t * | newelem, | |||
guint | left, | |||
guint | top | |||
) |
Adds a frame to the frames list with fixed coordinates.
This function adds a frame to a frames list, and puts it in the table linked to this list. It does not calculate the coordinates to use in the table but instead blindly uses the ones provided as parameters.
[in,out] | tab | the frame table struct containing the table and frames list |
[in] | newelem | a pointer to the new frame |
[in] | left | the left coordinate of the frame in the table |
[in] | top | the top coordinate of the frame in the table |
Definition at line 146 of file frame-table.c.
00147 { 00148 g_return_val_if_fail (tab != NULL, -1); 00149 g_return_val_if_fail (newelem != NULL, -2); 00150 00151 frame_set_id (newelem, tab->frames_list); 00152 tab->frames_list = g_list_prepend (tab->frames_list, newelem); 00153 newelem->parent = tab; 00154 00155 return table_add_with_coords (tab, newelem, left, top); 00156 }
void frame_table_free | ( | frame_table_t * | tab | ) |
Frees a frame table, it's list of frames and it's internal data.
This function frees a frame table and all the frames it contains.
[out] | tab | a pointer to the frame table |
Definition at line 209 of file frame-table.c.
00210 { 00211 g_free (tab->slot_data); 00212 frame_list_free (tab->frames_list); 00213 // The GtkWidgets have been freed when the main window was destroyed. 00214 g_free (tab); 00215 }
void frame_table_hide_frames | ( | frame_table_t * | tab | ) |
Hides the frames of a frame table.
This functions sets the hidden flag of frames associated to a frame table to TRUE.
[out] | tab | the frame table whose frames must be hidden |
Definition at line 118 of file frame-table.c.
gint frame_table_list_cmp_by_position | ( | gconstpointer | a, | |
gconstpointer | b | |||
) |
Compares two frame tables' position.
This function compares two frame tables. It returns the difference between their position in the notebook.
[in] | a | a pointer to the first table |
[in] | b | a pointer to the second table |
Definition at line 93 of file frame-table.c.
00094 { 00095 return ((frame_table_t *)a)->position - ((frame_table_t *)b)->position; 00096 }
frame_table_t* frame_table_new | ( | ) |
Creates a frame table with an empty GtkTable.
This function allocates the memory for a new frame_table_t that should be freed with frame_table_free, and initialises it's GtkTable and various private data structures.
Definition at line 219 of file frame-table.c.
00220 { 00221 frame_table_t *tab = g_malloc (sizeof (frame_table_t)); 00222 gint i; 00223 GtkToolItem *item = gtk_tool_item_new (); 00224 00225 tab->position = -1; 00226 00227 // Set the HBox containing the table and bar 00228 tab->table_box = gtk_hbox_new (FALSE, 0); 00229 00230 // Setup the table 00231 tab->table = gtk_table_new (1, 1, FALSE); 00232 gtk_table_set_row_spacings (GTK_TABLE (tab->table), 10); 00233 gtk_table_set_col_spacings (GTK_TABLE (tab->table), 10); 00234 gtk_table_set_homogeneous (GTK_TABLE (tab->table), TRUE); 00235 gtk_box_pack_start (GTK_BOX (tab->table_box), tab->table, TRUE, TRUE, 0); 00236 00237 // Set the hidden frames toolbar 00238 tab->hidden_bar = gtk_toolbar_new (); 00239 gtk_toolbar_set_orientation (GTK_TOOLBAR (tab->hidden_bar), GTK_ORIENTATION_VERTICAL); 00240 /* gtk_toolbar_set_icon_size (GTK_TOOLBAR (tab->hidden_bar), GTK_ICON_SIZE_SMALL_TOOLBAR);*/ 00241 gtk_tool_item_set_expand (item, TRUE); 00242 gtk_toolbar_insert (GTK_TOOLBAR (tab->hidden_bar), item, 0); 00243 gtk_box_pack_start (GTK_BOX (tab->table_box), tab->hidden_bar, FALSE, TRUE, 0); 00244 00245 for (i=0; i<LAST_SIZE_RATIO_T; i++) 00246 tab->children_size[i] = 0; 00247 00248 tab->slot_data = g_malloc (sizeof (frame_t*)); 00249 tab->slot_data[0] = NULL; 00250 00251 tab->frames_list = NULL; 00252 00253 return tab; 00254 }
int frame_table_remove | ( | frame_table_t * | tab, | |
frame_t * | elem | |||
) |
Removes a frame from the frames list.
This function removes a frame from the table given as a parameter, frees it and removes it from the list associated to this table.
[in,out] | tab | the frame table containing the frame |
[in] | elem | a pointer to the frame |
Definition at line 160 of file frame-table.c.
00161 { 00162 g_return_val_if_fail (tab != NULL, -1); 00163 g_return_val_if_fail (elem != NULL, -2); 00164 00165 GList *iter; 00166 00167 iter = g_list_find (tab->frames_list, elem); 00168 00169 if (iter) { 00170 int x = table_remove (tab, elem); 00171 elem->parent = NULL; 00172 frame_free (elem); 00173 tab->frames_list = g_list_remove (tab->frames_list, elem); 00174 return x; 00175 } else { 00176 return -1; 00177 } 00178 }
void frame_table_show_frames | ( | frame_table_t * | tab | ) |
Shows the frames of a frame table.
This functions sets the hidden flag of frames associated to a frame table to FALSE.
[out] | tab | the frame table whose frames must be shown |
Definition at line 125 of file frame-table.c.
gboolean hidden_bar_add_frame | ( | frame_table_t * | tab, | |
frame_t * | f | |||
) |
Adds a tool item to the hidden frames bar representing a frame.
This function, given a frame and a frame table, adds a visual representation of the frame in the frame table's hidden frames toolbar, which consists of a toolbutton with a tooltip.
[in,out] | tab | the frame table containing the hidden frames bar |
[in] | f | the frame to add to the bar |
Definition at line 33 of file frame-table.c.
00034 { 00035 g_return_val_if_fail (tab != NULL, FALSE); 00036 g_return_val_if_fail (f != NULL, FALSE); 00037 00038 const gchar *sizelabel = NULL; 00039 gchar *timelabel = NULL; 00040 gchar *tooltip = NULL; 00041 GtkToolItem *item = NULL; 00042 00043 item = gtk_tool_button_new (NULL, f->type); 00044 gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "synema-window"); 00045 gtk_toolbar_insert (GTK_TOOLBAR (tab->hidden_bar), item, -1); 00046 gtk_widget_show (GTK_WIDGET (item)); 00047 00048 switch (f->size) { 00049 case NORMAL: 00050 sizelabel = NORMAL_LABEL; 00051 break; 00052 case LARGE: 00053 sizelabel = LARGE_LABEL; 00054 break; 00055 case FULL: 00056 sizelabel = FULL_LABEL; 00057 break; 00058 default: 00059 sizelabel = NULL; 00060 } 00061 00062 timelabel = time_period_get_display_name (&f->display_period, TRUE); 00063 tooltip = g_strdup_printf ("<big>\t%s</big>\n\n<b>Machine:</b>\t\t %s\n<b>Time Period:</b>\t %s\n<b>Size:</b>\t\t\t %s", 00064 f->get_display_name (f), 00065 machine_get_display_name (f->display_machine), 00066 timelabel, 00067 sizelabel); 00068 gtk_tool_item_set_tooltip_markup (item, tooltip); 00069 g_free (tooltip); 00070 g_free (timelabel); 00071 00072 f->hidden_item = item; 00073 00074 return TRUE; 00075 }
gboolean hidden_bar_remove_frame | ( | frame_table_t * | tab, | |
frame_t * | f | |||
) |
Removes a given frame from the hidden frames bar.
This function, given a frame and a frame table, removes the frame's tool item from the hidden frames toolbar. provided the frame has such an item set.
[in,out] | tab | the frame table containing the hidden frames bar |
[in] | f | the frame to remove from the bar |
Definition at line 79 of file frame-table.c.
00080 { 00081 g_return_val_if_fail (tab != NULL, FALSE); 00082 g_return_val_if_fail (f != NULL, FALSE); 00083 g_return_val_if_fail (f->hidden_item != NULL, FALSE); 00084 00085 gtk_container_remove (GTK_CONTAINER (tab->hidden_bar), GTK_WIDGET (f->hidden_item)); 00086 f->hidden_item = NULL; 00087 00088 return TRUE; 00089 }