dia r4091 - in trunk: . app lib objects/UML
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4091 - in trunk: . app lib objects/UML
- Date: Fri, 18 Jul 2008 22:00:56 +0000 (UTC)
Author: hans
Date: Fri Jul 18 22:00:55 2008
New Revision: 4091
URL: http://svn.gnome.org/viewvc/dia?rev=4091&view=rev
Log:
2008-07-18 Hans Breuer <hans breuer org>
[ on the way to compile dia with GTK_DISABLE_DEPRECATED ]
* app/makefile.msc lib/makefile.msc : -DGTK_DISABLE_DEPRECATED
* app/app_procs.c : s/gtk_timeout_add/g_timeout_add/
* app/autosave.c : g(tk)_idle_remove_by_data ()
* app/color_area.c : remove gtk_color_selection_set_update_policy () -
it does not have any effect anymore
* app/defaults.c : use g_object_ref_sink()
* app/diagram_tree.c app/diagram_tree_menu.c :
#undef GTK_DISABLE_DEPRECATED for GtkCList
* app/diapagelayout.[ch] : information hiding to not pollute all users
with deprecated stuff
* app/disp_callbacks.c : remove gtk_menu_item_set_show_toggle (), it's
deprecated and doesn't have any effect anymore, use g_signal_connect ()
* app/display.c : replace gtk_idle_*() and gtk_object_get_user_data ()
* app/dynamic_refresh.c : port away from gtk_timeout_*()
* app/filedlg.c : not gtk_object_get_user_data () anymore
* app/gtkhwrapbox.[ch] app/gtkvwrapbox.[ch] app/gtkwrapbox.[ch] :
copied already ported version from The GIMP
* app/interface.c : away from gtk_object_get_user_data ()
* app/interface.h app/sheets.h : #ifdefed GtkTooltips
* app/layer_dialog.[ch] : information hiding of deprecated stuff
* app/linewidth_area.c app/navigation.c :
s/gtk_drawing_area_size/gtk_widget_set_size_request/
* app/menus.c : #undef GTK_DISABLE_DEPRECATED for GtkTooltips
* app/pagesetup.c : replace gtk_object_set_data_full () and adapt to
DiaPageLayout information hiding
* app/preferences.c : GtkComboBox instead of GtkOptionMenu
* app/properties.c : g_object_ref_sink ()
[ #undef GTK_DISABLE_DEPRECATED ...]
* app/splash.c : ... for GtkPixmap
* lib/diaarrowchooser.[ch] : ... for GtkTooltips
* app/sheets.c app/sheets_dialog.c app/sheets_dialog_callbacks.c : ...
for GtkOptionMenu and GtkTooltips
* lib/dialinechooser.c : use g_object_ref_sink()
* lib/dialogs.c : replace gtk_box_pack_start_defaults()
* lib/messages.c : removed #undef GTK_DISABLE_DEPRECATED
* lib/prop_inttypes.c : use gtk_combo_box_new_text () instead of
deprecated gtk_option_menu_new(), also g_signal_*()
* lib/prop_sdarray.c : use g_signal_connect()
* lib/propdialogs.c : g_object_set_data (), g_signal_connect ()
* lib/widgets.[ch] : moved struct _DiaDynamicMenu to implemention
to hide _deprecated_ internals (GtkOptionMenu
* objects/UML/class_dialog.c(umlclass_update_connectionpoints) : dont
crash when called without having used the properties dialog before
Modified:
trunk/ChangeLog
trunk/app/app_procs.c
trunk/app/autosave.c
trunk/app/color_area.c
trunk/app/defaults.c
trunk/app/diagram_tree.c
trunk/app/diagram_tree_menu.c
trunk/app/diapagelayout.c
trunk/app/diapagelayout.h
trunk/app/disp_callbacks.c
trunk/app/display.c
trunk/app/dynamic_refresh.c
trunk/app/filedlg.c
trunk/app/gtkhwrapbox.c
trunk/app/gtkhwrapbox.h
trunk/app/gtkvwrapbox.c
trunk/app/gtkvwrapbox.h
trunk/app/gtkwrapbox.c
trunk/app/gtkwrapbox.h
trunk/app/interface.c
trunk/app/interface.h
trunk/app/layer_dialog.c
trunk/app/layer_dialog.h
trunk/app/linewidth_area.c
trunk/app/makefile.msc
trunk/app/menus.c
trunk/app/navigation.c
trunk/app/pagesetup.c
trunk/app/preferences.c
trunk/app/properties.c
trunk/app/sheets.c
trunk/app/sheets.h
trunk/app/sheets_dialog.c
trunk/app/sheets_dialog_callbacks.c
trunk/app/splash.c
trunk/lib/diaarrowchooser.c
trunk/lib/diaarrowchooser.h
trunk/lib/dialinechooser.c
trunk/lib/dialogs.c
trunk/lib/makefile.msc
trunk/lib/message.c
trunk/lib/prop_inttypes.c
trunk/lib/prop_sdarray.c
trunk/lib/propdialogs.c
trunk/lib/widgets.c
trunk/lib/widgets.h
trunk/objects/UML/class_dialog.c
Modified: trunk/app/app_procs.c
==============================================================================
--- trunk/app/app_procs.c (original)
+++ trunk/app/app_procs.c Fri Jul 18 22:00:55 2008
@@ -812,7 +812,7 @@
recent_file_history_init();
/* Set up autosave to check every 5 minutes */
- gtk_timeout_add(5*60*1000, autosave_check_autosave, NULL);
+ g_timeout_add(5*60*1000, autosave_check_autosave, NULL);
/* Create Diagram Tree Window */
create_tree_window();
Modified: trunk/app/autosave.c
==============================================================================
--- trunk/app/autosave.c (original)
+++ trunk/app/autosave.c Fri Jul 18 22:00:55 2008
@@ -50,7 +50,7 @@
{
Diagram *dia = (Diagram *)data;
- gtk_idle_remove_by_data(data);
+ g_idle_remove_by_data(data);
diagram_autosave(dia);
}
@@ -71,7 +71,7 @@
if (diagram_is_modified(diagram) &&
!diagram->autosaved) {
/* Diagram has been modified. At next idleness, save it */
- gtk_idle_add((GtkFunction)autosave_save_diagram, diagram);
+ g_idle_add (G_CALLBACK (autosave_save_diagram), diagram);
}
diagrams = g_list_next(diagrams);
}
Modified: trunk/app/color_area.c
==============================================================================
--- trunk/app/color_area.c (original)
+++ trunk/app/color_area.c Fri Jul 18 22:00:55 2008
@@ -322,10 +322,6 @@
GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
TRUE);
- gtk_color_selection_set_update_policy(
- GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
- GTK_UPDATE_CONTINUOUS);
-
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
g_signal_connect (G_OBJECT (window), "delete_event",
Modified: trunk/app/defaults.c
==============================================================================
--- trunk/app/defaults.c (original)
+++ trunk/app/defaults.c Fri Jul 18 22:00:55 2008
@@ -61,8 +61,7 @@
no_defaults_dialog = gtk_label_new(_("This object has no defaults."));
gtk_widget_show (no_defaults_dialog);
- gtk_widget_ref(no_defaults_dialog);
- gtk_object_sink(GTK_OBJECT(no_defaults_dialog));
+ g_object_ref_sink(GTK_OBJECT(no_defaults_dialog));
}
static gint
Modified: trunk/app/diagram_tree.c
==============================================================================
--- trunk/app/diagram_tree.c (original)
+++ trunk/app/diagram_tree.c Fri Jul 18 22:00:55 2008
@@ -25,6 +25,8 @@
#include <string.h>
+#undef GTK_DISABLE_DEPRECATED /* GtkCTree */
+
#include "properties.h"
#include "diagram_tree_menu.h"
#include "diagram_tree_menu_callbacks.h"
Modified: trunk/app/diagram_tree_menu.c
==============================================================================
--- trunk/app/diagram_tree_menu.c (original)
+++ trunk/app/diagram_tree_menu.c Fri Jul 18 22:00:55 2008
@@ -24,6 +24,7 @@
# include <config.h>
#endif
+#undef GTK_DISABLE_DEPRECATED /* GtkItemFactory, GtkCTree */
#include "diagram_tree_menu_callbacks.h"
#include "diagram_tree_menu.h"
#include "diagram_tree_window.h"
Modified: trunk/app/diapagelayout.c
==============================================================================
--- trunk/app/diapagelayout.c (original)
+++ trunk/app/diapagelayout.c Fri Jul 18 22:00:55 2008
@@ -25,6 +25,7 @@
#include <config.h>
#endif
+#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu, GtkSignal, ... */
#include "diapagelayout.h"
#include "widgets.h"
@@ -37,6 +38,41 @@
#include "paper.h"
#include "prefs.h"
+/* private class : noone wants to inherit and noone needs to mess with details */
+#define DIA_PAGE_LAYOUT_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, dia_page_layout_get_type(), DiaPageLayoutClass)
+#define DIA_IS_PAGE_LAYOUT(obj) GTK_CHECK_TYPE(obj, dia_page_layout_get_type())
+
+typedef struct _DiaPageLayoutClass DiaPageLayoutClass;
+
+struct _DiaPageLayout {
+ GtkTable parent;
+
+ /*<private>*/
+ GtkWidget *paper_size, *paper_label;
+ GtkWidget *orient_portrait, *orient_landscape;
+ GtkWidget *tmargin, *bmargin, *lmargin, *rmargin;
+ GtkWidget *scale, *fitto;
+ GtkWidget *scaling, *fitw, *fith;
+
+ GtkWidget *darea;
+
+ GdkGC *gc;
+ GdkColor white, black, blue;
+ gint papernum; /* index into page_metrics array */
+
+ /* position of paper preview */
+ gint x, y, width, height;
+
+ gboolean block_changed;
+};
+
+struct _DiaPageLayoutClass {
+ GtkTableClass parent_class;
+
+ void (*changed)(DiaPageLayout *pl);
+};
+
+
enum {
CHANGED,
LAST_SIGNAL
@@ -133,7 +169,7 @@
for (i = 0; paper_names != NULL;
i++, paper_names = g_list_next(paper_names)) {
menuitem = gtk_menu_item_new_with_label(paper_names->data);
- gtk_object_set_user_data(GTK_OBJECT(menuitem), GINT_TO_POINTER(i));
+ g_object_set_data (G_OBJECT (menuitem), "user_data", GINT_TO_POINTER(i));
g_signal_connect(GTK_OBJECT(menuitem), "activate",
G_CALLBACK(paper_size_change), self);
gtk_container_add(GTK_CONTAINER(menu), menuitem);
@@ -457,6 +493,12 @@
}
void
+dia_page_layout_set_changed (DiaPageLayout *self, gboolean changed)
+{
+ self->block_changed = changed;
+}
+
+void
dia_page_layout_get_fit_dims(DiaPageLayout *self, gint *w, gint *h)
{
if (w)
@@ -661,7 +703,7 @@
{
gchar buf[512];
- self->papernum = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(item)));
+ self->papernum = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(item), "user_data"));
size_page(self, &self->darea->allocation);
gtk_widget_queue_draw(self->darea);
Modified: trunk/app/diapagelayout.h
==============================================================================
--- trunk/app/diapagelayout.h (original)
+++ trunk/app/diapagelayout.h Fri Jul 18 22:00:55 2008
@@ -24,47 +24,16 @@
#include <gtk/gtk.h>
-#define DIA_PAGE_LAYOUT(obj) GTK_CHECK_CAST(obj, dia_page_layout_get_type(), DiaPageLayout)
-#define DIA_PAGE_LAYOUT_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, dia_page_layout_get_type(), DiaPageLayoutClass)
-#define DIA_IS_PAGE_LAYOUT(obj) GTK_CHECK_TYPE(obj, dia_page_layout_get_type())
typedef struct _DiaPageLayout DiaPageLayout;
-typedef struct _DiaPageLayoutClass DiaPageLayoutClass;
+GType dia_page_layout_get_type (void);
+#define DIA_PAGE_LAYOUT(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_page_layout_get_type(), DiaPageLayout)
typedef enum {
DIA_PAGE_ORIENT_PORTRAIT,
DIA_PAGE_ORIENT_LANDSCAPE
} DiaPageOrientation;
-struct _DiaPageLayout {
- GtkTable parent;
-
- /*<private>*/
- GtkWidget *paper_size, *paper_label;
- GtkWidget *orient_portrait, *orient_landscape;
- GtkWidget *tmargin, *bmargin, *lmargin, *rmargin;
- GtkWidget *scale, *fitto;
- GtkWidget *scaling, *fitw, *fith;
-
- GtkWidget *darea;
-
- GdkGC *gc;
- GdkColor white, black, blue;
- gint papernum; /* index into page_metrics array */
-
- /* position of paper preview */
- gint x, y, width, height;
-
- gboolean block_changed;
-};
-
-struct _DiaPageLayoutClass {
- GtkTableClass parent_class;
-
- void (*changed)(DiaPageLayout *pl);
-};
-
-GtkType dia_page_layout_get_type (void);
GtkWidget *dia_page_layout_new (void);
const gchar *dia_page_layout_get_paper (DiaPageLayout *pl);
@@ -89,7 +58,8 @@
gint *w, gint *h);
void dia_page_layout_set_fit_dims(DiaPageLayout *self,
gint w, gint h);
-
+void dia_page_layout_set_changed (DiaPageLayout *self,
+ gboolean changed);
void dia_page_layout_get_effective_area (DiaPageLayout *self,
gfloat *width,
Modified: trunk/app/disp_callbacks.c
==============================================================================
--- trunk/app/disp_callbacks.c (original)
+++ trunk/app/disp_callbacks.c Fri Jul 18 22:00:55 2008
@@ -152,8 +152,6 @@
menu_item = gtk_check_menu_item_new();
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item),
item->active & DIAMENU_TOGGLE_ON);
- gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(menu_item),
- TRUE);
} else {
if (item->text)
menu_item = gtk_menu_item_new_with_label(gettext(item->text));
@@ -165,8 +163,8 @@
item->app_data = menu_item;
if ( dia_menu->items[i].callback ) {
/* only connect signal handler if there is actually a callback */
- gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
- (GtkSignalFunc)object_menu_proxy, &dia_menu->items[i]);
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (object_menu_proxy), &dia_menu->items[i]);
} else {
if ( item->callback_data ) {
/* This menu item is a submenu if it has no callback, but does
@@ -248,12 +246,12 @@
gtk_widget_set_sensitive(GTK_WIDGET(item->app_data),
item->active & DIAMENU_ACTIVE);
if (item->active & DIAMENU_TOGGLE) {
- g_signal_handlers_block_by_func(GTK_CHECK_MENU_ITEM(item->app_data),
- (GtkSignalFunc)object_menu_proxy, item);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->app_data),
- item->active & DIAMENU_TOGGLE_ON);
- g_signal_handlers_unblock_by_func(GTK_CHECK_MENU_ITEM(item->app_data),
- (GtkSignalFunc)object_menu_proxy, item);
+ g_signal_handlers_block_by_func (G_OBJECT (GTK_CHECK_MENU_ITEM (item->app_data)),
+ G_CALLBACK (object_menu_proxy), item);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item->app_data),
+ item->active & DIAMENU_TOGGLE_ON);
+ g_signal_handlers_unblock_by_func (G_OBJECT (GTK_CHECK_MENU_ITEM(item->app_data)),
+ G_CALLBACK (object_menu_proxy), item);
}
}
Modified: trunk/app/display.c
==============================================================================
--- trunk/app/display.c (original)
+++ trunk/app/display.c Fri Jul 18 22:00:55 2008
@@ -83,7 +83,7 @@
zoom_text = g_strdup_printf("%.1f%%",
ddisp->zoom_factor * 100.0 / DDISPLAY_NORMAL_ZOOM);
zoomcombo = ddisp->zoom_status;
- gtk_entry_set_text(GTK_ENTRY(gtk_object_get_user_data(GTK_OBJECT(zoomcombo))),
+ gtk_entry_set_text(GTK_ENTRY (g_object_get_data (G_OBJECT(zoomcombo), "user_data")),
zoom_text);
}
@@ -612,8 +612,7 @@
{
/* if no update is queued, queue update */
if (!ddisp->update_id)
- ddisp->update_id = gtk_idle_add((GtkFunction) ddisplay_update_handler,
- ddisp);
+ ddisp->update_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc)ddisplay_update_handler, ddisp, NULL);
}
static void
@@ -1046,7 +1045,7 @@
/* dont mix new renderer with old updates */
if (ddisp->update_id) {
- gtk_idle_remove (ddisp->update_id);
+ g_source_remove (ddisp->update_id);
ddisp->update_id = 0;
}
@@ -1105,7 +1104,7 @@
ddisp_destroy(DDisplay *ddisp)
{
if (ddisp->update_id) {
- gtk_idle_remove(ddisp->update_id);
+ g_source_remove (ddisp->update_id);
ddisp->update_id = 0;
}
@@ -1140,7 +1139,7 @@
close_ddisp = FALSE;
if (ddisp->update_id && close_ddisp) {
- gtk_idle_remove(ddisp->update_id);
+ g_source_remove (ddisp->update_id);
ddisp->update_id = 0;
}
/* fall through */
Modified: trunk/app/dynamic_refresh.c
==============================================================================
--- trunk/app/dynamic_refresh.c (original)
+++ trunk/app/dynamic_refresh.c Fri Jul 18 22:00:55 2008
@@ -76,34 +76,44 @@
return TRUE;
}
-static gboolean idle_handler(gpointer data) {
+static gboolean
+idle_handler (gpointer data)
+{
guint new_timeout;
new_timeout = dynobj_list_get_dynobj_rate();
if (timeout != new_timeout) {
if (timer_id) {
- gtk_timeout_remove(timer_id);
+ g_source_remove (timer_id);
timer_id = 0;
}
timeout = new_timeout;
if (timeout) {
- timer_id = gtk_timeout_add(timeout,timer_handler,NULL);
+ timer_id = g_timeout_add_full (G_PRIORITY_LOW, timeout, timer_handler, NULL, NULL);
}
}
idle_id = 0;
return FALSE;
}
-void dynobj_refresh_kick(void) {
+void
+dynobj_refresh_kick(void)
+{
if (!idle_id)
- idle_id = gtk_idle_add_priority(GTK_PRIORITY_LOW,idle_handler,NULL);
+ idle_id = g_idle_add_full (G_PRIORITY_LOW, idle_handler, NULL, NULL);
}
-void dynobj_refresh_init(void) {
+void
+dynobj_refresh_init(void)
+{
/* NOP */
}
-void dynobj_refresh_finish(void) {
- if (timer_id) gtk_timeout_remove(timer_id);
- if (idle_id) gtk_idle_remove(idle_id);
+void
+dynobj_refresh_finish (void)
+{
+ if (timer_id)
+ g_source_remove (timer_id);
+ if (idle_id)
+ g_source_remove(idle_id);
}
Modified: trunk/app/filedlg.c
==============================================================================
--- trunk/app/filedlg.c (original)
+++ trunk/app/filedlg.c Fri Jul 18 22:00:55 2008
@@ -355,7 +355,7 @@
struct stat stat_struct;
if (response == GTK_RESPONSE_ACCEPT) {
- dia = gtk_object_get_user_data(GTK_OBJECT(fs));
+ dia = g_object_get_data (G_OBJECT(fs), "user_data");
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
@@ -403,8 +403,8 @@
g_free (filename);
}
/* if we have our own reference, drop it before destroy */
- if ((dia = gtk_object_get_user_data(GTK_OBJECT(fs))) != NULL) {
- gtk_object_set_user_data(GTK_OBJECT(fs), NULL);
+ if ((dia = g_object_get_data (G_OBJECT(fs), "user_data")) != NULL) {
+ g_object_set_data (G_OBJECT(fs), "user_data", NULL);
g_object_unref (dia);
}
gtk_widget_destroy(GTK_WIDGET(fs));
@@ -451,10 +451,17 @@
g_signal_connect(G_OBJECT(compressbutton), "toggled",
G_CALLBACK(toggle_compress_callback), NULL);
gtk_widget_show(compressbutton);
+#if GTK_CHECK_VERSION (2,12,0)
+ gtk_widget_set_tooltip_text (compressbutton,
+ _("Compression reduces file size to less than 1/10th "
+ "size and speeds up loading and saving. Some text "
+ "programs cannot manipulate compressed files."));
+#else
gtk_tooltips_set_tip(tool_tips, compressbutton,
_("Compression reduces file size to less than 1/10th "
"size and speeds up loading and saving. Some text "
"programs cannot manipulate compressed files."), NULL);
+#endif
g_signal_connect (GTK_FILE_CHOOSER(savedlg),
"response", G_CALLBACK(file_save_as_response_callback), compressbutton);
g_signal_connect(GTK_OBJECT(savedlg), "destroy",
@@ -466,12 +473,12 @@
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compressbutton),
dia->data->is_compressed);
g_signal_handlers_unblock_by_func(G_OBJECT(compressbutton), toggle_compress_callback, NULL);
- if (gtk_object_get_user_data(GTK_OBJECT(savedlg)) != NULL)
- g_object_unref(gtk_object_get_user_data(GTK_OBJECT(savedlg)));
+ if (g_object_get_data (G_OBJECT (savedlg), "user_data") != NULL)
+ g_object_unref (g_object_get_data (G_OBJECT (savedlg), "user_data"));
if (GTK_WIDGET_VISIBLE(savedlg)) {
/* keep a refernce to the diagram */
g_object_ref(dia);
- gtk_object_set_user_data(GTK_OBJECT(savedlg), dia);
+ g_object_set_data (G_OBJECT (savedlg), "user_data", dia);
gtk_window_present (GTK_WINDOW(savedlg));
return;
}
@@ -491,7 +498,7 @@
g_free(filename);
}
g_object_ref(dia);
- gtk_object_set_user_data(GTK_OBJECT(savedlg), dia);
+ g_object_set_data (G_OBJECT (savedlg), "user_data", dia);
gtk_widget_show(savedlg);
}
@@ -619,7 +626,7 @@
DiaExportFilter *ef;
struct stat statbuf;
- dia = gtk_object_get_user_data(GTK_OBJECT(fs));
+ dia = g_object_get_data (G_OBJECT (fs), "user_data");
g_assert (dia);
if (response == GTK_RESPONSE_ACCEPT) {
@@ -739,10 +746,10 @@
g_signal_connect(GTK_FILE_CHOOSER(exportdlg),
"response", G_CALLBACK(file_export_response_callback), omenu);
}
- if (gtk_object_get_user_data(GTK_OBJECT(exportdlg)))
- g_object_unref (gtk_object_get_user_data(GTK_OBJECT(exportdlg)));
+ if (g_object_get_data (G_OBJECT(exportdlg), "user_data"))
+ g_object_unref (g_object_get_data (G_OBJECT(exportdlg), "user_data"));
g_object_ref(dia);
- gtk_object_set_user_data(GTK_OBJECT(exportdlg), dia);
+ g_object_set_data (G_OBJECT (exportdlg), "user_data", dia);
gtk_widget_set_sensitive(exportdlg, TRUE);
if (dia && dia->filename)
Modified: trunk/app/gtkhwrapbox.c
==============================================================================
--- trunk/app/gtkhwrapbox.c (original)
+++ trunk/app/gtkhwrapbox.c Fri Jul 18 22:00:55 2008
@@ -20,22 +20,23 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
#include "gtkhwrapbox.h"
-#include <math.h>
/* --- prototypes --- */
static void gtk_hwrap_box_class_init (GtkHWrapBoxClass *klass);
static void gtk_hwrap_box_init (GtkHWrapBox *hwbox);
static void gtk_hwrap_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+ GtkRequisition *requisition);
static void gtk_hwrap_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
+ GtkAllocation *allocation);
static GSList* reverse_list_row_children (GtkWrapBox *wbox,
- GtkWrapBoxChild **child_p,
- GtkAllocation *area,
- guint *max_height,
- gboolean *can_vexpand);
+ GtkWrapBoxChild **child_p,
+ GtkAllocation *area,
+ guint *max_height,
+ gboolean *can_vexpand);
/* --- variables --- */
@@ -43,46 +44,48 @@
/* --- functions --- */
-GtkType
+GType
gtk_hwrap_box_get_type (void)
{
- static GtkType hwrap_box_type = 0;
-
- if (!hwrap_box_type)
+ static GType hwrap_box_type = 0;
+
+ if (! hwrap_box_type)
{
- static const GtkTypeInfo hwrap_box_info =
+ const GTypeInfo hwrap_box_info =
{
- "GtkHWrapBox",
- sizeof (GtkHWrapBox),
- sizeof (GtkHWrapBoxClass),
- (GtkClassInitFunc) gtk_hwrap_box_class_init,
- (GtkObjectInitFunc) gtk_hwrap_box_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ sizeof (GtkHWrapBoxClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_hwrap_box_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkHWrapBox),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_hwrap_box_init,
};
-
- hwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &hwrap_box_info);
+
+ hwrap_box_type = g_type_register_static (GTK_TYPE_WRAP_BOX, "GtkHWrapBox",
+ &hwrap_box_info, 0);
}
-
+
return hwrap_box_type;
}
static void
gtk_hwrap_box_class_init (GtkHWrapBoxClass *class)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkWrapBoxClass *wrap_box_class;
-
- object_class = GTK_OBJECT_CLASS (class);
+
+ object_class = G_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
wrap_box_class = GTK_WRAP_BOX_CLASS (class);
-
- parent_class = gtk_type_class (GTK_TYPE_WRAP_BOX);
-
+
+ parent_class = g_type_class_peek_parent (class);
+
widget_class->size_request = gtk_hwrap_box_size_request;
widget_class->size_allocate = gtk_hwrap_box_size_allocate;
@@ -99,24 +102,18 @@
GtkWidget*
gtk_hwrap_box_new (gboolean homogeneous)
{
- GtkHWrapBox *hwbox;
-
- hwbox = GTK_HWRAP_BOX (gtk_widget_new (GTK_TYPE_HWRAP_BOX, NULL));
-
- GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
-
- return GTK_WIDGET (hwbox);
+ return g_object_new (GTK_TYPE_HWRAP_BOX, "homogeneous", homogeneous, NULL);
}
static inline void
get_child_requisition (GtkWrapBox *wbox,
- GtkWidget *child,
- GtkRequisition *child_requisition)
+ GtkWidget *child,
+ GtkRequisition *child_requisition)
{
if (wbox->homogeneous)
{
GtkHWrapBox *hwbox = GTK_HWRAP_BOX (wbox);
-
+
child_requisition->width = hwbox->max_child_width;
child_requisition->height = hwbox->max_child_height;
}
@@ -126,8 +123,8 @@
static gfloat
get_layout_size (GtkHWrapBox *this,
- guint max_width,
- guint *width_inc)
+ guint max_width,
+ guint *width_inc)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (this);
GtkWrapBoxChild *child;
@@ -144,26 +141,26 @@
guint row_width, row_height, n = 1;
if (!GTK_WIDGET_VISIBLE (child->widget))
- continue;
+ continue;
get_child_requisition (wbox, child->widget, &child_requisition);
if (!last_row_filled)
- *width_inc = MIN (*width_inc, child_requisition.width - left_over);
+ *width_inc = MIN (*width_inc, child_requisition.width - left_over);
row_width = child_requisition.width;
row_height = child_requisition.height;
for (row_child = child->next; row_child && n < wbox->child_limit; row_child = row_child->next)
- {
- if (GTK_WIDGET_VISIBLE (row_child->widget))
- {
- get_child_requisition (wbox, row_child->widget, &child_requisition);
- if (row_width + wbox->hspacing + child_requisition.width > max_width)
- break;
- row_width += wbox->hspacing + child_requisition.width;
- row_height = MAX (row_height, child_requisition.height);
- n++;
- }
- child = row_child;
- }
+ {
+ if (GTK_WIDGET_VISIBLE (row_child->widget))
+ {
+ get_child_requisition (wbox, row_child->widget, &child_requisition);
+ if (row_width + wbox->hspacing + child_requisition.width > max_width)
+ break;
+ row_width += wbox->hspacing + child_requisition.width;
+ row_height = MAX (row_height, child_requisition.height);
+ n++;
+ }
+ child = row_child;
+ }
last_row_filled = n >= wbox->child_limit;
left_over = last_row_filled ? 0 : max_width - (row_width + wbox->hspacing);
total_height += (n_rows ? wbox->vspacing : 0) + row_height;
@@ -172,22 +169,22 @@
if (*width_inc > this->max_child_width)
*width_inc = 0;
-
+
return MAX (total_height, 1);
}
static void
gtk_hwrap_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+ GtkRequisition *requisition)
{
GtkHWrapBox *this = GTK_HWRAP_BOX (widget);
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
gfloat ratio_dist, layout_width = 0;
guint row_inc = 0;
-
+
g_return_if_fail (requisition != NULL);
-
+
requisition->width = 0;
requisition->height = 0;
this->max_child_width = 0;
@@ -197,12 +194,12 @@
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
- GtkRequisition child_requisition;
-
- gtk_widget_size_request (child->widget, &child_requisition);
+ GtkRequisition child_requisition;
+
+ gtk_widget_size_request (child->widget, &child_requisition);
- this->max_child_width = MAX (this->max_child_width, child_requisition.width);
- this->max_child_height = MAX (this->max_child_height, child_requisition.height);
+ this->max_child_width = MAX (this->max_child_width, child_requisition.width);
+ this->max_child_height = MAX (this->max_child_height, child_requisition.height);
}
/* figure all possible layouts */
@@ -215,26 +212,26 @@
layout_width += row_inc;
layout_height = get_layout_size (this, layout_width, &row_inc);
- ratio = layout_width / layout_height; /*<h2v-skip>*/
+ ratio = layout_width / layout_height; /*<h2v-skip>*/
dist = MAX (ratio, wbox->aspect_ratio) - MIN (ratio, wbox->aspect_ratio);
if (dist < ratio_dist)
- {
- ratio_dist = dist;
- requisition->width = layout_width;
- requisition->height = layout_height;
- }
-
+ {
+ ratio_dist = dist;
+ requisition->width = layout_width;
+ requisition->height = layout_height;
+ }
+
/* g_print ("ratio for width %d height %d = %f\n",
- (gint) layout_width,
- (gint) layout_height,
- ratio);
+ (gint) layout_width,
+ (gint) layout_height,
+ ratio);
*/
}
while (row_inc);
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
- /* g_print ("choosen: width %d, height %d\n",
+ /* g_print ("chosen: width %d, height %d\n",
requisition->width,
requisition->height);
*/
@@ -242,29 +239,29 @@
static GSList*
reverse_list_row_children (GtkWrapBox *wbox,
- GtkWrapBoxChild **child_p,
- GtkAllocation *area,
- guint *max_child_size,
- gboolean *expand_line)
+ GtkWrapBoxChild **child_p,
+ GtkAllocation *area,
+ guint *max_child_size,
+ gboolean *expand_line)
{
GSList *slist = NULL;
guint width = 0, row_width = area->width;
GtkWrapBoxChild *child = *child_p;
-
+
*max_child_size = 0;
*expand_line = FALSE;
-
+
while (child && !GTK_WIDGET_VISIBLE (child->widget))
{
*child_p = child->next;
child = *child_p;
}
-
+
if (child)
{
GtkRequisition child_requisition;
guint n = 1;
-
+
get_child_requisition (wbox, child->widget, &child_requisition);
width += child_requisition.width;
*max_child_size = MAX (*max_child_size, child_requisition.height);
@@ -272,62 +269,62 @@
slist = g_slist_prepend (slist, child);
*child_p = child->next;
child = *child_p;
-
+
while (child && n < wbox->child_limit)
- {
- if (GTK_WIDGET_VISIBLE (child->widget))
- {
- get_child_requisition (wbox, child->widget, &child_requisition);
- if (width + wbox->hspacing + child_requisition.width > row_width ||
- child->wrapped)
- break;
- width += wbox->hspacing + child_requisition.width;
- *max_child_size = MAX (*max_child_size, child_requisition.height);
- *expand_line |= child->vexpand;
- slist = g_slist_prepend (slist, child);
- n++;
- }
- *child_p = child->next;
- child = *child_p;
- }
+ {
+ if (GTK_WIDGET_VISIBLE (child->widget))
+ {
+ get_child_requisition (wbox, child->widget, &child_requisition);
+ if (width + wbox->hspacing + child_requisition.width > row_width ||
+ child->wrapped)
+ break;
+ width += wbox->hspacing + child_requisition.width;
+ *max_child_size = MAX (*max_child_size, child_requisition.height);
+ *expand_line |= child->vexpand;
+ slist = g_slist_prepend (slist, child);
+ n++;
+ }
+ *child_p = child->next;
+ child = *child_p;
+ }
}
-
+
return slist;
}
static void
layout_row (GtkWrapBox *wbox,
- GtkAllocation *area,
- GSList *children,
- guint children_per_line,
- gboolean vexpand)
+ GtkAllocation *area,
+ GSList *children,
+ guint children_per_line,
+ gboolean vexpand)
{
GSList *slist;
guint n_children = 0, n_expand_children = 0, have_expand_children = 0;
gint total_width = 0;
gfloat x, width, extra;
GtkAllocation child_allocation;
-
+
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
GtkRequisition child_requisition;
-
+
n_children++;
if (child->hexpand)
- n_expand_children++;
-
+ n_expand_children++;
+
get_child_requisition (wbox, child->widget, &child_requisition);
total_width += child_requisition.width;
}
-
+
width = MAX (1, area->width - (n_children - 1) * wbox->hspacing);
if (width > total_width)
extra = width - total_width;
else
extra = 0;
have_expand_children = n_expand_children && extra;
-
+
x = area->x;
if (wbox->homogeneous)
{
@@ -343,95 +340,95 @@
else
{
if (wbox->justify == GTK_JUSTIFY_FILL)
- {
- width = extra;
- have_expand_children = TRUE;
- n_expand_children = n_children;
- extra /= ((gdouble) n_expand_children);
- }
+ {
+ width = extra;
+ have_expand_children = TRUE;
+ n_expand_children = n_children;
+ extra /= ((gdouble) n_expand_children);
+ }
else if (wbox->justify == GTK_JUSTIFY_CENTER)
- {
- x += extra / 2;
- width = 0;
- extra = 0;
- }
+ {
+ x += extra / 2;
+ width = 0;
+ extra = 0;
+ }
else if (wbox->justify == GTK_JUSTIFY_LEFT)
- {
- width = 0;
- extra = 0;
- }
+ {
+ width = 0;
+ extra = 0;
+ }
else if (wbox->justify == GTK_JUSTIFY_RIGHT)
- {
- x += extra;
- width = 0;
- extra = 0;
- }
+ {
+ x += extra;
+ width = 0;
+ extra = 0;
+ }
}
-
+
n_children = 0;
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
-
+
child_allocation.x = x;
child_allocation.y = area->y;
if (wbox->homogeneous)
- {
- child_allocation.height = area->height;
- child_allocation.width = width;
- x += child_allocation.width + wbox->hspacing;
- }
+ {
+ child_allocation.height = area->height;
+ child_allocation.width = width;
+ x += child_allocation.width + wbox->hspacing;
+ }
else
- {
- GtkRequisition child_requisition;
-
- get_child_requisition (wbox, child->widget, &child_requisition);
-
- if (child_requisition.height >= area->height)
- child_allocation.height = area->height;
- else
- {
- child_allocation.height = child_requisition.height;
- if (wbox->line_justify == GTK_JUSTIFY_FILL || child->vfill)
- child_allocation.height = area->height;
- else if (child->vexpand || wbox->line_justify == GTK_JUSTIFY_CENTER)
- child_allocation.y += (area->height - child_requisition.height) / 2;
- else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
- child_allocation.y += area->height - child_requisition.height;
- }
-
- if (have_expand_children)
- {
- child_allocation.width = child_requisition.width;
- if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
- {
- guint space;
-
- n_expand_children--;
- space = extra * n_expand_children;
- space = width - space;
- width -= space;
- if (child->hfill)
- child_allocation.width += space;
- else
- {
- child_allocation.x += space / 2;
- x += space;
- }
- }
- }
- else
- {
- /* g_print ("child_allocation.x %d += %d * %f ",
- child_allocation.x, n_children, extra); */
- child_allocation.x += n_children * extra;
- /* g_print ("= %d\n",
- child_allocation.x); */
- child_allocation.width = MIN (child_requisition.width,
- area->width - child_allocation.x + area->x);
- }
- }
-
+ {
+ GtkRequisition child_requisition;
+
+ get_child_requisition (wbox, child->widget, &child_requisition);
+
+ if (child_requisition.height >= area->height)
+ child_allocation.height = area->height;
+ else
+ {
+ child_allocation.height = child_requisition.height;
+ if (wbox->line_justify == GTK_JUSTIFY_FILL || child->vfill)
+ child_allocation.height = area->height;
+ else if (child->vexpand || wbox->line_justify == GTK_JUSTIFY_CENTER)
+ child_allocation.y += (area->height - child_requisition.height) / 2;
+ else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
+ child_allocation.y += area->height - child_requisition.height;
+ }
+
+ if (have_expand_children)
+ {
+ child_allocation.width = child_requisition.width;
+ if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
+ {
+ guint space;
+
+ n_expand_children--;
+ space = extra * n_expand_children;
+ space = width - space;
+ width -= space;
+ if (child->hfill)
+ child_allocation.width += space;
+ else
+ {
+ child_allocation.x += space / 2;
+ x += space;
+ }
+ }
+ }
+ else
+ {
+ /* g_print ("child_allocation.x %d += %d * %f ",
+ child_allocation.x, n_children, extra); */
+ child_allocation.x += n_children * extra;
+ /* g_print ("= %d\n",
+ child_allocation.x); */
+ child_allocation.width = MIN (child_requisition.width,
+ area->width - child_allocation.x + area->x);
+ }
+ }
+
x += child_allocation.width + wbox->hspacing;
gtk_widget_size_allocate (child->widget, &child_allocation);
n_children++;
@@ -444,12 +441,12 @@
GSList *children;
guint16 min_size;
guint expand : 1;
- Line *next;
+ Line *next;
};
static void
layout_rows (GtkWrapBox *wbox,
- GtkAllocation *area)
+ GtkAllocation *area)
{
GtkWrapBoxChild *next_child;
guint min_height;
@@ -459,151 +456,152 @@
guint total_height = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_height;
guint children_per_line;
-
+
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
- &next_child,
- area,
- &min_height,
- &vexpand);
+ &next_child,
+ area,
+ &min_height,
+ &vexpand);
slist = g_slist_reverse (slist);
children_per_line = g_slist_length (slist);
while (slist)
{
- Line *line = g_new (Line, 1);
-
+ Line *line = g_slice_new (Line);
+
line->children = slist;
line->min_size = min_height;
total_height += min_height;
line->expand = vexpand;
if (vexpand)
- n_expand_lines++;
+ n_expand_lines++;
line->next = line_list;
line_list = line;
n_lines++;
-
+
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
- &next_child,
- area,
- &min_height,
- &vexpand);
+ &next_child,
+ area,
+ &min_height,
+ &vexpand);
slist = g_slist_reverse (slist);
}
-
+
if (total_height > area->height)
shrink_height = total_height - area->height;
else
shrink_height = 0;
-
+
if (1) /* reverse lines and shrink */
{
Line *prev = NULL, *last = NULL;
gfloat n_shrink_lines = n_lines;
-
+
while (line_list)
- {
- Line *tmp = line_list->next;
+ {
+ Line *tmp = line_list->next;
- if (shrink_height)
- {
- Line *line = line_list;
- guint shrink_fract = shrink_height / n_shrink_lines + 0.5;
-
- if (line->min_size > shrink_fract)
- {
- shrink_height -= shrink_fract;
- line->min_size -= shrink_fract;
- }
- else
- {
- shrink_height -= line->min_size - 1;
- line->min_size = 1;
- }
- }
- n_shrink_lines--;
-
- last = line_list;
- line_list->next = prev;
- prev = line_list;
- line_list = tmp;
- }
+ if (shrink_height)
+ {
+ Line *line = line_list;
+ guint shrink_fract = shrink_height / n_shrink_lines + 0.5;
+
+ if (line->min_size > shrink_fract)
+ {
+ shrink_height -= shrink_fract;
+ line->min_size -= shrink_fract;
+ }
+ else
+ {
+ shrink_height -= line->min_size - 1;
+ line->min_size = 1;
+ }
+ }
+ n_shrink_lines--;
+
+ last = line_list;
+ line_list->next = prev;
+ prev = line_list;
+ line_list = tmp;
+ }
line_list = last;
}
-
+
if (n_lines)
{
Line *line;
gfloat y, height, extra = 0;
-
+
height = area->height;
height = MAX (n_lines, height - (n_lines - 1) * wbox->vspacing);
-
+
if (wbox->homogeneous)
- height /= ((gdouble) n_lines);
+ height /= ((gdouble) n_lines);
else if (n_expand_lines)
- {
- height = MAX (0, height - total_height);
- extra = height / ((gdouble) n_expand_lines);
- }
+ {
+ height = MAX (0, height - total_height);
+ extra = height / ((gdouble) n_expand_lines);
+ }
else
- height = 0;
-
+ height = 0;
+
y = area->y;
line = line_list;
while (line)
- {
- GtkAllocation row_allocation;
- Line *next_line = line->next;
-
- row_allocation.x = area->x;
- row_allocation.width = area->width;
- if (wbox->homogeneous)
- row_allocation.height = height;
- else
- {
- row_allocation.height = line->min_size;
-
- if (line->expand)
- row_allocation.height += extra;
- }
-
- row_allocation.y = y;
-
- y += row_allocation.height + wbox->vspacing;
- layout_row (wbox,
- &row_allocation,
- line->children,
- children_per_line,
- line->expand);
-
- g_slist_free (line->children);
- g_free (line);
- line = next_line;
- }
+ {
+ GtkAllocation row_allocation;
+ Line *next_line = line->next;
+
+ row_allocation.x = area->x;
+ row_allocation.width = area->width;
+ if (wbox->homogeneous)
+ row_allocation.height = height;
+ else
+ {
+ row_allocation.height = line->min_size;
+
+ if (line->expand)
+ row_allocation.height += extra;
+ }
+
+ row_allocation.y = y;
+
+ y += row_allocation.height + wbox->vspacing;
+ layout_row (wbox,
+ &row_allocation,
+ line->children,
+ children_per_line,
+ line->expand);
+
+ g_slist_free (line->children);
+ line = next_line;
+ }
+
+ g_slice_free_chain (Line, line_list, next);
}
}
static void
gtk_hwrap_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkAllocation area;
gint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
-
+
widget->allocation = *allocation;
area.x = allocation->x + border;
area.y = allocation->y + border;
area.width = MAX (1, (gint) allocation->width - border * 2);
area.height = MAX (1, (gint) allocation->height - border * 2);
-
+
/*<h2v-off>*/
/* g_print ("got: width %d, height %d\n",
allocation->width,
allocation->height);
*/
/*<h2v-on>*/
-
+
layout_rows (wbox, &area);
}
Modified: trunk/app/gtkhwrapbox.h
==============================================================================
--- trunk/app/gtkhwrapbox.h (original)
+++ trunk/app/gtkhwrapbox.h Fri Jul 18 22:00:55 2008
@@ -30,12 +30,12 @@
/* --- type macros --- */
-#define GTK_TYPE_HWRAP_BOX (gtk_hwrap_box_get_type ())
-#define GTK_HWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBox))
-#define GTK_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
-#define GTK_IS_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_HWRAP_BOX))
-#define GTK_IS_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HWRAP_BOX))
-#define GTK_HWRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
+#define GTK_TYPE_HWRAP_BOX (gtk_hwrap_box_get_type ())
+#define GTK_HWRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBox))
+#define GTK_HWRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
+#define GTK_IS_HWRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HWRAP_BOX))
+#define GTK_IS_HWRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HWRAP_BOX))
+#define GTK_HWRAP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
/* --- typedefs --- */
@@ -47,7 +47,7 @@
struct _GtkHWrapBox
{
GtkWrapBox parent_widget;
-
+
/*<h2v-off>*/
guint max_child_width;
guint max_child_height;
@@ -61,7 +61,7 @@
/* --- prototypes --- */
-GtkType gtk_hwrap_box_get_type (void) G_GNUC_CONST;
+GType gtk_hwrap_box_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_hwrap_box_new (gboolean homogeneous);
Modified: trunk/app/gtkvwrapbox.c
==============================================================================
--- trunk/app/gtkvwrapbox.c (original)
+++ trunk/app/gtkvwrapbox.c Fri Jul 18 22:00:55 2008
@@ -20,21 +20,23 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
#include "gtkvwrapbox.h"
-#include <math.h>
+
/* --- prototypes --- */
static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass);
static void gtk_vwrap_box_init (GtkVWrapBox *vwbox);
static void gtk_vwrap_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+ GtkRequisition *requisition);
static void gtk_vwrap_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
+ GtkAllocation *allocation);
static GSList* reverse_list_col_children (GtkWrapBox *wbox,
- GtkWrapBoxChild **child_p,
- GtkAllocation *area,
- guint *max_width,
- gboolean *can_hexpand);
+ GtkWrapBoxChild **child_p,
+ GtkAllocation *area,
+ guint *max_width,
+ gboolean *can_hexpand);
/* --- variables --- */
@@ -42,46 +44,48 @@
/* --- functions --- */
-GtkType
+GType
gtk_vwrap_box_get_type (void)
{
- static GtkType vwrap_box_type = 0;
-
- if (!vwrap_box_type)
+ static GType vwrap_box_type = 0;
+
+ if (! vwrap_box_type)
{
- static const GtkTypeInfo vwrap_box_info =
+ const GTypeInfo vwrap_box_info =
{
- "GtkVWrapBox",
- sizeof (GtkVWrapBox),
- sizeof (GtkVWrapBoxClass),
- (GtkClassInitFunc) gtk_vwrap_box_class_init,
- (GtkObjectInitFunc) gtk_vwrap_box_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ sizeof (GtkVWrapBoxClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_vwrap_box_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkVWrapBox),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_vwrap_box_init,
};
-
- vwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &vwrap_box_info);
+
+ vwrap_box_type = g_type_register_static (GTK_TYPE_WRAP_BOX, "GtkVWrapBox",
+ &vwrap_box_info, 0);
}
-
+
return vwrap_box_type;
}
static void
gtk_vwrap_box_class_init (GtkVWrapBoxClass *class)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkWrapBoxClass *wrap_box_class;
-
- object_class = GTK_OBJECT_CLASS (class);
+
+ object_class = G_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
wrap_box_class = GTK_WRAP_BOX_CLASS (class);
-
- parent_class = gtk_type_class (GTK_TYPE_WRAP_BOX);
-
+
+ parent_class = g_type_class_peek_parent (class);
+
widget_class->size_request = gtk_vwrap_box_size_request;
widget_class->size_allocate = gtk_vwrap_box_size_allocate;
@@ -98,24 +102,18 @@
GtkWidget*
gtk_vwrap_box_new (gboolean homogeneous)
{
- GtkVWrapBox *vwbox;
-
- vwbox = GTK_VWRAP_BOX (gtk_widget_new (GTK_TYPE_VWRAP_BOX, NULL));
-
- GTK_WRAP_BOX (vwbox)->homogeneous = homogeneous ? TRUE : FALSE;
-
- return GTK_WIDGET (vwbox);
+ return g_object_new (GTK_TYPE_VWRAP_BOX, "homogeneous", homogeneous, NULL);
}
static inline void
get_child_requisition (GtkWrapBox *wbox,
- GtkWidget *child,
- GtkRequisition *child_requisition)
+ GtkWidget *child,
+ GtkRequisition *child_requisition)
{
if (wbox->homogeneous)
{
GtkVWrapBox *vwbox = GTK_VWRAP_BOX (wbox);
-
+
child_requisition->height = vwbox->max_child_height;
child_requisition->width = vwbox->max_child_width;
}
@@ -125,8 +123,8 @@
static gfloat
get_layout_size (GtkVWrapBox *this,
- guint max_height,
- guint *height_inc)
+ guint max_height,
+ guint *height_inc)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (this);
GtkWrapBoxChild *child;
@@ -143,26 +141,26 @@
guint col_height, col_width, n = 1;
if (!GTK_WIDGET_VISIBLE (child->widget))
- continue;
+ continue;
get_child_requisition (wbox, child->widget, &child_requisition);
if (!last_col_filled)
- *height_inc = MIN (*height_inc, child_requisition.height - left_over);
+ *height_inc = MIN (*height_inc, child_requisition.height - left_over);
col_height = child_requisition.height;
col_width = child_requisition.width;
for (col_child = child->next; col_child && n < wbox->child_limit; col_child = col_child->next)
- {
- if (GTK_WIDGET_VISIBLE (col_child->widget))
- {
- get_child_requisition (wbox, col_child->widget, &child_requisition);
- if (col_height + wbox->vspacing + child_requisition.height > max_height)
- break;
- col_height += wbox->vspacing + child_requisition.height;
- col_width = MAX (col_width, child_requisition.width);
- n++;
- }
- child = col_child;
- }
+ {
+ if (GTK_WIDGET_VISIBLE (col_child->widget))
+ {
+ get_child_requisition (wbox, col_child->widget, &child_requisition);
+ if (col_height + wbox->vspacing + child_requisition.height > max_height)
+ break;
+ col_height += wbox->vspacing + child_requisition.height;
+ col_width = MAX (col_width, child_requisition.width);
+ n++;
+ }
+ child = col_child;
+ }
last_col_filled = n >= wbox->child_limit;
left_over = last_col_filled ? 0 : max_height - (col_height + wbox->vspacing);
total_width += (n_cols ? wbox->hspacing : 0) + col_width;
@@ -171,22 +169,22 @@
if (*height_inc > this->max_child_height)
*height_inc = 0;
-
+
return MAX (total_width, 1);
}
static void
gtk_vwrap_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+ GtkRequisition *requisition)
{
GtkVWrapBox *this = GTK_VWRAP_BOX (widget);
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
gfloat ratio_dist, layout_height = 0;
guint col_inc = 0;
-
+
g_return_if_fail (requisition != NULL);
-
+
requisition->height = 0;
requisition->width = 0;
this->max_child_height = 0;
@@ -196,12 +194,12 @@
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
- GtkRequisition child_requisition;
-
- gtk_widget_size_request (child->widget, &child_requisition);
+ GtkRequisition child_requisition;
- this->max_child_height = MAX (this->max_child_height, child_requisition.height);
- this->max_child_width = MAX (this->max_child_width, child_requisition.width);
+ gtk_widget_size_request (child->widget, &child_requisition);
+
+ this->max_child_height = MAX (this->max_child_height, child_requisition.height);
+ this->max_child_width = MAX (this->max_child_width, child_requisition.width);
}
/* figure all possible layouts */
@@ -214,26 +212,26 @@
layout_height += col_inc;
layout_width = get_layout_size (this, layout_height, &col_inc);
- ratio = layout_width / layout_height; /*<h2v-skip>*/
+ ratio = layout_width / layout_height; /*<h2v-skip>*/
dist = MAX (ratio, wbox->aspect_ratio) - MIN (ratio, wbox->aspect_ratio);
if (dist < ratio_dist)
- {
- ratio_dist = dist;
- requisition->height = layout_height;
- requisition->width = layout_width;
- }
-
+ {
+ ratio_dist = dist;
+ requisition->height = layout_height;
+ requisition->width = layout_width;
+ }
+
/* g_print ("ratio for height %d width %d = %f\n",
- (gint) layout_height,
- (gint) layout_width,
- ratio);
+ (gint) layout_height,
+ (gint) layout_width,
+ ratio);
*/
}
while (col_inc);
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
- /* g_print ("choosen: height %d, width %d\n",
+ /* g_print ("chosen: height %d, width %d\n",
requisition->height,
requisition->width);
*/
@@ -241,29 +239,29 @@
static GSList*
reverse_list_col_children (GtkWrapBox *wbox,
- GtkWrapBoxChild **child_p,
- GtkAllocation *area,
- guint *max_child_size,
- gboolean *expand_line)
+ GtkWrapBoxChild **child_p,
+ GtkAllocation *area,
+ guint *max_child_size,
+ gboolean *expand_line)
{
GSList *slist = NULL;
guint height = 0, col_height = area->height;
GtkWrapBoxChild *child = *child_p;
-
+
*max_child_size = 0;
*expand_line = FALSE;
-
+
while (child && !GTK_WIDGET_VISIBLE (child->widget))
{
*child_p = child->next;
child = *child_p;
}
-
+
if (child)
{
GtkRequisition child_requisition;
guint n = 1;
-
+
get_child_requisition (wbox, child->widget, &child_requisition);
height += child_requisition.height;
*max_child_size = MAX (*max_child_size, child_requisition.width);
@@ -271,62 +269,62 @@
slist = g_slist_prepend (slist, child);
*child_p = child->next;
child = *child_p;
-
+
while (child && n < wbox->child_limit)
- {
- if (GTK_WIDGET_VISIBLE (child->widget))
- {
- get_child_requisition (wbox, child->widget, &child_requisition);
- if (height + wbox->vspacing + child_requisition.height > col_height ||
- child->wrapped)
- break;
- height += wbox->vspacing + child_requisition.height;
- *max_child_size = MAX (*max_child_size, child_requisition.width);
- *expand_line |= child->hexpand;
- slist = g_slist_prepend (slist, child);
- n++;
- }
- *child_p = child->next;
- child = *child_p;
- }
+ {
+ if (GTK_WIDGET_VISIBLE (child->widget))
+ {
+ get_child_requisition (wbox, child->widget, &child_requisition);
+ if (height + wbox->vspacing + child_requisition.height > col_height ||
+ child->wrapped)
+ break;
+ height += wbox->vspacing + child_requisition.height;
+ *max_child_size = MAX (*max_child_size, child_requisition.width);
+ *expand_line |= child->hexpand;
+ slist = g_slist_prepend (slist, child);
+ n++;
+ }
+ *child_p = child->next;
+ child = *child_p;
+ }
}
-
+
return slist;
}
static void
layout_col (GtkWrapBox *wbox,
- GtkAllocation *area,
- GSList *children,
- guint children_per_line,
- gboolean hexpand)
+ GtkAllocation *area,
+ GSList *children,
+ guint children_per_line,
+ gboolean hexpand)
{
GSList *slist;
guint n_children = 0, n_expand_children = 0, have_expand_children = 0;
gint total_height = 0;
gfloat y, height, extra;
GtkAllocation child_allocation;
-
+
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
GtkRequisition child_requisition;
-
+
n_children++;
if (child->vexpand)
- n_expand_children++;
-
+ n_expand_children++;
+
get_child_requisition (wbox, child->widget, &child_requisition);
total_height += child_requisition.height;
}
-
+
height = MAX (1, area->height - (n_children - 1) * wbox->vspacing);
if (height > total_height)
extra = height - total_height;
else
extra = 0;
have_expand_children = n_expand_children && extra;
-
+
y = area->y;
if (wbox->homogeneous)
{
@@ -342,95 +340,95 @@
else
{
if (wbox->justify == GTK_JUSTIFY_FILL)
- {
- height = extra;
- have_expand_children = TRUE;
- n_expand_children = n_children;
- extra /= ((gdouble) n_expand_children);
- }
+ {
+ height = extra;
+ have_expand_children = TRUE;
+ n_expand_children = n_children;
+ extra /= ((gdouble) n_expand_children);
+ }
else if (wbox->justify == GTK_JUSTIFY_CENTER)
- {
- y += extra / 2;
- height = 0;
- extra = 0;
- }
+ {
+ y += extra / 2;
+ height = 0;
+ extra = 0;
+ }
else if (wbox->justify == GTK_JUSTIFY_LEFT)
- {
- height = 0;
- extra = 0;
- }
+ {
+ height = 0;
+ extra = 0;
+ }
else if (wbox->justify == GTK_JUSTIFY_RIGHT)
- {
- y += extra;
- height = 0;
- extra = 0;
- }
+ {
+ y += extra;
+ height = 0;
+ extra = 0;
+ }
}
-
+
n_children = 0;
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
-
+
child_allocation.y = y;
child_allocation.x = area->x;
if (wbox->homogeneous)
- {
- child_allocation.width = area->width;
- child_allocation.height = height;
- y += child_allocation.height + wbox->vspacing;
- }
+ {
+ child_allocation.width = area->width;
+ child_allocation.height = height;
+ y += child_allocation.height + wbox->vspacing;
+ }
else
- {
- GtkRequisition child_requisition;
-
- get_child_requisition (wbox, child->widget, &child_requisition);
-
- if (child_requisition.width >= area->width)
- child_allocation.width = area->width;
- else
- {
- child_allocation.width = child_requisition.width;
- if (wbox->line_justify == GTK_JUSTIFY_FILL || child->hfill)
- child_allocation.width = area->width;
- else if (child->hexpand || wbox->line_justify == GTK_JUSTIFY_CENTER)
- child_allocation.x += (area->width - child_requisition.width) / 2;
- else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
- child_allocation.x += area->width - child_requisition.width;
- }
-
- if (have_expand_children)
- {
- child_allocation.height = child_requisition.height;
- if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
- {
- guint space;
-
- n_expand_children--;
- space = extra * n_expand_children;
- space = height - space;
- height -= space;
- if (child->vfill)
- child_allocation.height += space;
- else
- {
- child_allocation.y += space / 2;
- y += space;
- }
- }
- }
- else
- {
- /* g_print ("child_allocation.y %d += %d * %f ",
- child_allocation.y, n_children, extra); */
- child_allocation.y += n_children * extra;
- /* g_print ("= %d\n",
- child_allocation.y); */
- child_allocation.height = MIN (child_requisition.height,
- area->height - child_allocation.y + area->y);
- }
- }
-
+ {
+ GtkRequisition child_requisition;
+
+ get_child_requisition (wbox, child->widget, &child_requisition);
+
+ if (child_requisition.width >= area->width)
+ child_allocation.width = area->width;
+ else
+ {
+ child_allocation.width = child_requisition.width;
+ if (wbox->line_justify == GTK_JUSTIFY_FILL || child->hfill)
+ child_allocation.width = area->width;
+ else if (child->hexpand || wbox->line_justify == GTK_JUSTIFY_CENTER)
+ child_allocation.x += (area->width - child_requisition.width) / 2;
+ else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
+ child_allocation.x += area->width - child_requisition.width;
+ }
+
+ if (have_expand_children)
+ {
+ child_allocation.height = child_requisition.height;
+ if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
+ {
+ guint space;
+
+ n_expand_children--;
+ space = extra * n_expand_children;
+ space = height - space;
+ height -= space;
+ if (child->vfill)
+ child_allocation.height += space;
+ else
+ {
+ child_allocation.y += space / 2;
+ y += space;
+ }
+ }
+ }
+ else
+ {
+ /* g_print ("child_allocation.y %d += %d * %f ",
+ child_allocation.y, n_children, extra); */
+ child_allocation.y += n_children * extra;
+ /* g_print ("= %d\n",
+ child_allocation.y); */
+ child_allocation.height = MIN (child_requisition.height,
+ area->height - child_allocation.y + area->y);
+ }
+ }
+
y += child_allocation.height + wbox->vspacing;
gtk_widget_size_allocate (child->widget, &child_allocation);
n_children++;
@@ -448,7 +446,7 @@
static void
layout_cols (GtkWrapBox *wbox,
- GtkAllocation *area)
+ GtkAllocation *area)
{
GtkWrapBoxChild *next_child;
guint min_width;
@@ -458,151 +456,152 @@
guint total_width = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_width;
guint children_per_line;
-
+
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
- &next_child,
- area,
- &min_width,
- &hexpand);
+ &next_child,
+ area,
+ &min_width,
+ &hexpand);
slist = g_slist_reverse (slist);
children_per_line = g_slist_length (slist);
while (slist)
{
- Line *line = g_new (Line, 1);
-
+ Line *line = g_slice_new (Line);
+
line->children = slist;
line->min_size = min_width;
total_width += min_width;
line->expand = hexpand;
if (hexpand)
- n_expand_lines++;
+ n_expand_lines++;
line->next = line_list;
line_list = line;
n_lines++;
-
+
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
- &next_child,
- area,
- &min_width,
- &hexpand);
+ &next_child,
+ area,
+ &min_width,
+ &hexpand);
slist = g_slist_reverse (slist);
}
-
+
if (total_width > area->width)
shrink_width = total_width - area->width;
else
shrink_width = 0;
-
+
if (1) /* reverse lines and shrink */
{
Line *prev = NULL, *last = NULL;
gfloat n_shrink_lines = n_lines;
-
+
while (line_list)
- {
- Line *tmp = line_list->next;
+ {
+ Line *tmp = line_list->next;
- if (shrink_width)
- {
- Line *line = line_list;
- guint shrink_fract = shrink_width / n_shrink_lines + 0.5;
-
- if (line->min_size > shrink_fract)
- {
- shrink_width -= shrink_fract;
- line->min_size -= shrink_fract;
- }
- else
- {
- shrink_width -= line->min_size - 1;
- line->min_size = 1;
- }
- }
- n_shrink_lines--;
-
- last = line_list;
- line_list->next = prev;
- prev = line_list;
- line_list = tmp;
- }
+ if (shrink_width)
+ {
+ Line *line = line_list;
+ guint shrink_fract = shrink_width / n_shrink_lines + 0.5;
+
+ if (line->min_size > shrink_fract)
+ {
+ shrink_width -= shrink_fract;
+ line->min_size -= shrink_fract;
+ }
+ else
+ {
+ shrink_width -= line->min_size - 1;
+ line->min_size = 1;
+ }
+ }
+ n_shrink_lines--;
+
+ last = line_list;
+ line_list->next = prev;
+ prev = line_list;
+ line_list = tmp;
+ }
line_list = last;
}
-
+
if (n_lines)
{
Line *line;
gfloat x, width, extra = 0;
-
+
width = area->width;
width = MAX (n_lines, width - (n_lines - 1) * wbox->hspacing);
-
+
if (wbox->homogeneous)
- width /= ((gdouble) n_lines);
+ width /= ((gdouble) n_lines);
else if (n_expand_lines)
- {
- width = MAX (0, width - total_width);
- extra = width / ((gdouble) n_expand_lines);
- }
+ {
+ width = MAX (0, width - total_width);
+ extra = width / ((gdouble) n_expand_lines);
+ }
else
- width = 0;
-
+ width = 0;
+
x = area->x;
line = line_list;
while (line)
- {
- GtkAllocation col_allocation;
- Line *next_line = line->next;
-
- col_allocation.y = area->y;
- col_allocation.height = area->height;
- if (wbox->homogeneous)
- col_allocation.width = width;
- else
- {
- col_allocation.width = line->min_size;
-
- if (line->expand)
- col_allocation.width += extra;
- }
-
- col_allocation.x = x;
-
- x += col_allocation.width + wbox->hspacing;
- layout_col (wbox,
- &col_allocation,
- line->children,
- children_per_line,
- line->expand);
-
- g_slist_free (line->children);
- g_free (line);
- line = next_line;
- }
+ {
+ GtkAllocation col_allocation;
+ Line *next_line = line->next;
+
+ col_allocation.y = area->y;
+ col_allocation.height = area->height;
+ if (wbox->homogeneous)
+ col_allocation.width = width;
+ else
+ {
+ col_allocation.width = line->min_size;
+
+ if (line->expand)
+ col_allocation.width += extra;
+ }
+
+ col_allocation.x = x;
+
+ x += col_allocation.width + wbox->hspacing;
+ layout_col (wbox,
+ &col_allocation,
+ line->children,
+ children_per_line,
+ line->expand);
+
+ g_slist_free (line->children);
+ line = next_line;
+ }
+
+ g_slice_free_chain (Line, line_list, next);
}
}
static void
gtk_vwrap_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkAllocation area;
gint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
-
+
widget->allocation = *allocation;
area.y = allocation->y + border;
area.x = allocation->x + border;
area.height = MAX (1, (gint) allocation->height - border * 2);
area.width = MAX (1, (gint) allocation->width - border * 2);
-
+
/*<h2v-off>*/
/* g_print ("got: width %d, height %d\n",
allocation->width,
allocation->height);
*/
/*<h2v-on>*/
-
+
layout_cols (wbox, &area);
}
Modified: trunk/app/gtkvwrapbox.h
==============================================================================
--- trunk/app/gtkvwrapbox.h (original)
+++ trunk/app/gtkvwrapbox.h Fri Jul 18 22:00:55 2008
@@ -30,12 +30,12 @@
/* --- type macros --- */
-#define GTK_TYPE_VWRAP_BOX (gtk_vwrap_box_get_type ())
-#define GTK_VWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBox))
-#define GTK_VWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_VWRAP_BOX, GtkVWrapBoxClass))
-#define GTK_IS_VWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_VWRAP_BOX))
-#define GTK_IS_VWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_VWRAP_BOX))
-#define GTK_VWRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBoxClass))
+#define GTK_TYPE_VWRAP_BOX (gtk_vwrap_box_get_type ())
+#define GTK_VWRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBox))
+#define GTK_VWRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_VWRAP_BOX, GtkVWrapBoxClass))
+#define GTK_IS_VWRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_VWRAP_BOX))
+#define GTK_IS_VWRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_VWRAP_BOX))
+#define GTK_VWRAP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBoxClass))
/* --- typedefs --- */
@@ -47,7 +47,7 @@
struct _GtkVWrapBox
{
GtkWrapBox parent_widget;
-
+
/*<h2v-off>*/
guint max_child_width;
guint max_child_height;
@@ -61,7 +61,7 @@
/* --- prototypes --- */
-GtkType gtk_vwrap_box_get_type (void) G_GNUC_CONST;
+GType gtk_vwrap_box_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_vwrap_box_new (gboolean homogeneous);
Modified: trunk/app/gtkwrapbox.c
==============================================================================
--- trunk/app/gtkwrapbox.c (original)
+++ trunk/app/gtkwrapbox.c Fri Jul 18 22:00:55 2008
@@ -20,21 +20,24 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
#include "gtkwrapbox.h"
-#include <math.h>
-/* --- arguments --- */
+
+/* --- properties --- */
enum {
- ARG_0,
- ARG_HOMOGENEOUS,
- ARG_JUSTIFY,
- ARG_HSPACING,
- ARG_VSPACING,
- ARG_LINE_JUSTIFY,
- ARG_ASPECT_RATIO,
- ARG_CURRENT_RATIO,
- ARG_CHILD_LIMIT
+ PROP_0,
+ PROP_HOMOGENEOUS,
+ PROP_JUSTIFY,
+ PROP_HSPACING,
+ PROP_VSPACING,
+ PROP_LINE_JUSTIFY,
+ PROP_ASPECT_RATIO,
+ PROP_CURRENT_RATIO,
+ PROP_CHILD_LIMIT
};
+
enum {
CHILD_PROP_0,
CHILD_PROP_POSITION,
@@ -49,35 +52,37 @@
/* --- prototypes --- */
static void gtk_wrap_box_class_init (GtkWrapBoxClass *klass);
static void gtk_wrap_box_init (GtkWrapBox *wbox);
-static void gtk_wrap_box_get_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
-static void gtk_wrap_box_set_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
+static void gtk_wrap_box_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_wrap_box_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void gtk_wrap_box_set_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void gtk_wrap_box_get_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void gtk_wrap_box_map (GtkWidget *widget);
static void gtk_wrap_box_unmap (GtkWidget *widget);
static gint gtk_wrap_box_expose (GtkWidget *widget,
- GdkEventExpose *event);
+ GdkEventExpose *event);
static void gtk_wrap_box_add (GtkContainer *container,
- GtkWidget *widget);
+ GtkWidget *widget);
static void gtk_wrap_box_remove (GtkContainer *container,
- GtkWidget *widget);
+ GtkWidget *widget);
static void gtk_wrap_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GtkType gtk_wrap_box_child_type (GtkContainer *container);
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+static GType gtk_wrap_box_child_type (GtkContainer *container);
/* --- variables --- */
@@ -85,51 +90,53 @@
/* --- functions --- */
-GtkType
+GType
gtk_wrap_box_get_type (void)
{
- static GtkType wrap_box_type = 0;
-
- if (!wrap_box_type)
+ static GType wrap_box_type = 0;
+
+ if (! wrap_box_type)
{
- static const GtkTypeInfo wrap_box_info =
+ const GTypeInfo wrap_box_info =
{
- "GtkWrapBox",
- sizeof (GtkWrapBox),
- sizeof (GtkWrapBoxClass),
- (GtkClassInitFunc) gtk_wrap_box_class_init,
- (GtkObjectInitFunc) gtk_wrap_box_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ sizeof (GtkWrapBoxClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_wrap_box_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkWrapBox),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_wrap_box_init,
};
-
- wrap_box_type = gtk_type_unique (GTK_TYPE_CONTAINER, &wrap_box_info);
+
+ wrap_box_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkWrapBox",
+ &wrap_box_info, 0);
}
-
+
return wrap_box_type;
}
static void
gtk_wrap_box_class_init (GtkWrapBoxClass *class)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
-
- object_class = GTK_OBJECT_CLASS (class);
+
+ object_class = G_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
-
+
parent_class = g_type_class_peek_parent (class);
-
- object_class->set_arg = gtk_wrap_box_set_arg;
- object_class->get_arg = gtk_wrap_box_get_arg;
-
+
+ object_class->set_property = gtk_wrap_box_set_property;
+ object_class->get_property = gtk_wrap_box_get_property;
+
widget_class->map = gtk_wrap_box_map;
widget_class->unmap = gtk_wrap_box_unmap;
widget_class->expose_event = gtk_wrap_box_expose;
-
+
container_class->add = gtk_wrap_box_add;
container_class->remove = gtk_wrap_box_remove;
container_class->forall = gtk_wrap_box_forall;
@@ -138,55 +145,130 @@
container_class->get_child_property = gtk_wrap_box_get_child_property;
class->rlist_line_children = NULL;
-
- gtk_object_add_arg_type ("GtkWrapBox::homogeneous",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
- gtk_object_add_arg_type ("GtkWrapBox::justify",
- GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFY);
- gtk_object_add_arg_type ("GtkWrapBox::hspacing",
- GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_HSPACING);
- gtk_object_add_arg_type ("GtkWrapBox::vspacing",
- GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_VSPACING);
- gtk_object_add_arg_type ("GtkWrapBox::line_justify",
- GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_LINE_JUSTIFY);
- gtk_object_add_arg_type ("GtkWrapBox::aspect_ratio",
- GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_ASPECT_RATIO);
- gtk_object_add_arg_type ("GtkWrapBox::current_ratio",
- GTK_TYPE_FLOAT, GTK_ARG_READABLE, ARG_CURRENT_RATIO);
- gtk_object_add_arg_type ("GtkWrapBox::max_children_per_line",
- GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_CHILD_LIMIT);
-
- gtk_container_class_install_child_property (container_class, CHILD_PROP_POSITION,
- g_param_spec_int ("position", NULL, NULL,
- -1, G_MAXINT, 0,
- G_PARAM_READWRITE));
- gtk_container_class_install_child_property (container_class, CHILD_PROP_HEXPAND,
- g_param_spec_boolean ("hexpand", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE));
- gtk_container_class_install_child_property (container_class, CHILD_PROP_HFILL,
- g_param_spec_boolean ("hfill", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE));
- gtk_container_class_install_child_property (container_class, CHILD_PROP_VEXPAND,
- g_param_spec_boolean ("vexpand", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE));
- gtk_container_class_install_child_property (container_class, CHILD_PROP_VFILL,
- g_param_spec_boolean ("vfill", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE));
- gtk_container_class_install_child_property (container_class, CHILD_PROP_VFILL,
- g_param_spec_boolean ("wrapped", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_HOMOGENEOUS,
+ g_param_spec_boolean ("homogeneous",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_JUSTIFY,
+ g_param_spec_enum ("justify",
+ NULL,
+ NULL,
+ GTK_TYPE_JUSTIFICATION,
+ GTK_JUSTIFY_LEFT,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_HSPACING,
+ g_param_spec_uint ("hspacing",
+ NULL,
+ NULL,
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_VSPACING,
+ g_param_spec_uint ("vspacing",
+ NULL,
+ NULL,
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_LINE_JUSTIFY,
+ g_param_spec_enum ("line-justify",
+ NULL,
+ NULL,
+ GTK_TYPE_JUSTIFICATION,
+ GTK_JUSTIFY_BOTTOM,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_ASPECT_RATIO,
+ g_param_spec_float ("aspect-ratio",
+ NULL,
+ NULL,
+ 0.0,
+ G_MAXFLOAT,
+ 1.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_CURRENT_RATIO,
+ g_param_spec_float ("current-ratio",
+ NULL,
+ NULL,
+ 0.0,
+ G_MAXFLOAT,
+ 1.0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_CHILD_LIMIT,
+ g_param_spec_uint ("max-children-per-line",
+ NULL,
+ NULL,
+ 1,
+ 32767,
+ 32767,
+ G_PARAM_READWRITE));
+
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_POSITION,
+ g_param_spec_int ("position",
+ NULL,
+ NULL,
+ -1, G_MAXINT, 0,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_HEXPAND,
+ g_param_spec_boolean ("hexpand",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_HFILL,
+ g_param_spec_boolean ("hfill",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_VEXPAND,
+ g_param_spec_boolean ("vexpand",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_VFILL,
+ g_param_spec_boolean ("vfill",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_WRAPPED,
+ g_param_spec_boolean ("wrapped",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
}
static void
gtk_wrap_box_init (GtkWrapBox *wbox)
{
GTK_WIDGET_SET_FLAGS (wbox, GTK_NO_WINDOW);
-
+
wbox->homogeneous = FALSE;
wbox->hspacing = 0;
wbox->vspacing = 0;
@@ -194,101 +276,108 @@
wbox->line_justify = GTK_JUSTIFY_BOTTOM;
wbox->n_children = 0;
wbox->children = NULL;
- wbox->aspect_ratio = 1;
+ wbox->aspect_ratio = 1.0;
wbox->child_limit = 32767;
}
static void
-gtk_wrap_box_set_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id)
+gtk_wrap_box_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (object);
-
- switch (arg_id)
+
+ switch (property_id)
{
- case ARG_HOMOGENEOUS:
- gtk_wrap_box_set_homogeneous (wbox, GTK_VALUE_BOOL (*arg));
+ case PROP_HOMOGENEOUS:
+ gtk_wrap_box_set_homogeneous (wbox, g_value_get_boolean (value));
break;
- case ARG_JUSTIFY:
- gtk_wrap_box_set_justify (wbox, GTK_VALUE_ENUM (*arg));
+ case PROP_JUSTIFY:
+ gtk_wrap_box_set_justify (wbox, g_value_get_enum (value));
break;
- case ARG_LINE_JUSTIFY:
- gtk_wrap_box_set_line_justify (wbox, GTK_VALUE_ENUM (*arg));
+ case PROP_LINE_JUSTIFY:
+ gtk_wrap_box_set_line_justify (wbox, g_value_get_enum (value));
break;
- case ARG_HSPACING:
- gtk_wrap_box_set_hspacing (wbox, GTK_VALUE_UINT (*arg));
+ case PROP_HSPACING:
+ gtk_wrap_box_set_hspacing (wbox, g_value_get_uint (value));
break;
- case ARG_VSPACING:
- gtk_wrap_box_set_vspacing (wbox, GTK_VALUE_UINT (*arg));
+ case PROP_VSPACING:
+ gtk_wrap_box_set_vspacing (wbox, g_value_get_uint (value));
break;
- case ARG_ASPECT_RATIO:
- gtk_wrap_box_set_aspect_ratio (wbox, GTK_VALUE_FLOAT (*arg));
+ case PROP_ASPECT_RATIO:
+ gtk_wrap_box_set_aspect_ratio (wbox, g_value_get_float (value));
break;
- case ARG_CHILD_LIMIT:
- if (wbox->child_limit != GTK_VALUE_UINT (*arg))
- {
- wbox->child_limit = CLAMP (GTK_VALUE_UINT (*arg), 1, 32767);
- gtk_widget_queue_resize (GTK_WIDGET (wbox));
- }
+ case PROP_CHILD_LIMIT:
+ if (wbox->child_limit != g_value_get_uint (value))
+ gtk_widget_queue_resize (GTK_WIDGET (wbox));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
-gtk_wrap_box_get_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id)
+gtk_wrap_box_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (object);
GtkWidget *widget = GTK_WIDGET (object);
-
- switch (arg_id)
+
+ switch (property_id)
{
- case ARG_HOMOGENEOUS:
- GTK_VALUE_BOOL (*arg) = wbox->homogeneous;
+ case PROP_HOMOGENEOUS:
+ g_value_set_boolean (value, wbox->homogeneous);
break;
- case ARG_JUSTIFY:
- GTK_VALUE_ENUM (*arg) = wbox->justify;
+ case PROP_JUSTIFY:
+ g_value_set_enum (value, wbox->justify);
break;
- case ARG_LINE_JUSTIFY:
- GTK_VALUE_ENUM (*arg) = wbox->line_justify;
+ case PROP_LINE_JUSTIFY:
+ g_value_set_enum (value, wbox->line_justify);
break;
- case ARG_HSPACING:
- GTK_VALUE_UINT (*arg) = wbox->hspacing;
+ case PROP_HSPACING:
+ g_value_set_uint (value, wbox->hspacing);
break;
- case ARG_VSPACING:
- GTK_VALUE_UINT (*arg) = wbox->vspacing;
+ case PROP_VSPACING:
+ g_value_set_uint (value, wbox->vspacing);
break;
- case ARG_ASPECT_RATIO:
- GTK_VALUE_FLOAT (*arg) = wbox->aspect_ratio;
+ case PROP_ASPECT_RATIO:
+ g_value_set_float (value, wbox->aspect_ratio);
break;
- case ARG_CURRENT_RATIO:
- GTK_VALUE_FLOAT (*arg) = (((gfloat) widget->allocation.width) /
- ((gfloat) widget->allocation.height));
+ case PROP_CURRENT_RATIO:
+ g_value_set_float (value, (((gfloat) widget->allocation.width) /
+ ((gfloat) widget->allocation.height)));
break;
- case ARG_CHILD_LIMIT:
- GTK_VALUE_UINT (*arg) = wbox->child_limit;
+ case PROP_CHILD_LIMIT:
+ g_value_set_uint (value, wbox->child_limit);
break;
default:
- arg->type = GTK_TYPE_INVALID;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_wrap_box_set_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
- gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE, wrapped = FALSE;
-
+ gboolean hexpand = FALSE, hfill = FALSE;
+ gboolean vexpand = FALSE, vfill = FALSE;
+ gboolean wrapped = FALSE;
+
if (property_id != CHILD_PROP_POSITION)
- gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill, &wrapped);
-
+ gtk_wrap_box_query_child_packing (wbox, child,
+ &hexpand, &hfill,
+ &vexpand, &vfill,
+ &wrapped);
+
switch (property_id)
{
case CHILD_PROP_POSITION:
@@ -296,33 +385,33 @@
break;
case CHILD_PROP_HEXPAND:
gtk_wrap_box_set_child_packing (wbox, child,
- g_value_get_boolean (value), hfill,
- vexpand, vfill,
- wrapped);
+ g_value_get_boolean (value), hfill,
+ vexpand, vfill,
+ wrapped);
break;
case CHILD_PROP_HFILL:
gtk_wrap_box_set_child_packing (wbox, child,
- hexpand, g_value_get_boolean (value),
- vexpand, vfill,
- wrapped);
+ hexpand, g_value_get_boolean (value),
+ vexpand, vfill,
+ wrapped);
break;
case CHILD_PROP_VEXPAND:
gtk_wrap_box_set_child_packing (wbox, child,
- hexpand, hfill,
- g_value_get_boolean (value), vfill,
- wrapped);
+ hexpand, hfill,
+ g_value_get_boolean (value), vfill,
+ wrapped);
break;
case CHILD_PROP_VFILL:
gtk_wrap_box_set_child_packing (wbox, child,
- hexpand, hfill,
- vexpand, g_value_get_boolean (value),
- wrapped);
+ hexpand, hfill,
+ vexpand, g_value_get_boolean (value),
+ wrapped);
break;
case CHILD_PROP_WRAPPED:
gtk_wrap_box_set_child_packing (wbox, child,
- hexpand, hfill,
- vexpand, vfill,
- g_value_get_boolean (value));
+ hexpand, hfill,
+ vexpand, vfill,
+ g_value_get_boolean (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
@@ -332,17 +421,22 @@
static void
gtk_wrap_box_get_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
- gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE, wrapped = FALSE;
-
+ gboolean hexpand = FALSE, hfill = FALSE;
+ gboolean vexpand = FALSE, vfill = FALSE;
+ gboolean wrapped = FALSE;
+
if (property_id != CHILD_PROP_POSITION)
- gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill, &wrapped);
-
+ gtk_wrap_box_query_child_packing (wbox, child,
+ &hexpand, &hfill,
+ &vexpand, &vfill,
+ &wrapped);
+
switch (property_id)
{
GtkWrapBoxChild *child_info;
@@ -350,11 +444,11 @@
case CHILD_PROP_POSITION:
i = 0;
for (child_info = wbox->children; child_info; child_info = child_info->next)
- {
- if (child_info->widget == child)
- break;
- i += 1;
- }
+ {
+ if (child_info->widget == child)
+ break;
+ i += 1;
+ }
g_value_set_int (value, child_info ? i : -1);
break;
case CHILD_PROP_HEXPAND:
@@ -378,18 +472,18 @@
}
}
-static GtkType
-gtk_wrap_box_child_type (GtkContainer *container)
+static GType
+gtk_wrap_box_child_type (GtkContainer *container)
{
return GTK_TYPE_WIDGET;
}
void
gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
- gboolean homogeneous)
+ gboolean homogeneous)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
+
homogeneous = homogeneous != FALSE;
if (wbox->homogeneous != homogeneous)
{
@@ -400,10 +494,10 @@
void
gtk_wrap_box_set_hspacing (GtkWrapBox *wbox,
- guint hspacing)
+ guint hspacing)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
+
if (wbox->hspacing != hspacing)
{
wbox->hspacing = hspacing;
@@ -413,10 +507,10 @@
void
gtk_wrap_box_set_vspacing (GtkWrapBox *wbox,
- guint vspacing)
+ guint vspacing)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
+
if (wbox->vspacing != vspacing)
{
wbox->vspacing = vspacing;
@@ -426,11 +520,11 @@
void
gtk_wrap_box_set_justify (GtkWrapBox *wbox,
- GtkJustification justify)
+ GtkJustification justify)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (justify <= GTK_JUSTIFY_FILL);
-
+
if (wbox->justify != justify)
{
wbox->justify = justify;
@@ -440,11 +534,11 @@
void
gtk_wrap_box_set_line_justify (GtkWrapBox *wbox,
- GtkJustification line_justify)
+ GtkJustification line_justify)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (line_justify <= GTK_JUSTIFY_FILL);
-
+
if (wbox->line_justify != line_justify)
{
wbox->line_justify = line_justify;
@@ -454,12 +548,12 @@
void
gtk_wrap_box_set_aspect_ratio (GtkWrapBox *wbox,
- gfloat aspect_ratio)
+ gfloat aspect_ratio)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
+
aspect_ratio = CLAMP (aspect_ratio, 1.0 / 256.0, 256.0);
-
+
if (wbox->aspect_ratio != aspect_ratio)
{
wbox->aspect_ratio = aspect_ratio;
@@ -469,11 +563,11 @@
void
gtk_wrap_box_pack (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean hexpand,
- gboolean hfill,
- gboolean vexpand,
- gboolean vfill)
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
@@ -484,20 +578,21 @@
void
gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean hexpand,
- gboolean hfill,
- gboolean vexpand,
- gboolean vfill,
- gboolean wrapped)
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill,
+ gboolean wrapped)
{
GtkWrapBoxChild *child_info;
-
+
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == NULL);
-
- child_info = g_new (GtkWrapBoxChild, 1);
+
+ child_info = g_slice_new (GtkWrapBoxChild);
+
child_info->widget = child;
child_info->hexpand = hexpand ? TRUE : FALSE;
child_info->hfill = hfill ? TRUE : FALSE;
@@ -508,127 +603,127 @@
if (wbox->children)
{
GtkWrapBoxChild *last = wbox->children;
-
+
while (last->next)
- last = last->next;
+ last = last->next;
last->next = child_info;
}
else
wbox->children = child_info;
wbox->n_children++;
-
+
gtk_widget_set_parent (child, GTK_WIDGET (wbox));
-
+
if (GTK_WIDGET_REALIZED (wbox))
gtk_widget_realize (child);
-
+
if (GTK_WIDGET_VISIBLE (wbox) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (wbox))
- gtk_widget_map (child);
-
+ gtk_widget_map (child);
+
gtk_widget_queue_resize (child);
}
}
void
gtk_wrap_box_reorder_child (GtkWrapBox *wbox,
- GtkWidget *child,
- gint position)
+ GtkWidget *child,
+ gint position)
{
GtkWrapBoxChild *child_info, *last = NULL;
-
+
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
-
+
for (child_info = wbox->children; child_info; last = child_info, child_info = last->next)
if (child_info->widget == child)
break;
-
+
if (child_info && wbox->children->next)
{
GtkWrapBoxChild *tmp;
-
+
if (last)
- last->next = child_info->next;
+ last->next = child_info->next;
else
- wbox->children = child_info->next;
-
+ wbox->children = child_info->next;
+
last = NULL;
tmp = wbox->children;
while (position && tmp->next)
- {
- position--;
- last = tmp;
- tmp = last->next;
- }
-
+ {
+ position--;
+ last = tmp;
+ tmp = last->next;
+ }
+
if (position)
- {
- tmp->next = child_info;
- child_info->next = NULL;
- }
+ {
+ tmp->next = child_info;
+ child_info->next = NULL;
+ }
else
- {
- child_info->next = tmp;
- if (last)
- last->next = child_info;
- else
- wbox->children = child_info;
- }
-
+ {
+ child_info->next = tmp;
+ if (last)
+ last->next = child_info;
+ else
+ wbox->children = child_info;
+ }
+
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
- gtk_widget_queue_resize (child);
+ gtk_widget_queue_resize (child);
}
}
void
gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean *hexpand,
- gboolean *hfill,
- gboolean *vexpand,
- gboolean *vfill,
- gboolean *wrapped)
+ GtkWidget *child,
+ gboolean *hexpand,
+ gboolean *hfill,
+ gboolean *vexpand,
+ gboolean *vfill,
+ gboolean *wrapped)
{
GtkWrapBoxChild *child_info;
-
+
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
-
+
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
-
+
if (child_info)
{
if (hexpand)
- *hexpand = child_info->hexpand;
+ *hexpand = child_info->hexpand;
if (hfill)
- *hfill = child_info->hfill;
+ *hfill = child_info->hfill;
if (vexpand)
- *vexpand = child_info->vexpand;
+ *vexpand = child_info->vexpand;
if (vfill)
- *vfill = child_info->vfill;
+ *vfill = child_info->vfill;
if (wrapped)
- *wrapped = child_info->wrapped;
+ *wrapped = child_info->wrapped;
}
}
void
gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean hexpand,
- gboolean hfill,
- gboolean vexpand,
- gboolean vfill,
- gboolean wrapped)
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill,
+ gboolean wrapped)
{
GtkWrapBoxChild *child_info;
-
+
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
-
+
hexpand = hexpand != FALSE;
hfill = hfill != FALSE;
vexpand = vexpand != FALSE;
@@ -638,7 +733,7 @@
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
-
+
if (child_info &&
(child_info->hexpand != hexpand || child_info->vexpand != vexpand ||
child_info->hfill != hfill || child_info->vfill != vfill ||
@@ -649,15 +744,15 @@
child_info->vexpand = vexpand;
child_info->vfill = vfill;
child_info->wrapped = wrapped;
-
+
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
- gtk_widget_queue_resize (child);
+ gtk_widget_queue_resize (child);
}
}
guint*
gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
- guint *_n_lines)
+ guint *_n_lines)
{
GtkWrapBoxChild *next_child = NULL;
GtkAllocation area, *allocation;
@@ -678,10 +773,10 @@
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
- &next_child,
- &area,
- &max_child_size,
- &expand_line);
+ &next_child,
+ &area,
+ &max_child_size,
+ &expand_line);
while (slist)
{
guint l = n_lines++;
@@ -691,10 +786,10 @@
g_slist_free (slist);
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
- &next_child,
- &area,
- &max_child_size,
- &expand_line);
+ &next_child,
+ &area,
+ &max_child_size,
+ &expand_line);
}
if (_n_lines)
@@ -708,12 +803,12 @@
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
-
+
GTK_WIDGET_SET_FLAGS (wbox, GTK_MAPPED);
-
+
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget) &&
- !GTK_WIDGET_MAPPED (child->widget))
+ !GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
@@ -722,59 +817,59 @@
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
-
+
GTK_WIDGET_UNSET_FLAGS (wbox, GTK_MAPPED);
-
+
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget) &&
- GTK_WIDGET_MAPPED (child->widget))
+ GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
static gint
gtk_wrap_box_expose (GtkWidget *widget,
- GdkEventExpose *event)
+ GdkEventExpose *event)
{
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
static void
gtk_wrap_box_add (GtkContainer *container,
- GtkWidget *widget)
+ GtkWidget *widget)
{
gtk_wrap_box_pack (GTK_WRAP_BOX (container), widget, FALSE, TRUE, FALSE, TRUE);
}
static void
gtk_wrap_box_remove (GtkContainer *container,
- GtkWidget *widget)
+ GtkWidget *widget)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
GtkWrapBoxChild *child, *last = NULL;
-
+
child = wbox->children;
while (child)
{
if (child->widget == widget)
- {
- gboolean was_visible;
-
- was_visible = GTK_WIDGET_VISIBLE (widget);
- gtk_widget_unparent (widget);
-
- if (last)
- last->next = child->next;
- else
- wbox->children = child->next;
- g_free (child);
- wbox->n_children--;
-
- if (was_visible)
- gtk_widget_queue_resize (GTK_WIDGET (container));
-
- break;
- }
-
+ {
+ gboolean was_visible;
+
+ was_visible = GTK_WIDGET_VISIBLE (widget);
+ gtk_widget_unparent (widget);
+
+ if (last)
+ last->next = child->next;
+ else
+ wbox->children = child->next;
+ g_slice_free (GtkWrapBoxChild, child);
+ wbox->n_children--;
+
+ if (was_visible)
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+
+ break;
+ }
+
last = child;
child = last->next;
}
@@ -782,20 +877,20 @@
static void
gtk_wrap_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
GtkWrapBoxChild *child;
-
+
child = wbox->children;
while (child)
{
GtkWidget *widget = child->widget;
-
+
child = child->next;
-
+
callback (widget, callback_data);
}
}
Modified: trunk/app/gtkwrapbox.h
==============================================================================
--- trunk/app/gtkwrapbox.h (original)
+++ trunk/app/gtkwrapbox.h Fri Jul 18 22:00:55 2008
@@ -30,12 +30,12 @@
/* --- type macros --- */
-#define GTK_TYPE_WRAP_BOX (gtk_wrap_box_get_type ())
-#define GTK_WRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBox))
-#define GTK_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
-#define GTK_IS_WRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_WRAP_BOX))
-#define GTK_IS_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WRAP_BOX))
-#define GTK_WRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
+#define GTK_TYPE_WRAP_BOX (gtk_wrap_box_get_type ())
+#define GTK_WRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBox))
+#define GTK_WRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
+#define GTK_IS_WRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WRAP_BOX))
+#define GTK_IS_WRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WRAP_BOX))
+#define GTK_WRAP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
/* --- typedefs --- */
@@ -47,7 +47,7 @@
struct _GtkWrapBox
{
GtkContainer container;
-
+
guint homogeneous : 1;
guint justify : 4;
guint line_justify : 4;
@@ -63,10 +63,10 @@
GtkContainerClass parent_class;
GSList* (*rlist_line_children) (GtkWrapBox *wbox,
- GtkWrapBoxChild **child_p,
- GtkAllocation *area,
- guint *max_child_size,
- gboolean *expand_line);
+ GtkWrapBoxChild **child_p,
+ GtkAllocation *area,
+ guint *max_child_size,
+ gboolean *expand_line);
};
struct _GtkWrapBoxChild
{
@@ -76,7 +76,7 @@
guint vexpand : 1;
guint vfill : 1;
guint wrapped : 1;
-
+
GtkWrapBoxChild *next;
};
#define GTK_JUSTIFY_TOP GTK_JUSTIFY_LEFT
@@ -84,51 +84,51 @@
/* --- prototypes --- */
-GtkType gtk_wrap_box_get_type (void) G_GNUC_CONST;
-void gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
- gboolean homogeneous);
-void gtk_wrap_box_set_hspacing (GtkWrapBox *wbox,
- guint hspacing);
-void gtk_wrap_box_set_vspacing (GtkWrapBox *wbox,
- guint vspacing);
-void gtk_wrap_box_set_justify (GtkWrapBox *wbox,
- GtkJustification justify);
-void gtk_wrap_box_set_line_justify (GtkWrapBox *wbox,
- GtkJustification line_justify);
-void gtk_wrap_box_set_aspect_ratio (GtkWrapBox *wbox,
- gfloat aspect_ratio);
-void gtk_wrap_box_pack (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean hexpand,
- gboolean hfill,
- gboolean vexpand,
- gboolean vfill);
-void gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean hexpand,
- gboolean hfill,
- gboolean vexpand,
- gboolean vfill,
- gboolean wrapped);
+GType gtk_wrap_box_get_type (void) G_GNUC_CONST;
+void gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
+ gboolean homogeneous);
+void gtk_wrap_box_set_hspacing (GtkWrapBox *wbox,
+ guint hspacing);
+void gtk_wrap_box_set_vspacing (GtkWrapBox *wbox,
+ guint vspacing);
+void gtk_wrap_box_set_justify (GtkWrapBox *wbox,
+ GtkJustification justify);
+void gtk_wrap_box_set_line_justify (GtkWrapBox *wbox,
+ GtkJustification line_justify);
+void gtk_wrap_box_set_aspect_ratio (GtkWrapBox *wbox,
+ gfloat aspect_ratio);
+void gtk_wrap_box_pack (GtkWrapBox *wbox,
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill);
+void gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill,
+ gboolean wrapped);
void gtk_wrap_box_reorder_child (GtkWrapBox *wbox,
- GtkWidget *child,
- gint position);
+ GtkWidget *child,
+ gint position);
void gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean *hexpand,
- gboolean *hfill,
- gboolean *vexpand,
- gboolean *vfill,
- gboolean *wrapped);
+ GtkWidget *child,
+ gboolean *hexpand,
+ gboolean *hfill,
+ gboolean *vexpand,
+ gboolean *vfill,
+ gboolean *wrapped);
void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean hexpand,
- gboolean hfill,
- gboolean vexpand,
- gboolean vfill,
- gboolean wrapped);
-guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
- guint *n_lines);
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill,
+ gboolean wrapped);
+guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
+ guint *n_lines);
G_END_DECLS
Modified: trunk/app/interface.c
==============================================================================
--- trunk/app/interface.c (original)
+++ trunk/app/interface.c Fri Jul 18 22:00:55 2008
@@ -18,6 +18,7 @@
#include <config.h>
+#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
#include <gtk/gtk.h>
#include <stdio.h>
@@ -397,7 +398,7 @@
G_CALLBACK(zoom_activate_callback),
ddisp);
gtk_box_pack_start_defaults(GTK_BOX(combo), entry);
- gtk_object_set_user_data(GTK_OBJECT(combo), entry);
+ g_object_set_data (G_OBJECT(combo), "user_data", entry);
gtk_entry_set_width_chars(GTK_ENTRY(entry), 8);
gtk_widget_show(entry);
@@ -406,7 +407,7 @@
arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
gtk_container_add(GTK_CONTAINER(button), arrow);
gtk_box_pack_start_defaults(GTK_BOX(combo), button);
- gtk_object_set_user_data(GTK_OBJECT(combo), entry);
+ g_object_set_data (G_OBJECT(combo), "user_data", entry);
gtk_widget_show_all(button);
menu = gtk_menu_new();
@@ -746,7 +747,7 @@
} else {
ddisp->shell = gtk_event_box_new ();
}
- gtk_object_set_user_data (GTK_OBJECT (ddisp->shell), (gpointer) ddisp);
+ g_object_set_data (G_OBJECT (ddisp->shell), "user_data", (gpointer) ddisp);
gtk_widget_set_events (ddisp->shell,
GDK_POINTER_MOTION_MASK |
@@ -865,7 +866,7 @@
g_signal_connect (GTK_OBJECT (ddisp->canvas), "drag_data_received",
G_CALLBACK(display_data_received_callback), ddisp);
- gtk_object_set_user_data (GTK_OBJECT (ddisp->canvas), (gpointer) ddisp);
+ g_object_set_data (G_OBJECT (ddisp->canvas), "user_data", (gpointer) ddisp);
/* pack all the widgets */
gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1,
Modified: trunk/app/interface.h
==============================================================================
--- trunk/app/interface.h (original)
+++ trunk/app/interface.h Fri Jul 18 22:00:55 2008
@@ -106,7 +106,9 @@
void tool_select_update (GtkWidget *w, gpointer data);
void fill_sheet_menu(void);
+#ifndef GTK_DISABLE_DEPRECATED
extern GtkTooltips *tool_tips;
+#endif
void close_notebook_page_callback (GtkButton *button, gpointer user_data);
Modified: trunk/app/layer_dialog.c
==============================================================================
--- trunk/app/layer_dialog.c (original)
+++ trunk/app/layer_dialog.c Fri Jul 18 22:00:55 2008
@@ -29,6 +29,7 @@
#include <assert.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
+#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "intl.h"
@@ -40,6 +41,54 @@
#include "dia-app-icons.h"
+/* DiaLayerWidget: */
+#define DIA_LAYER_WIDGET(obj) \
+ GTK_CHECK_CAST (obj, dia_layer_widget_get_type (), DiaLayerWidget)
+#define DIA_LAYER_WIDGET_CLASS(klass) \
+ GTK_CHECK_CLASS_CAST (klass, dia_layer_widget_get_type (), DiaLayerWidgetClass)
+#define IS_DIA_LAYER_WIDGET(obj) \
+ GTK_CHECK_TYPE (obj, dia_layer_widget_get_type ())
+
+typedef struct _DiaLayerWidgetClass DiaLayerWidgetClass;
+typedef struct _EditLayerDialog EditLayerDialog;
+
+struct _DiaLayerWidget
+{
+ GtkListItem list_item;
+
+ Diagram *dia;
+ Layer *layer;
+
+ GtkWidget *visible;
+ GtkWidget *connectable;
+ GtkWidget *label;
+
+ EditLayerDialog *edit_dialog;
+
+ /** If true, the user has set this layers connectivity to on
+ * while it was not selected.
+ */
+ gboolean connect_on;
+ /** If true, the user has set this layers connectivity to off
+ * while it was selected.
+ */
+ gboolean connect_off;
+};
+
+struct _EditLayerDialog {
+ GtkWidget *dialog;
+ GtkWidget *name_entry;
+ DiaLayerWidget *layer_widget;
+};
+
+
+struct _DiaLayerWidgetClass
+{
+ GtkListItemClass parent_class;
+};
+
+GtkType dia_layer_widget_get_type(void);
+
struct LayerDialog {
GtkWidget *dialog;
GtkWidget *diagram_omenu;
Modified: trunk/app/layer_dialog.h
==============================================================================
--- trunk/app/layer_dialog.h (original)
+++ trunk/app/layer_dialog.h Fri Jul 18 22:00:55 2008
@@ -30,54 +30,8 @@
/* Integrated UI component */
GtkWidget * create_layer_view_widget (void);
-/* DiaLayerWidget: */
-#define DIA_LAYER_WIDGET(obj) \
- GTK_CHECK_CAST (obj, dia_layer_widget_get_type (), DiaLayerWidget)
-#define DIA_LAYER_WIDGET_CLASS(klass) \
- GTK_CHECK_CLASS_CAST (klass, dia_layer_widget_get_type (), DiaLayerWidgetClass)
-#define IS_DIA_LAYER_WIDGET(obj) \
- GTK_CHECK_TYPE (obj, dia_layer_widget_get_type ())
-
typedef struct _DiaLayerWidget DiaLayerWidget;
-typedef struct _DiaLayerWidgetClass DiaLayerWidgetClass;
-typedef struct _EditLayerDialog EditLayerDialog;
-
-struct _DiaLayerWidget
-{
- GtkListItem list_item;
-
- Diagram *dia;
- Layer *layer;
-
- GtkWidget *visible;
- GtkWidget *connectable;
- GtkWidget *label;
-
- EditLayerDialog *edit_dialog;
-
- /** If true, the user has set this layers connectivity to on
- * while it was not selected.
- */
- gboolean connect_on;
- /** If true, the user has set this layers connectivity to off
- * while it was selected.
- */
- gboolean connect_off;
-};
-
-struct _EditLayerDialog {
- GtkWidget *dialog;
- GtkWidget *name_entry;
- DiaLayerWidget *layer_widget;
-};
-
-
-struct _DiaLayerWidgetClass
-{
- GtkListItemClass parent_class;
-};
-GtkType dia_layer_widget_get_type(void);
GtkWidget* dia_layer_widget_new(Diagram *dia, Layer *layer);
void dia_layer_set_layer(DiaLayerWidget *widget, Diagram *dia, Layer *layer);
void dia_layer_update_from_layer(DiaLayerWidget *widget);
Modified: trunk/app/linewidth_area.c
==============================================================================
--- trunk/app/linewidth_area.c (original)
+++ trunk/app/linewidth_area.c Fri Jul 18 22:00:55 2008
@@ -190,8 +190,7 @@
event_box = gtk_event_box_new();
linewidth_area = gtk_drawing_area_new ();
- gtk_drawing_area_size (GTK_DRAWING_AREA (linewidth_area),
- AREA_WIDTH, AREA_HEIGHT);
+ gtk_widget_set_size_request (linewidth_area, AREA_WIDTH, AREA_HEIGHT);
gtk_widget_set_events (linewidth_area, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
g_signal_connect (GTK_OBJECT (linewidth_area), "event",
G_CALLBACK(linewidth_area_events),
@@ -205,8 +204,9 @@
}
static void
-get_current_line_width() {
- float newvalue = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(linewidth_button));
+get_current_line_width()
+{
+ float newvalue = gtk_spin_button_get_value (GTK_SPIN_BUTTON (linewidth_button));
active_linewidth = linewidth_number_from_width(newvalue);
linewidth_area_draw(GTK_WIDGET(linewidth_area_widget));
attributes_set_default_linewidth(newvalue);
Modified: trunk/app/makefile.msc
==============================================================================
--- trunk/app/makefile.msc (original)
+++ trunk/app/makefile.msc Fri Jul 18 22:00:55 2008
@@ -7,7 +7,7 @@
# not yet
PKG_CFLAGS = -FImsvc_recommended_pragmas.h \
-DWIN32 -DHAVE_LIBART -DHAVE_LIBPNG \
- -I.. $(GLIB_CFLAGS) $(GTK2_CFLAGS) \
+ -I.. -DGTK_DISABLE_DEPRECATED $(GLIB_CFLAGS) $(GTK2_CFLAGS) \
!IFDEF USEFT2
-DHAVE_FREETYPE $(FREETYPE2_CFLAGS) \
!ENDIF
Modified: trunk/app/menus.c
==============================================================================
--- trunk/app/menus.c (original)
+++ trunk/app/menus.c Fri Jul 18 22:00:55 2008
@@ -21,6 +21,7 @@
#include <config.h>
#endif
+#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
Modified: trunk/app/navigation.c
==============================================================================
--- trunk/app/navigation.c (original)
+++ trunk/app/navigation.c Fri Jul 18 22:00:55 2008
@@ -206,7 +206,7 @@
/*drawing area*/
drawing_area = gtk_drawing_area_new ();
- gtk_drawing_area_size (GTK_DRAWING_AREA(drawing_area), nav->width, nav->height);
+ gtk_widget_set_size_request (drawing_area, nav->width, nav->height);
gtk_widget_set_events (drawing_area, 0
| GDK_EXPOSURE_MASK
Modified: trunk/app/pagesetup.c
==============================================================================
--- trunk/app/pagesetup.c (original)
+++ trunk/app/pagesetup.c Fri Jul 18 22:00:55 2008
@@ -89,8 +89,7 @@
G_CALLBACK (pagesetup_respond), ps);
/* destroy ps when the dialog is closed */
- gtk_object_set_data_full(GTK_OBJECT(ps->window), "pagesetup", ps,
- (GtkDestroyNotify)g_free);
+ g_datalist_set_data_full (&G_OBJECT (ps->window)->qdata, "pagesetup", ps, g_free);
ps->paper = dia_page_layout_new();
dia_page_layout_set_paper(DIA_PAGE_LAYOUT(ps->paper), dia->data->paper.name);
@@ -139,7 +138,7 @@
if (dwidth <= 0.0 || dheight <= 0.0)
return;
- DIA_PAGE_LAYOUT(ps->paper)->block_changed = TRUE;
+ dia_page_layout_set_changed (DIA_PAGE_LAYOUT(ps->paper), TRUE);
cur_scaling = dia_page_layout_get_scaling(DIA_PAGE_LAYOUT(ps->paper));
dia_page_layout_get_effective_area(DIA_PAGE_LAYOUT(ps->paper),
@@ -160,7 +159,7 @@
dia_page_layout_set_fit_dims(DIA_PAGE_LAYOUT(ps->paper), fitw, fith);
}
- DIA_PAGE_LAYOUT(ps->paper)->block_changed = FALSE;
+ dia_page_layout_set_changed (DIA_PAGE_LAYOUT(ps->paper), FALSE);
}
/* This affects the actual setup. It should only be called when
Modified: trunk/app/preferences.c
==============================================================================
--- trunk/app/preferences.c (original)
+++ trunk/app/preferences.c Fri Jul 18 22:00:55 2008
@@ -361,9 +361,7 @@
break;
}
if (names == NULL) return;
- gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
- gtk_menu_set_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(widget))), index);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(widget))))), TRUE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), index);
break;
}
case PREF_STRING:
@@ -390,13 +388,13 @@
case PREF_REAL:
case PREF_UREAL:
*((real *)ptr) = (real)
- gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(widget));
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON(widget));
break;
case PREF_COLOUR:
dia_color_selector_get_color(widget, (Color *)ptr);
break;
case PREF_CHOICE: {
- int index = gtk_option_menu_get_history(GTK_OPTION_MENU(widget));
+ int index = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
GList *names = (data->choice_list_function)();
*((gchar **)ptr) = g_strdup((gchar *)g_list_nth_data(names, index));
break;
@@ -438,7 +436,7 @@
1.0, 10.0, 10.0 ));
widget = gtk_spin_button_new (adj, 1.0, 0);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(widget), TRUE);
- gtk_widget_set_usize(widget, 80, -1);
+ gtk_widget_set_size_request (widget, 80, -1);
break;
case PREF_UINT:
adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0,
@@ -446,7 +444,7 @@
1.0, 10.0, 10.0 ));
widget = gtk_spin_button_new (adj, 1.0, 0);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(widget), TRUE);
- gtk_widget_set_usize(widget, 80, -1);
+ gtk_widget_set_size_request (widget, 80, -1);
break;
case PREF_REAL:
adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0,
@@ -454,7 +452,7 @@
1.0, 10.0, 10.0 ));
widget = gtk_spin_button_new (adj, 1.0, 3);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(widget), TRUE);
- gtk_widget_set_usize(widget, 80, -1);
+ gtk_widget_set_size_request (widget, 80, -1);
break;
case PREF_UREAL:
adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0,
@@ -462,7 +460,7 @@
1.0, 10.0, 10.0 ));
widget = gtk_spin_button_new (adj, 1.0, 3);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(widget), TRUE);
- gtk_widget_set_usize(widget, 80, -1);
+ gtk_widget_set_size_request (widget, 80, -1);
break;
case PREF_COLOUR:
widget = dia_color_selector_new();
@@ -471,20 +469,14 @@
widget = gtk_entry_new();
break;
case PREF_CHOICE: {
- GtkWidget *menu;
GList *names;
GSList *group = NULL;
- widget = gtk_option_menu_new();
- menu = gtk_menu_new();
- for (names = (data->choice_list_function)(); names != NULL;
+ widget = gtk_combo_box_new_text ();
+ for (names = (data->choice_list_function)();
+ names != NULL;
names = g_list_next(names)) {
- GtkWidget *menuitem =
- gtk_radio_menu_item_new_with_label(group, (gchar *)names->data);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
- group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), (gchar *)names->data);
}
- gtk_option_menu_set_menu(GTK_OPTION_MENU(widget), menu);
- gtk_widget_show_all(menu);
break;
}
case PREF_NONE:
Modified: trunk/app/properties.c
==============================================================================
--- trunk/app/properties.c (original)
+++ trunk/app/properties.c Fri Jul 18 22:00:55 2008
@@ -80,8 +80,7 @@
no_properties_dialog = gtk_label_new(_("This object has no properties."));
gtk_widget_show (no_properties_dialog);
- g_object_ref(G_OBJECT(no_properties_dialog));
- gtk_object_sink(GTK_OBJECT(no_properties_dialog));
+ g_object_ref_sink (G_OBJECT (no_properties_dialog));
}
static gint
Modified: trunk/app/sheets.c
==============================================================================
--- trunk/app/sheets.c (original)
+++ trunk/app/sheets.c Fri Jul 18 22:00:55 2008
@@ -22,6 +22,7 @@
#include <string.h>
+#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu */
#ifdef GNOME
#include <gnome.h>
#else
Modified: trunk/app/sheets.h
==============================================================================
--- trunk/app/sheets.h (original)
+++ trunk/app/sheets.h Fri Jul 18 22:00:55 2008
@@ -72,7 +72,9 @@
extern GtkWidget *sheets_dialog;
extern GtkWidget *sheets_dialog_optionmenu_menu;
+#ifndef GTK_DISABLE_DEPRECATED
extern GtkTooltips *sheets_dialog_tooltips;
+#endif
SheetObjectMod *sheets_append_sheet_object_mod(SheetObject *so, SheetMod *sm);
SheetMod *sheets_append_sheet_mods(Sheet *sheet);
Modified: trunk/app/sheets_dialog.c
==============================================================================
--- trunk/app/sheets_dialog.c (original)
+++ trunk/app/sheets_dialog.c Fri Jul 18 22:00:55 2008
@@ -36,6 +36,7 @@
#endif
#include <string.h>
+#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu, ... */
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
Modified: trunk/app/sheets_dialog_callbacks.c
==============================================================================
--- trunk/app/sheets_dialog_callbacks.c (original)
+++ trunk/app/sheets_dialog_callbacks.c Fri Jul 18 22:00:55 2008
@@ -47,6 +47,7 @@
#include <glib/gstdio.h>
#include <gmodule.h>
+#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu */
#ifdef GNOME
#include <gnome.h>
#else
Modified: trunk/app/splash.c
==============================================================================
--- trunk/app/splash.c (original)
+++ trunk/app/splash.c Fri Jul 18 22:00:55 2008
@@ -1,5 +1,6 @@
#include <config.h>
+#undef GTK_DISABLE_DEPRECATED /* GtkPixmap */
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
Modified: trunk/lib/diaarrowchooser.c
==============================================================================
--- trunk/lib/diaarrowchooser.c (original)
+++ trunk/lib/diaarrowchooser.c Fri Jul 18 22:00:55 2008
@@ -22,6 +22,7 @@
/** \file diaarrowchooser.c A widget to choose arrowhead. This only select arrowhead, not width and height.
* \ingroup diawidgets
*/
+#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
#include <gtk/gtk.h>
#include <config.h>
Modified: trunk/lib/diaarrowchooser.h
==============================================================================
--- trunk/lib/diaarrowchooser.h (original)
+++ trunk/lib/diaarrowchooser.h Fri Jul 18 22:00:55 2008
@@ -92,7 +92,13 @@
GtkWidget *dia_arrow_chooser_new (gboolean left,
DiaChangeArrowCallback callback,
- gpointer user_data, GtkTooltips *tool_tips);
+ gpointer user_data,
+#ifndef GTK_DISABLE_DEPRECATED
+ GtkTooltips *tool_tips
+#else
+ gpointer tool_tips
+#endif
+ );
void dia_arrow_chooser_set_arrow(DiaArrowChooser *chooser, Arrow *arrow);
ArrowType dia_arrow_chooser_get_arrow_type(DiaArrowChooser *chooser);
Modified: trunk/lib/dialinechooser.c
==============================================================================
--- trunk/lib/dialinechooser.c (original)
+++ trunk/lib/dialinechooser.c Fri Jul 18 22:00:55 2008
@@ -315,10 +315,9 @@
lchooser->selector = DIALINESTYLESELECTOR(wid);
menu = gtk_menu_new();
- g_object_ref(G_OBJECT(menu));
- gtk_object_sink(GTK_OBJECT(menu));
+ g_object_ref_sink(GTK_OBJECT(menu));
g_object_set_data_full(G_OBJECT(lchooser), button_menu_key, menu,
- (GDestroyNotify)gtk_widget_unref);
+ (GDestroyNotify)g_object_unref);
for (i = 0; i <= LINESTYLE_DOTTED; i++) {
mi = gtk_menu_item_new();
g_object_set_data(G_OBJECT(mi), menuitem_enum_key, GINT_TO_POINTER(i));
Modified: trunk/lib/dialogs.c
==============================================================================
--- trunk/lib/dialogs.c (original)
+++ trunk/lib/dialogs.c Fri Jul 18 22:00:55 2008
@@ -71,8 +71,8 @@
GtkWidget *label = gtk_label_new(title);
GtkWidget *entry = gtk_spin_button_new(limits, 10.0, decimals);
- gtk_box_pack_start_defaults(GTK_BOX(box), label);
- gtk_box_pack_start_defaults(GTK_BOX(box), entry);
+ gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX(box), entry, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box);
return GTK_SPIN_BUTTON(entry);
Modified: trunk/lib/makefile.msc
==============================================================================
--- trunk/lib/makefile.msc (original)
+++ trunk/lib/makefile.msc Fri Jul 18 22:00:55 2008
@@ -9,6 +9,7 @@
PKG_CFLAGS = -FImsvc_recommended_pragmas.h \
-I.. \
+ -DGTK_DISABLE_DEPRECATED \
$(GTK2_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(ZLIB_CFLAGS) \
Modified: trunk/lib/message.c
==============================================================================
--- trunk/lib/message.c (original)
+++ trunk/lib/message.c Fri Jul 18 22:00:55 2008
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
-#undef GTK_DISABLE_DEPRECATED /* for gtk_object_get_user_data */
#include <gtk/gtk.h>
#include <glib.h>
Modified: trunk/lib/prop_inttypes.c
==============================================================================
--- trunk/lib/prop_inttypes.c (original)
+++ trunk/lib/prop_inttypes.c Fri Jul 18 22:00:55 2008
@@ -29,7 +29,7 @@
#include <stdlib.h> /* strtol */
-#undef GTK_DISABLE_DEPRECATED /* gtk_signal_connect, gtk_object_set_user_data */
+#undef GTK_DISABLE_DEPRECATED /* gtk_option_menu_new */
#include <gtk/gtk.h>
#define WIDGET GtkWidget
#include "properties.h"
@@ -185,8 +185,8 @@
boolprop_get_widget(BoolProperty *prop, PropDialog *dialog)
{
GtkWidget *ret = gtk_toggle_button_new_with_label(_("No"));
- gtk_signal_connect(GTK_OBJECT(ret), "toggled",
- GTK_SIGNAL_FUNC(bool_toggled), NULL);
+ g_signal_connect(G_OBJECT(ret), "toggled",
+ G_CALLBACK (bool_toggled), NULL);
prophandler_connect(&prop->common,GTK_OBJECT(ret),"toggled");
return ret;
}
@@ -490,21 +490,12 @@
if (prop->common.extra_data) {
PropEnumData *enumdata = prop->common.extra_data;
- GtkWidget *menu;
guint i;
- ret = gtk_option_menu_new();
- menu = gtk_menu_new();
- for (i = 0; enumdata[i].name != NULL; i++) {
- GtkWidget *item = gtk_menu_item_new_with_label(_(enumdata[i].name));
-
- gtk_object_set_user_data(GTK_OBJECT(item),
- GUINT_TO_POINTER(enumdata[i].enumv));
- gtk_container_add(GTK_CONTAINER(menu), item);
- gtk_widget_show(item);
- prophandler_connect(&prop->common,GTK_OBJECT(item),"activate");
- }
- gtk_option_menu_set_menu(GTK_OPTION_MENU(ret), menu);
+ ret = gtk_combo_box_new_text ();
+ for (i = 0; enumdata[i].name != NULL; i++)
+ gtk_combo_box_append_text (GTK_COMBO_BOX (ret), _(enumdata[i].name));
+ prophandler_connect(&prop->common, GTK_OBJECT (ret), "changed");
} else {
ret = gtk_entry_new(); /* should use spin button/option menu */
}
@@ -524,7 +515,7 @@
break;
}
}
- gtk_option_menu_set_history(GTK_OPTION_MENU(widget), pos);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), pos);
} else {
char buf[16];
g_snprintf(buf, sizeof(buf), "%d", prop->enum_data);
@@ -535,13 +526,15 @@
static void
enumprop_set_from_widget(EnumProperty *prop, WIDGET *widget)
{
- if (GTK_IS_OPTION_MENU(widget)) {
- prop->enum_data=
- GPOINTER_TO_UINT(gtk_object_get_user_data(
- GTK_OBJECT(GTK_OPTION_MENU(widget)->menu_item)));
+ if (GTK_IS_COMBO_BOX (widget)) {
+ guint pos = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ PropEnumData *enumdata = prop->common.extra_data;
+
+ g_return_if_fail (enumdata != NULL);
+
+ prop->enum_data = enumdata[pos].enumv;
} else {
- prop->enum_data = strtol(gtk_entry_get_text(GTK_ENTRY(widget)),
- NULL, 0);
+ prop->enum_data = strtol(gtk_entry_get_text(GTK_ENTRY(widget)), NULL, 0);
}
}
Modified: trunk/lib/prop_sdarray.c
==============================================================================
--- trunk/lib/prop_sdarray.c (original)
+++ trunk/lib/prop_sdarray.c Fri Jul 18 22:00:55 2008
@@ -252,8 +252,8 @@
arrayprop_get_widget(ArrayProperty *prop, PropDialog *dialog)
{
GtkWidget *ret = gtk_button_new_with_label (prop->common.descr->tooltip);
- gtk_signal_connect (GTK_OBJECT (ret), "clicked",
- (GtkSignalFunc) darray_prop_edit, prop);
+ g_signal_connect (G_OBJECT (ret), "clicked",
+ G_CALLBACK (darray_prop_edit), prop);
return ret;
}
Modified: trunk/lib/propdialogs.c
==============================================================================
--- trunk/lib/propdialogs.c (original)
+++ trunk/lib/propdialogs.c Fri Jul 18 22:00:55 2008
@@ -28,7 +28,6 @@
#include <string.h>
-#undef GTK_DISABLE_DEPRECATED /* gtk_signal_connect, ... */
#include <gtk/gtk.h>
#define WIDGET GtkWidget
#include "widgets.h"
@@ -54,9 +53,9 @@
prop_dialog_container_push(dialog,dialog->widget);
- gtk_object_set_data(GTK_OBJECT(dialog->widget), prop_dialogdata_key, dialog);
- gtk_signal_connect(GTK_OBJECT(dialog->widget), "destroy",
- GTK_SIGNAL_FUNC(prop_dialog_signal_destroy), NULL);
+ g_object_set_data (G_OBJECT (dialog->widget), prop_dialogdata_key, dialog);
+ g_signal_connect (G_OBJECT (dialog->widget), "destroy",
+ G_CALLBACK (prop_dialog_signal_destroy), NULL);
prop_dialog_fill(dialog,obj,is_default);
@@ -76,8 +75,7 @@
PropDialog *
prop_dialog_from_widget(GtkWidget *dialog_widget)
{
- return gtk_object_get_data(GTK_OBJECT(dialog_widget),
- prop_dialogdata_key);
+ return g_object_get_data (G_OBJECT (dialog_widget), prop_dialogdata_key);
}
static void
@@ -234,10 +232,10 @@
/* g_message("connected signal %s to property %s",signal,prop->name); */
- gtk_signal_connect(object,
- signal,
- GTK_SIGNAL_FUNC(property_signal_handler),
- (gpointer)(&prop->self));
+ g_signal_connect (G_OBJECT (object),
+ signal,
+ G_CALLBACK (property_signal_handler),
+ (gpointer)(&prop->self));
}
void
Modified: trunk/lib/widgets.c
==============================================================================
--- trunk/lib/widgets.c (original)
+++ trunk/lib/widgets.c Fri Jul 18 22:00:55 2008
@@ -39,6 +39,35 @@
#include <time.h>
#include <gdk/gdkkeysyms.h>
+/* hidden internals for two reasosn:
+ * - noone is supposed to mess with the internals
+ * - it uses deprecated stuff
+ */
+struct _DiaDynamicMenu {
+ GtkOptionMenu parent;
+
+ GList *default_entries;
+
+ DDMCreateItemFunc create_func;
+ DDMCallbackFunc activate_func;
+ gpointer userdata;
+
+ GtkMenuItem *other_item;
+
+ gchar *persistent_name;
+ gint cols;
+
+ gchar *active;
+ /** For the list-based versions, these are the options */
+ GList *options;
+
+};
+
+struct _DiaDynamicMenuClass {
+ GtkOptionMenuClass parent_class;
+};
+
+
/************* DiaSizeSelector: ***************/
/* A widget that selects two sizes, width and height, optionally keeping
* aspect ratio. When created, aspect ratio is locked, but the user can
@@ -279,7 +308,9 @@
/************* DiaFontSelector: ***************/
-/* FIXME: Should these structs be in widgets.h instead? */
+/* Should these structs be in widgets.h instead? :
+ * _no_ they should not, noone is supposed to mess with the internals, ever heard of information hiding?
+ */
struct _DiaFontSelector
{
Modified: trunk/lib/widgets.h
==============================================================================
--- trunk/lib/widgets.h (original)
+++ trunk/lib/widgets.h Fri Jul 18 22:00:55 2008
@@ -39,39 +39,39 @@
#include "units.h"
/* DiaFontSelector: */
-#define DIAFONTSELECTOR(obj) GTK_CHECK_CAST (obj, dia_font_selector_get_type (), DiaFontSelector)
-#define DIAFONTSELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, dia_font_selector_get_type (), DiaFontSelectorClass)
-#define IS_DIAFONTSELECTOR(obj) GTK_CHECK_TYPE (obj, dia_font_selector_get_type ())
+#define DIAFONTSELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_font_selector_get_type (), DiaFontSelector)
+#define DIAFONTSELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_font_selector_get_type (), DiaFontSelectorClass)
+#define IS_DIAFONTSELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_font_selector_get_type ())
-GtkType dia_font_selector_get_type (void);
+GType dia_font_selector_get_type (void);
GtkWidget* dia_font_selector_new (void);
void dia_font_selector_set_font (DiaFontSelector *fs, DiaFont *font);
void dia_font_selector_set_preview (DiaFontSelector *fs, gchar *text);
DiaFont * dia_font_selector_get_font (DiaFontSelector *fs);
/* DiaAlignmentSelector: */
-#define DIAALIGNMENTSELECTOR(obj) GTK_CHECK_CAST (obj, dia_alignment_selector_get_type (), DiaAlignmentSelector)
-#define DIAALIGNMENTSELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, dia_alignment_selector_get_type (), DiaAlignmentSelectorClass)
-#define IS_DIAALIGNMENTSELECTOR(obj) GTK_CHECK_TYPE (obj, dia_alignment_selector_get_type ())
+#define DIAALIGNMENTSELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_alignment_selector_get_type (), DiaAlignmentSelector)
+#define DIAALIGNMENTSELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_alignment_selector_get_type (), DiaAlignmentSelectorClass)
+#define IS_DIAALIGNMENTSELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_alignment_selector_get_type ())
-GtkType dia_alignment_selector_get_type (void);
+GType dia_alignment_selector_get_type (void);
GtkWidget* dia_alignment_selector_new (void);
Alignment dia_alignment_selector_get_alignment (DiaAlignmentSelector *as);
void dia_alignment_selector_set_alignment (DiaAlignmentSelector *as,
Alignment align);
/* DiaLineStyleSelector: */
-#define DIALINESTYLESELECTOR(obj) GTK_CHECK_CAST (obj, dia_line_style_selector_get_type (), DiaLineStyleSelector)
-#define DIALINESTYLESELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, dia_line_style_selector_get_type (), DiaLineStyleSelectorClass)
-#define IS_DIALINESTYLESELECTOR(obj) GTK_CHECK_TYPE (obj, dia_line_style_selector_get_type ())
+#define DIALINESTYLESELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_line_style_selector_get_type (), DiaLineStyleSelector)
+#define DIALINESTYLESELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_line_style_selector_get_type (), DiaLineStyleSelectorClass)
+#define IS_DIALINESTYLESELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_line_style_selector_get_type ())
#define DEFAULT_LINESTYLE LINESTYLE_SOLID
#define DEFAULT_LINESTYLE_DASHLEN 1.0
-GtkType dia_line_style_selector_get_type (void);
+GType dia_line_style_selector_get_type (void);
GtkWidget* dia_line_style_selector_new (void);
void dia_line_style_selector_get_linestyle (DiaLineStyleSelector *as,
LineStyle *linestyle,
@@ -81,37 +81,17 @@
real dashlength);
/* DiaColorSelector: */
-#define DIACOLORSELECTOR(obj) GTK_CHECK_CAST (obj, dia_color_selector_get_type (), DiaColorSelector)
-#define DIACOLORSELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, dia_color_selector_get_type (), DiaColorSelectorClass)
-#define IS_DIACOLORSELECTOR(obj) GTK_CHECK_TYPE (obj, dia_color_selector_get_type ())
+#define DIACOLORSELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_color_selector_get_type (), DiaColorSelector)
+#define DIACOLORSELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_color_selector_get_type (), DiaColorSelectorClass)
+#define IS_DIACOLORSELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_color_selector_get_type ())
#define DEFAULT_FG_COLOR color_black
#define DEFAULT_BG_COLOR color_white
#define DEFAULT_COLOR color_white
-/*
- FIXME: DiaColorSelector is actually a DiaDynamicMenu,
- as returned by dia_color_selector_new
-*/
-struct _DiaColorSelector
-{
- GtkButton button;
-
- GtkWidget *area;
- GdkGC *gc;
-
- GtkWidget *col_sel;
-
-};
-
-struct _DiaColorSelectorClass
-{
- GtkButtonClass parent_class;
-};
-
/* FIXME: _get_type is not implemented */
-GtkType dia_color_selector_get_type (void);
+GType dia_color_selector_get_type (void);
GtkWidget* dia_color_selector_new (void);
void dia_color_selector_get_color (GtkWidget *cs, Color *color);
void dia_color_selector_set_color (GtkWidget *cs,
@@ -138,33 +118,33 @@
/* DiaFileSelector: */
-#define DIAFILESELECTOR(obj) GTK_CHECK_CAST (obj, dia_file_selector_get_type (), DiaFileSelector)
-#define DIAFILESELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, dia_file_selector_get_type (), DiaFileSelectorClass)
-#define IS_DIAFILESELECTOR(obj) GTK_CHECK_TYPE (obj, dia_file_selector_get_type ())
+#define DIAFILESELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_file_selector_get_type (), DiaFileSelector)
+#define DIAFILESELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_file_selector_get_type (), DiaFileSelectorClass)
+#define IS_DIAFILESELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_file_selector_get_type ())
-GtkType dia_file_selector_get_type (void);
+GType dia_file_selector_get_type (void);
GtkWidget* dia_file_selector_new (void);
void dia_file_selector_set_file (DiaFileSelector *fs, char *file);
const gchar *dia_file_selector_get_file (DiaFileSelector *fs);
/* DiaSizeSelector: */
-#define DIA_SIZE_SELECTOR(obj) GTK_CHECK_CAST (obj, dia_size_selector_get_type (), DiaSizeSelector)
-#define DIA_SIZE_SELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, dia_size_selector_get_type (), DiaSizeSelectorClass)
-#define IS_DIA_SIZE_SELECTOR(obj) GTK_CHECK_TYPE (obj, dia_size_selector_get_type ())
+#define DIA_SIZE_SELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_size_selector_get_type (), DiaSizeSelector)
+#define DIA_SIZE_SELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_size_selector_get_type (), DiaSizeSelectorClass)
+#define IS_DIA_SIZE_SELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_size_selector_get_type ())
-GtkType dia_size_selector_get_type (void);
+GType dia_size_selector_get_type (void);
GtkWidget* dia_size_selector_new (real width, real height);
void dia_size_selector_set_locked(DiaSizeSelector *ss, gboolean locked);
void dia_size_selector_set_size (DiaSizeSelector *ss, real width, real height);
-gboolean dia_size_selector_get_size (DiaSizeSelector *ss, real *width, real *height);
+gboolean dia_size_selector_get_size (DiaSizeSelector *ss, real *width, real *height);
/* DiaUnitSpinner */
-#define DIA_UNIT_SPINNER(obj) GTK_CHECK_CAST(obj, dia_unit_spinner_get_type(), DiaUnitSpinner)
-#define DIA_UNIT_SPINNER_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, dia_unit_spinner_get_type(), DiaUnitSpinnerClass)
-#define DIA_IS_UNIT_SPINNER(obj) GTK_CHECK_TYPE(obj, dia_unit_spinner_get_type())
+#define DIA_UNIT_SPINNER(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, dia_unit_spinner_get_type(), DiaUnitSpinner)
+#define DIA_UNIT_SPINNER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, dia_unit_spinner_get_type(), DiaUnitSpinnerClass)
+#define DIA_IS_UNIT_SPINNER(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, dia_unit_spinner_get_type())
typedef struct _DiaUnitSpinner DiaUnitSpinner;
typedef struct _DiaUnitSpinnerClass DiaUnitSpinnerClass;
@@ -180,7 +160,7 @@
};
-GtkType dia_unit_spinner_get_type (void);
+GType dia_unit_spinner_get_type (void);
GtkWidget *dia_unit_spinner_new (GtkAdjustment *adjustment,
DiaUnit adj_unit);
void dia_unit_spinner_set_value (DiaUnitSpinner *self, gdouble val);
@@ -189,9 +169,9 @@
/* DiaDynamicMenu */
-#define DIA_DYNAMIC_MENU(obj) GTK_CHECK_CAST(obj, dia_dynamic_menu_get_type(), DiaDynamicMenu)
-#define DIA_DYNAMIC_MENU_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, dia_dynamic_menu_get_type(), DiaDynamicMenuClass)
-#define DIA_IS_DYNAMIC_MENU(obj) GTK_CHECK_TYPE(obj, dia_dynamic_menu_get_type())
+#define DIA_DYNAMIC_MENU(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, dia_dynamic_menu_get_type(), DiaDynamicMenu)
+#define DIA_DYNAMIC_MENU_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, dia_dynamic_menu_get_type(), DiaDynamicMenuClass)
+#define DIA_IS_DYNAMIC_MENU(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, dia_dynamic_menu_get_type())
typedef struct _DiaDynamicMenu DiaDynamicMenu;
typedef struct _DiaDynamicMenuClass DiaDynamicMenuClass;
@@ -208,31 +188,7 @@
typedef GtkWidget *(* DDMCreateItemFunc)(DiaDynamicMenu *, gchar *);
typedef void (* DDMCallbackFunc)(DiaDynamicMenu *, const gchar *, gpointer);
-struct _DiaDynamicMenu {
- GtkOptionMenu parent;
-
- GList *default_entries;
-
- DDMCreateItemFunc create_func;
- DDMCallbackFunc activate_func;
- gpointer userdata;
-
- GtkMenuItem *other_item;
-
- gchar *persistent_name;
- gint cols;
-
- gchar *active;
- /** For the list-based versions, these are the options */
- GList *options;
-
-};
-
-struct _DiaDynamicMenuClass {
- GtkOptionMenuClass parent_class;
-};
-
-GtkType dia_dynamic_menu_get_type (void);
+GType dia_dynamic_menu_get_type (void);
GtkWidget *dia_dynamic_menu_new(DDMCreateItemFunc create,
gpointer userdata,
Modified: trunk/objects/UML/class_dialog.c
==============================================================================
--- trunk/objects/UML/class_dialog.c (original)
+++ trunk/objects/UML/class_dialog.c Fri Jul 18 22:00:55 2008
@@ -3133,7 +3133,8 @@
list = g_list_next(list);
}
- gtk_list_clear_items (GTK_LIST (prop_dialog->attributes_list), 0, -1);
+ if (prop_dialog)
+ gtk_list_clear_items (GTK_LIST (prop_dialog->attributes_list), 0, -1);
list = umlclass->operations;
while (list != NULL) {
@@ -3149,7 +3150,8 @@
list = g_list_next(list);
}
- gtk_list_clear_items (GTK_LIST (prop_dialog->operations_list), 0, -1);
+ if (prop_dialog)
+ gtk_list_clear_items (GTK_LIST (prop_dialog->operations_list), 0, -1);
#ifdef UML_MAINPOINT
obj->connections[connection_index++] = ¨class->connections[UMLCLASS_CONNECTIONPOINTS];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]