str1++;
}
lttv_module_require(str1, NULL);
- g_slist_foreach(g_main_window_list, (gpointer)update_menu_toolbar_constructors,
- NULL);
g_strfreev(dir);
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_CANCEL:
lttv_library_info(library, &library_info);
if(strcmp(unload_module_name, library_info.name) == 0){
lttv_library_unload(library);
- g_slist_foreach(g_main_window_list,
- (gpointer)update_menu_toolbar_constructors,
- NULL);
break;
}
}
}
-/* Insert or remove all menu entry and tool buttons into all main windows
+/* Insert or remove all menu entry and tool buttons into this main window
* for modules.
*
- * It adds them in a hash table as well, so it can keep track of which
- * menu entries and buttons are currently in each main window, for later
- * removal.
*/
-void update_menu_toolbar_constructors(MainWindow * mw, gpointer user_data)
+void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data)
{
int i;
GdkPixbuf *pixbuf;
lttvwindow_viewer_constructor constructor;
LttvMenus * global_menu, * instance_menu;
LttvToolbars * global_toolbar, * instance_toolbar;
- LttvMenuClosure *menu_item_i, *menu_item_j;
- LttvToolbarClosure *toolbar_item_i, *toolbar_item_j;
+ LttvMenuClosure *menu_item;
+ LttvToolbarClosure *toolbar_item;
LttvAttributeValue value;
LttvIAttribute *global_attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
/* Add missing menu entries to window instance */
for(i=0;i<global_menu->len;i++) {
- menu_item_i = &g_array_index(global_menu, LttvMenuClosure, i);
+ menu_item = &g_array_index(global_menu, LttvMenuClosure, i);
+
+ //add menu_item to window instance;
+ constructor = menu_item->con;
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+ new_widget =
+ gtk_menu_item_new_with_mnemonic (menu_item->menuText);
+ gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
+ new_widget);
+ g_signal_connect ((gpointer) new_widget, "activate",
+ G_CALLBACK (insert_viewer_wrap),
+ constructor);
+ gtk_widget_show (new_widget);
+ lttv_menus_add(instance_menu, menu_item->con,
+ menu_item->menu_path,
+ menu_item->menu_text,
+ new_widget);
- for(j=0;j<instance_menu->len;j++) {
- menu_item_j = &g_array_index(instance_menu, LttvMenuClosure, j);
-
- if(menu_item_i->con == menu_item_j->con)
- break;
- }
- if(j == instance_menu->len) /* not found */
- {
- //add menu_item_i to window instance;
- constructor = menu_item->con;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
- new_widget =
- gtk_menu_item_new_with_mnemonic (menu_item_i->menuText);
- gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
- new_widget);
- g_signal_connect ((gpointer) new_widget, "activate",
- G_CALLBACK (insert_viewer_wrap),
- constructor);
- gtk_widget_show (new_widget);
- lttv_menus_add(instance_menu, menu_item_i->con,
- menu_item_i->menu_path,
- menu_item_i->menu_text,
- new_widget);
- }
-
- }
-
- /* Remove missing menu entries from window instance */
- for(i=0;i<instance_menu->len;i++) {
- menu_item_i = &g_array_index(instance_menu, LttvMenuClosure, i);
-
- for(j=0;j<global_menu->len;j++) {
- menu_item_j = &g_array_index(global_menu, LttvMenuClosure, j);
-
- if(menu_item_i->con == menu_item_j->con)
- break;
- }
- if(j == global_menu->len) /* not found */
- {
- //remove menu_item_i from window instance;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
- gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu),
- menu_item_i->widget);
- lttv_menus_remove(instance_menu, menu_item_i->con);
- }
}
/* Add missing toolbar entries to window instance */
for(i=0;i<global_toolbar->len;i++) {
- toolbar_item_i = &g_array_index(global_toolbar, LttvToolbarClosure, i);
-
- for(j=0;j<instance_toolbar->len;j++) {
- toolbar_item_j = &g_array_index(instance_toolbar, LttvToolbarClosure, j);
-
- if(toolbar_item_i->con == toolbar_item_j->con)
- break;
- }
- if(j == instance_toolbar->len) /* not found */
- {
- //add toolbar_item_i to window instance;
- constructor = toolbar_item->con;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
- pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_item->pixmap);
- pixmap = gtk_image_new_from_pixbuf(pixbuf);
- new_widget =
- gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
- GTK_TOOLBAR_CHILD_BUTTON,
- NULL,
- "",
- toolbar_item->tooltip, NULL,
- pixmap, NULL, NULL);
- gtk_label_set_use_underline(
- GTK_LABEL (((GtkToolbarChild*) (
- g_list_last (GTK_TOOLBAR
- (tool_menu_title_menu)->children)->data))->label),
- TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
- g_signal_connect ((gpointer) new_widget,
- "clicked",
- G_CALLBACK (insert_viewer_wrap),
- constructor);
- gtk_widget_show (new_widget);
-
- lttv_toolbars_add(instance_toolbar, toolbar_item_i->con,
- toolbar_item_i->tooltip,
- toolbar_item_i->pixmap,
- new_widget);
+ toolbar_item = &g_array_index(global_toolbar, LttvToolbarClosure, i);
+
+ //add toolbar_item to window instance;
+ constructor = toolbar_item->con;
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_item->pixmap);
+ pixmap = gtk_image_new_from_pixbuf(pixbuf);
+ new_widget =
+ gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
+ GTK_TOOLBAR_CHILD_BUTTON,
+ NULL,
+ "",
+ toolbar_item->tooltip, NULL,
+ pixmap, NULL, NULL);
+ gtk_label_set_use_underline(
+ GTK_LABEL (((GtkToolbarChild*) (
+ g_list_last (GTK_TOOLBAR
+ (tool_menu_title_menu)->children)->data))->label),
+ TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
+ g_signal_connect ((gpointer) new_widget,
+ "clicked",
+ G_CALLBACK (insert_viewer_wrap),
+ constructor);
+ gtk_widget_show (new_widget);
- }
- }
+ lttv_toolbars_add(instance_toolbar, toolbar_item->con,
+ toolbar_item->tooltip,
+ toolbar_item->pixmap,
+ new_widget);
- /* Remove missing toolbar entries from window instance */
- for(i=0;i<instance_toolbar->len;i++) {
- toolbar_item_i = &g_array_index(instance_toolbar, LttvToolbarClosure, i);
-
- for(j=0;j<global_toolbar->len;j++) {
- toolbar_item_j = &g_array_index(global_toolbar, LttvToolbarClosure, j);
-
- if(toolbar_item_i->con == toolbar_item_j->con)
- break;
- }
- if(j == global_toolbar->len) /* not found */
- {
- //remove toolbar_item_i from window instance;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
- gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu),
- toolbar_item_i->widget);
- lttv_toolbars_remove(instance_toolbar, toolbar_item_i->con);
- }
}
+
}
"viewers/toolbar", LTTV_POINTER, &value));
(LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new();
- update_menu_toolbar_constructors(new_m_window, NULL);
+ add_all_menu_toolbar_constructors(new_m_window, NULL);
g_object_set_data(G_OBJECT(new_window), "mainWindow", (gpointer)new_m_window);
//create a default tab
g_array_free(h, TRUE);
}
-inline void lttv_menus_add(LttvMenus *h, lttvwindow_viewer_constructor f, char* menuPath, char* menuText, GtkWidget *widget)
+inline LttvMenuClosure lttv_menus_add(LttvMenus *h, lttvwindow_viewer_constructor f, char* menuPath, char* menuText, GtkWidget *widget)
{
LttvMenuClosure c;
c.menuText = menuText;
c.widget = widget;
g_array_append_val(h,c);
+
+ return c;
}
-gboolean lttv_menus_remove(LttvMenus *h, lttvwindow_viewer_constructor f)
+GtkWidget *lttv_menus_remove(LttvMenus *h, lttvwindow_viewer_constructor f)
{
LttvMenuClosure * tmp;
gint i;
+ GtkWidget *widget;
+
for(i=0;i<h->len;i++){
tmp = & g_array_index(h, LttvMenuClosure, i);
- if(tmp->con == f)break;
+ if(tmp->con == f) {
+ widget = tmp->widget;
+ break;
+ }
}
if(i<h->len){
g_array_remove_index(h, i);
- return TRUE;
- }else return FALSE;
+ return widget;
+ }else return NULL;
}
void lttv_menus_destroy(LttvMenus *h);
-void lttv_menus_add(LttvMenus *h, lttvwindow_viewer_constructor f, char* menuPath, char * menuText, GtkWidget *widget);
+LttvMenuClosure lttv_menus_add(LttvMenus *h, lttvwindow_viewer_constructor f, char* menuPath, char * menuText, GtkWidget *widget);
-gboolean lttv_menus_remove(LttvMenus *h, lttvwindow_viewer_constructor f);
+GtkWidget *lttv_menus_remove(LttvMenus *h, lttvwindow_viewer_constructor f);
unsigned lttv_menus_number(LttvMenus *h);
g_array_free(h, TRUE);
}
-inline void lttv_toolbars_add(LttvToolbars *h, lttvwindow_viewer_constructor f, char* tooltip, char ** pixmap, GtkWidget *widget)
+inline LttvToolbarClosure void lttv_toolbars_add(LttvToolbars *h, lttvwindow_viewer_constructor f, char* tooltip, char ** pixmap, GtkWidget *widget)
{
LttvToolbarClosure c;
c.pixmap = pixmap;
c.widget = widget;
g_array_append_val(h,c);
+
+ return c;
}
-gboolean lttv_toolbars_remove(LttvToolbars *h, lttvwindow_viewer_constructor f)
+GtkWidget *lttv_toolbars_remove(LttvToolbars *h, lttvwindow_viewer_constructor f)
{
LttvToolbarClosure * tmp;
gint i;
+ GtkWidget *widget;
+
for(i=0;i<h->len;i++){
tmp = & g_array_index(h, LttvToolbarClosure, i);
- if(tmp->con == f)break;
+ if(tmp->con == f) {
+ widget = tmp->widget;
+ break;
+ }
}
if(i<h->len){
g_array_remove_index(h, i);
- return TRUE;
- }else return FALSE;
+ return widget;
+ }else return NULL;
}
unsigned lttv_toolbars_number(LttvToolbars *h)
void lttv_toolbars_destroy(LttvToolbars *h);
-void lttv_toolbars_add(LttvToolbars *h,
+LttvToolbarClosure lttv_toolbars_add(LttvToolbars *h,
lttvwindow_viewer_constructor f,
char* tooltip,
char ** pixmap,
GtkWidget *widget);
-gboolean lttv_toolbars_remove(LttvToolbars *h, lttvwindow_viewer_constructor f);
+GtkWidget *lttv_toolbars_remove(LttvToolbars *h, lttvwindow_viewer_constructor f);
unsigned lttv_toolbars_number(LttvToolbars *h);
}
+void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvToolbars * instance_toolbar;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *new_widget, *pixmap;
+ GdkPixbuf *pixbuf;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/toolbar", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new();
+ instance_toolbar = (LttvToolbars*)*(value.v_pointer);
+
+ constructor = toolbar_c->con;
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap);
+ pixmap = gtk_image_new_from_pixbuf(pixbuf);
+ new_widget =
+ gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
+ GTK_TOOLBAR_CHILD_BUTTON,
+ NULL,
+ "",
+ toolbar_item->tooltip, NULL,
+ pixmap, NULL, NULL);
+ gtk_label_set_use_underline(
+ GTK_LABEL (((GtkToolbarChild*) (
+ g_list_last (GTK_TOOLBAR
+ (tool_menu_title_menu)->children)->data))->label),
+ TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
+ g_signal_connect ((gpointer) new_widget,
+ "clicked",
+ G_CALLBACK (insert_viewer_wrap),
+ constructor);
+ gtk_widget_show (new_widget);
+
+ lttv_toolbars_add(instance_toolbar, toolbar_item_i->con,
+ toolbar_item_i->tooltip,
+ toolbar_item_i->pixmap,
+ new_widget);
+
+}
+
+void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvToolbars * instance_menu;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *new_widget;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/menu", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvMenus*)*(value.v_pointer) = lttv_menus_new();
+ instance_menu = (LttvMenus*)*(value.v_pointer);
+
+
+ constructor = menu_item->con;
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+ new_widget =
+ gtk_menu_item_new_with_mnemonic (menu_c->menuText);
+ gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
+ new_widget);
+ g_signal_connect ((gpointer) new_widget, "activate",
+ G_CALLBACK (insert_viewer_wrap),
+ constructor);
+ gtk_widget_show (new_widget);
+ lttv_menus_add(instance_menu, menu_c->con,
+ menu_c->menu_path,
+ menu_c->menu_text,
+ new_widget);
+}
+
+void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvToolbars * instance_toolbar;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *widget;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/toolbar", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new();
+ instance_toolbar = (LttvToolbars*)*(value.v_pointer);
+
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
+ widget = lttv_menus_remove(instance_toolbar, viewer_constructor);
+ gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu),
+ widget);
+}
+
+
+void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvMenus * instance_menu;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *widget;
+ LttvMenuClosure *menu_item_i;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/menu", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvMenus*)*(value.v_pointer) = lttv_menus_new();
+ instance_menu = (LttvMenus*)*(value.v_pointer);
+
+ widget = lttv_menus_remove(instance_menu, viewer_constructor);
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+ gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget);
+}
+
+
/**
* API parts
*/
LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
LttvToolbars * toolbar;
LttvMenus * menu;
+ LttvToolbarClosure toolbar_c;
+ LttvMenuClosure menu_c;
LttvAttributeValue value;
if(pixmap != NULL) {
toolbar = lttv_toolbars_new();
*(value.v_pointer) = toolbar;
}
- lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
- main_window_add_toolbars_item(toolbar, view_constructor, tooltip, pixmap);
+ toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
+
+ g_slist_foreach(g_main_window_list,
+ (gpointer)add_toolbar_constructor,
+ &toolbar_c);
}
if(menu_path != NULL) {
menu = lttv_menus_new();
*(value.v_pointer) = menu;
}
- lttv_menus_add(menu, view_constructor, menu_path, menu_text);
- main_window_add_menu_item(menu, view_constructor, menu_path, menu_text);
+ menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text);
+
+ g_slist_foreach(g_main_window_list,
+ (gpointer)add_menu_constructor,
+ &menu_c);
}
}
toolbar = (LttvToolbars*)*(value.v_pointer);
if(toolbar != NULL) {
- main_window_remove_toolbar_item(view_constructor);
+ g_slist_foreach(g_main_window_list,
+ (gpointer)remove_toolbar_constructor,
+ view_constructor);
lttv_toolbars_remove(toolbar, view_constructor);
}
menu = (LttvMenus*)*(value.v_pointer);
if(menu != NULL) {
- main_window_remove_menu_item(view_constructor);
+ g_slist_foreach(g_main_window_list,
+ (gpointer)remove_menu_constructor,
+ view_constructor);
lttv_menus_remove(menu, view_constructor);
}
-
-
}