From 8af8e4c5fec518b63c7877b49b228acc2b947177 Mon Sep 17 00:00:00 2001 From: yangxx Date: Mon, 29 Sep 2003 20:27:47 +0000 Subject: [PATCH] git-svn-id: http://ltt.polymtl.ca/svn@280 04897980-b3bd-0310-b5e0-8ef037075253 --- .../poly/include/lttv/gtkcustomhbox.h | 75 ---- .../poly/lttv/modules/gui/API/Makefile.am | 3 +- .../poly/lttv/modules/gui/API/gtkcustomhbox.c | 346 ------------------ .../lttv/modules/gui/mainWin/src/Makefile.am | 3 +- .../lttv/modules/gui/mainWin/src/callbacks.c | 2 +- ltt/branches/poly/lttv/modules/guiEvents.c | 39 +- 6 files changed, 18 insertions(+), 450 deletions(-) delete mode 100644 ltt/branches/poly/include/lttv/gtkcustomhbox.h delete mode 100644 ltt/branches/poly/lttv/modules/gui/API/gtkcustomhbox.c diff --git a/ltt/branches/poly/include/lttv/gtkcustomhbox.h b/ltt/branches/poly/include/lttv/gtkcustomhbox.h deleted file mode 100644 index 17ff5213..00000000 --- a/ltt/branches/poly/include/lttv/gtkcustomhbox.h +++ /dev/null @@ -1,75 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_CUSTOM_HBOX_H__ -#define __GTK_CUSTOM_HBOX_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GTK_TYPE_CUSTOM_HBOX (gtk_custom_hbox_get_type ()) -#define GTK_CUSTOM_HBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CUSTOM_HBOX, GtkCustomHBox)) -#define GTK_CUSTOM_HBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CUSTOM_HBOX, GtkCustomHBoxClass)) -#define GTK_IS_CUSTOM_HBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CUSTOM_HBOX)) -#define GTK_IS_CUSTOM_HBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CUSTOM_HBOX)) -#define GTK_CUSTOM_HBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CUSTOM_HBOX, GtkCustomHBoxClass)) - - -typedef struct _GtkCustomHBox GtkCustomHBox; -typedef struct _GtkCustomHBoxClass GtkCustomHBoxClass; - -typedef void (*remove_func)(GtkCustomHBox * hbox); - -struct _GtkCustomHBox -{ - GtkBox box; - remove_func remove_item; -}; - -struct _GtkCustomHBoxClass -{ - GtkBoxClass parent_class; -}; - - -GType gtk_custom_hbox_get_type (void) G_GNUC_CONST; -GtkWidget* gtk_custom_hbox_new (gboolean homogeneous, - gint spacing, - remove_func remove); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GTK_CUSTOM_HBOX_H__ */ diff --git a/ltt/branches/poly/lttv/modules/gui/API/Makefile.am b/ltt/branches/poly/lttv/modules/gui/API/Makefile.am index a4b646ae..e4c77884 100644 --- a/ltt/branches/poly/lttv/modules/gui/API/Makefile.am +++ b/ltt/branches/poly/lttv/modules/gui/API/Makefile.am @@ -11,8 +11,7 @@ AM_CFLAGS += $(GTK_CFLAGS) LIBS += $(GLIB_LIBS) LIBS += $(GTK_LIBS) -lib_LTLIBRARIES = libcustomBox.la libmainWinApi.la -libcustomBox_la_SOURCES = gtkcustomhbox.c +lib_LTLIBRARIES = libmainWinApi.la libmainWinApi_la_SOURCES = toolbar.c menu.c gtkTraceSet.c #libmainWinApi_la_LDFLAGS = -L${top_srcdir}/lttv/modules/gui/API -lcustomBox diff --git a/ltt/branches/poly/lttv/modules/gui/API/gtkcustomhbox.c b/ltt/branches/poly/lttv/modules/gui/API/gtkcustomhbox.c deleted file mode 100644 index 9f6ea9ef..00000000 --- a/ltt/branches/poly/lttv/modules/gui/API/gtkcustomhbox.c +++ /dev/null @@ -1,346 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include - - -static void gtk_custom_hbox_class_init (GtkCustomHBoxClass *klass); -static void gtk_custom_hbox_init (GtkCustomHBox *box); -static void gtk_custom_hbox_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_custom_hbox_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); - - -GType -gtk_custom_hbox_get_type (void) -{ - static GType hbox_type = 0; - - if (!hbox_type) - { - static const GTypeInfo hbox_info = - { - sizeof (GtkCustomHBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_custom_hbox_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCustomHBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_custom_hbox_init, - }; - - hbox_type = g_type_register_static (GTK_TYPE_BOX, "GtkCustomHBox", - &hbox_info, 0); - } - - return hbox_type; -} - -static void -gtk_custom_hbox_finalize (GObject *object) -{ - GtkCustomHBox * hbox = GTK_CUSTOM_HBOX (object); - - hbox->remove_item(hbox); - - G_OBJECT_CLASS(g_type_class_peek_parent(GTK_CUSTOM_HBOX_GET_CLASS(hbox)))->finalize(G_OBJECT(object)); -} - -static void -gtk_custom_hbox_class_init (GtkCustomHBoxClass *class) -{ - GtkWidgetClass *widget_class; - GObjectClass *gobject_class = G_OBJECT_CLASS(class); - - gobject_class->finalize = gtk_custom_hbox_finalize; - - widget_class = (GtkWidgetClass*) class; - - widget_class->size_request = gtk_custom_hbox_size_request; - widget_class->size_allocate = gtk_custom_hbox_size_allocate; -} - -static void -gtk_custom_hbox_init (GtkCustomHBox *hbox) -{ -} - -GtkWidget* -gtk_custom_hbox_new (gboolean homogeneous, - gint spacing, - remove_func remove) -{ - GtkCustomHBox *hbox; - - hbox = g_object_new (GTK_TYPE_CUSTOM_HBOX, NULL); - hbox->remove_item = remove; - - GTK_BOX (hbox)->spacing = spacing; - GTK_BOX (hbox)->homogeneous = homogeneous ? TRUE : FALSE; - - return GTK_WIDGET (hbox); -} - -static void -gtk_custom_hbox_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBox *box; - GtkBoxChild *child; - GList *children; - gint nvis_children; - gint width; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if (GTK_WIDGET_VISIBLE (child->widget)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (child->widget, &child_requisition); - - if (box->homogeneous) - { - width = child_requisition.width + child->padding * 2; - requisition->width = MAX (requisition->width, width); - } - else - { - requisition->width += child_requisition.width + child->padding * 2; - } - - requisition->height = MAX (requisition->height, child_requisition.height); - - nvis_children += 1; - } - } - - if (nvis_children > 0) - { - if (box->homogeneous) - requisition->width *= nvis_children; - requisition->width += (nvis_children - 1) * box->spacing; - } - - requisition->width += GTK_CONTAINER (box)->border_width * 2; - requisition->height += GTK_CONTAINER (box)->border_width * 2; -} - -static void -gtk_custom_hbox_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBox *box; - GtkBoxChild *child; - GList *children; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_width; - gint width; - gint extra; - gint x; - GtkTextDirection direction; - - box = GTK_BOX (widget); - widget->allocation = *allocation; - - direction = gtk_widget_get_direction (widget); - - nvis_children = 0; - nexpand_children = 0; - children = box->children; - - while (children) - { - child = children->data; - children = children->next; - - if (GTK_WIDGET_VISIBLE (child->widget)) - { - nvis_children += 1; - if (child->expand) - nexpand_children += 1; - } - } - - if (nvis_children > 0) - { - if (box->homogeneous) - { - width = (allocation->width - - GTK_CONTAINER (box)->border_width * 2 - - (nvis_children - 1) * box->spacing); - extra = width / nvis_children; - } - else if (nexpand_children > 0) - { - width = (gint) allocation->width - (gint) widget->requisition.width; - extra = width / nexpand_children; - } - else - { - width = 0; - extra = 0; - } - - x = allocation->x + GTK_CONTAINER (box)->border_width; - child_allocation.y = allocation->y + GTK_CONTAINER (box)->border_width; - child_allocation.height = MAX (1, (gint) allocation->height - (gint) GTK_CONTAINER (box)->border_width * 2); - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && GTK_WIDGET_VISIBLE (child->widget)) - { - if (box->homogeneous) - { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; - - nvis_children -= 1; - width -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - child_width = child_requisition.width + child->padding * 2; - - if (child->expand) - { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; - - nexpand_children -= 1; - width -= extra; - } - } - - if (child->fill) - { - child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); - child_allocation.x = x + child->padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2; - } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - - gtk_widget_size_allocate (child->widget, &child_allocation); - - x += child_width + box->spacing; - } - } - - x = allocation->x + allocation->width - GTK_CONTAINER (box)->border_width; - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && GTK_WIDGET_VISIBLE (child->widget)) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - if (box->homogeneous) - { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; - - nvis_children -= 1; - width -= extra; - } - else - { - child_width = child_requisition.width + child->padding * 2; - - if (child->expand) - { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; - - nexpand_children -= 1; - width -= extra; - } - } - - if (child->fill) - { - child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); - child_allocation.x = x + child->padding - child_width; - } - else - { - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; - } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - - gtk_widget_size_allocate (child->widget, &child_allocation); - - x -= (child_width + box->spacing); - } - } - } -} diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/Makefile.am b/ltt/branches/poly/lttv/modules/gui/mainWin/src/Makefile.am index 0fb734e1..7880689d 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/Makefile.am +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/Makefile.am @@ -3,8 +3,7 @@ AM_CFLAGS = $(GLIB_CFLAGS) AM_CFLAGS += $(GTK_CFLAGS) LIBS += $(GLIB_LIBS) -LIBS += $(GTK_LIBS) -L$(top_srcdir)/lttv/modules/gui/API -lmainWinApi\ - -lcustomBox +LIBS += $(GTK_LIBS) -L$(top_srcdir)/lttv/modules/gui/API -lmainWinApi INCLUDES = \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c index b897b609..1c184ab0 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c @@ -97,7 +97,7 @@ void insertView(GtkWidget* widget, view_constructor constructor) { gtk_custom_widget_add(custom, viewer); // Added by MD - g_object_unref(G_OBJECT(viewer)); + // g_object_unref(G_OBJECT(viewer)); } } diff --git a/ltt/branches/poly/lttv/modules/guiEvents.c b/ltt/branches/poly/lttv/modules/guiEvents.c index a5677aa5..0d3b9bc9 100644 --- a/ltt/branches/poly/lttv/modules/guiEvents.c +++ b/ltt/branches/poly/lttv/modules/guiEvents.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -60,7 +59,6 @@ gboolean updateTimeInterval(void * hook_data, void * call_data); gboolean updateCurrentTime(void * hook_data, void * call_data); void remove_item_from_queue(GQueue * q, gboolean fromHead); void remove_all_items_from_queue(GQueue * q); -void remove_instance(GtkCustomHBox * box); typedef struct _RawTraceData{ unsigned cpu_id; @@ -100,7 +98,6 @@ typedef struct _EventViewerData { LttTime trace_end; unsigned start_event_index; //the first event shown in the window unsigned end_event_index; //the last event shown in the window - GtkWidget * instance_container; //box to contain all widgets //scroll window containing Tree View GtkWidget * Scroll_Win; @@ -137,6 +134,7 @@ GtkWidget *hGuiEvents(mainWindow *pmParentWindow); EventViewerData *GuiEvents(mainWindow *pmParentWindow); //! Event Viewer's destructor void GuiEvents_Destructor(EventViewerData *Event_Viewer_Data); +void GuiEvents_free(EventViewerData *Event_Viewer_Data); static int Event_Selected_Hook(void *hook_data, void *call_data); @@ -247,7 +245,7 @@ hGuiEvents(mainWindow * pmParentWindow) EventViewerData* Event_Viewer_Data = GuiEvents(pmParentWindow) ; if(Event_Viewer_Data) - return Event_Viewer_Data->instance_container; + return Event_Viewer_Data->HBox_V; else return NULL; } @@ -397,10 +395,8 @@ GuiEvents(mainWindow *pmParentWindow) gtk_container_add (GTK_CONTAINER (Event_Viewer_Data->Scroll_Win), Event_Viewer_Data->Tree_V); - Event_Viewer_Data->instance_container = gtk_custom_hbox_new(0, 0, remove_instance); Event_Viewer_Data->HBox_V = gtk_hbox_new(0, 0); gtk_box_pack_start(GTK_BOX(Event_Viewer_Data->HBox_V), Event_Viewer_Data->Scroll_Win, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(Event_Viewer_Data->instance_container), Event_Viewer_Data->HBox_V, TRUE, TRUE, 0); /* Create vertical scrollbar and pack it */ Event_Viewer_Data->VScroll_VC = gtk_vscrollbar_new(NULL); @@ -426,7 +422,6 @@ GuiEvents(mainWindow *pmParentWindow) // Event_Viewer_Data->VTree_Adjust_C->upper; g_critical("value : %u",Event_Viewer_Data->VTree_Adjust_C->upper); /* Raw event trace */ - gtk_widget_show(Event_Viewer_Data->instance_container); gtk_widget_show(Event_Viewer_Data->HBox_V); gtk_widget_show(Event_Viewer_Data->Tree_V); gtk_widget_show(Event_Viewer_Data->VScroll_VC); @@ -466,6 +461,13 @@ GuiEvents(mainWindow *pmParentWindow) /* Set the Selected Event */ // Tree_V_set_cursor(Event_Viewer_Data); + + + g_object_set_data_full( + G_OBJECT(Event_Viewer_Data->HBox_V), + "Event_Viewer_Data", + Event_Viewer_Data, + (GDestroyNotify)GuiEvents_free); return Event_Viewer_Data; } @@ -1135,6 +1137,8 @@ GuiEvents_free(EventViewerData *Event_Viewer_Data) UnregUpdateTimeInterval(updateTimeInterval,Event_Viewer_Data, Event_Viewer_Data->mw); UnregUpdateCurrentTime(updateCurrentTime,Event_Viewer_Data, Event_Viewer_Data->mw); + sEvent_Viewer_Data_List = g_slist_remove(sEvent_Viewer_Data_List, Event_Viewer_Data); + g_warning("Delete Event data\n"); g_free(Event_Viewer_Data); } @@ -1144,8 +1148,8 @@ GuiEvents_Destructor(EventViewerData *Event_Viewer_Data) guint index; /* May already been done by GTK window closing */ - if(GTK_IS_WIDGET(Event_Viewer_Data->instance_container)) - gtk_widget_destroy(Event_Viewer_Data->instance_container); + if(GTK_IS_WIDGET(Event_Viewer_Data->HBox_V)) + gtk_widget_destroy(Event_Viewer_Data->HBox_V); /* Destroy the Tree View */ //gtk_widget_destroy(Event_Viewer_Data->Tree_V); @@ -1154,6 +1158,7 @@ GuiEvents_Destructor(EventViewerData *Event_Viewer_Data) //gtk_list_store_clear(Event_Viewer_Data->Store_M); //gtk_widget_destroy(GTK_WIDGET(Event_Viewer_Data->Store_M)); + g_warning("Delete Event data from destroy\n"); GuiEvents_free(Event_Viewer_Data); } @@ -1234,7 +1239,7 @@ gboolean updateCurrentTime(void * hook_data, void * call_data) void Tree_V_grab_focus(GtkWidget *widget, gpointer data){ EventViewerData *Event_Viewer_Data = (EventViewerData *)data; mainWindow * mw = Event_Viewer_Data->mw; - SetFocusedPane(mw, gtk_widget_get_parent(Event_Viewer_Data->instance_container)); + SetFocusedPane(mw, gtk_widget_get_parent(Event_Viewer_Data->HBox_V)); } void get_events(EventViewerData* Event_Viewer_Data, LttTime start, @@ -1499,20 +1504,6 @@ void remove_all_items_from_queue(GQueue *q) } } -void remove_instance(GtkCustomHBox * box){ - int i; - EventViewerData *Event_Viewer_Data ; - - for(i=0;iinstance_container){ - sEvent_Viewer_Data_List = g_slist_remove(sEvent_Viewer_Data_List, Event_Viewer_Data); - GuiEvents_free(Event_Viewer_Data); - break; - } - } -} - -- 2.34.1