[dia/dia-next: 10/59] More work to move away from GtkOptionMenu
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/dia-next: 10/59] More work to move away from GtkOptionMenu
- Date: Wed, 9 Jan 2019 18:35:08 +0000 (UTC)
commit 378eb92b80a3c55fc5d8a56e2b9e424b153d6e31
Author: Zander Brown <zbrown gnome org>
Date: Tue Dec 11 22:53:08 2018 +0000
More work to move away from GtkOptionMenu
Sheel/Line switcher now very broken but build
app/toolbox.c | 88 ++++-
lib/diadynamicmenu.c | 150 ++++-----
lib/diadynamicmenu.h | 13 +-
lib/dialinechooser.c | 39 +--
lib/dialinestyleselector.c | 22 +-
lib/libdia.def | 2 -
lib/widgets/dialist.c | 806 +++++++++++++++++++++------------------------
lib/widgets/dialist.h | 5 +
8 files changed, 540 insertions(+), 585 deletions(-)
---
diff --git a/app/toolbox.c b/app/toolbox.c
index 91768964..13900a3b 100644
--- a/app/toolbox.c
+++ b/app/toolbox.c
@@ -342,10 +342,15 @@ fill_sheet_wbox(Sheet *sheet)
}
static void
-sheet_option_menu_changed(DiaDynamicMenu *menu, gpointer user_data)
+sheet_option_menu_changed (GtkListBox *box,
+ GtkListBoxRow *row,
+ gpointer user_data)
{
- char *string = dia_dynamic_menu_get_entry(menu);
+ g_return_if_fail (DIA_IS_LIST_ITEM (row));
+
+ char *string = dia_list_item_get_value (DIA_LIST_ITEM (row));
Sheet *sheet = get_sheet_by_name(string);
+
if (sheet == NULL) {
message_warning(_("No sheet named %s"), string);
} else {
@@ -374,27 +379,86 @@ get_sheet_names()
return g_list_sort (names, cmp_names);
}
+#define DIA_TYPE_SHEET_META (dia_list_get_type ())
+G_DECLARE_FINAL_TYPE (DiaSheetMeta, dia_sheet_meta, DIA, SHEET_META, GObject)
+
+struct _DiaSheetMeta {
+ gchar *name;
+};
+
+G_DEFINE_TYPE (DiaSheetMeta, dia_sheet_meta, G_TYPE_OBJECT)
+
+static void
+dia_sheet_meta_class_init (DiaSheetMetaClass *klass)
+{
+
+}
+
+static void
+dia_sheet_meta_init (DiaSheetMeta *self)
+{
+
+}
+
+static GtkWidget *
+render_row (gpointer item, gpointer user_data)
+{
+ return dia_list_item_new_with_label (DIA_SHEET_META (item)->name);
+}
+
static void
create_sheet_dropdown_menu(GtkWidget *parent)
{
+ GListStore *sheets = g_list_store_new (DIA_TYPE_SHEET_META);
GList *sheet_names = get_sheet_names();
+ DiaSheetMeta *meta
+ GList *l;
+ GtkWidget *popover;
+ GtkWidget *frame;
+ GtkWidget *wrap;
+ GtkWidget *list;
if (sheet_option_menu != NULL) {
gtk_container_remove(GTK_CONTAINER(parent), sheet_option_menu);
sheet_option_menu = NULL;
}
- sheet_option_menu =
- dia_dynamic_menu_new_stringlistbased(_("Other sheets"), sheet_names,
- NULL, "sheets");
- g_signal_connect(DIA_DYNAMIC_MENU(sheet_option_menu), "value-changed",
+ meta = g_object_new (DIA_TYPE_SHEET_META, NULL);
+ meta->name = "Assorted";
+ g_list_store_append (sheets, meta);
+
+ meta = g_object_new (DIA_TYPE_SHEET_META, NULL);
+ meta->name = "Flowchart";
+ g_list_store_append (sheets, meta);
+
+ meta = g_object_new (DIA_TYPE_SHEET_META, NULL);
+ meta->name = "UML";
+ g_list_store_append (sheets, meta);
+
+ for (l = sheet_names; l != NULL; l = l->next) {
+ meta = g_object_new (DIA_TYPE_SHEET_META, NULL);
+ meta->name = l->data;
+ g_list_store_append (sheets, meta);
+ }
+
+ popover = gtk_popover_new ();
+ frame = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (popover), frame);
+ wrap = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (frame), wrap);
+ list = gtk_list_box_new ();
+ gtk_container_add (GTK_CONTAINER (wrap), list);
+ gtk_widget_show_all (frame);
+
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_SINGLE);
+ gtk_list_box_bind_model (GTK_LIST_BOX (list), G_LIST_MODEL (sheets), render_row, NULL, NULL);
+
+ // TODO: Display selected, Show recent on top, Persistance
+ sheet_option_menu = gtk_menu_button_new ();
+ gtk_menu_button_set_popover (GTK_MENU_BUTTON (sheet_option_menu), popover);
+
+ g_signal_connect (G_OBJECT (list), "row-selected",
G_CALLBACK(sheet_option_menu_changed), sheet_option_menu);
- dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(sheet_option_menu),
- "Assorted");
- dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(sheet_option_menu),
- "Flowchart");
- dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(sheet_option_menu),
- "UML");
/* gtk_widget_set_size_request(sheet_option_menu, 20, -1);*/
gtk_wrap_box_pack_wrapped(GTK_WRAP_BOX(parent), sheet_option_menu,
TRUE, TRUE, FALSE, FALSE, TRUE);
diff --git a/lib/diadynamicmenu.c b/lib/diadynamicmenu.c
index 15a813e5..690d3082 100644
--- a/lib/diadynamicmenu.c
+++ b/lib/diadynamicmenu.c
@@ -19,7 +19,6 @@
#include <config.h>
#include <string.h>
#include "intl.h"
-#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu, ... */
#include <gtk/gtk.h>
#include "diadynamicmenu.h"
#include "persistence.h"
@@ -29,7 +28,7 @@
* - it uses deprecated stuff
*/
struct _DiaDynamicMenu {
- GtkOptionMenu parent;
+ GtkMenuButton parent;
GList *default_entries;
@@ -37,7 +36,8 @@ struct _DiaDynamicMenu {
DDMCallbackFunc activate_func;
gpointer userdata;
- GtkMenuItem *other_item;
+ GtkWidget *other;
+ GtkWidget *list;
gchar *persistent_name;
gint cols;
@@ -49,7 +49,7 @@ struct _DiaDynamicMenu {
};
struct _DiaDynamicMenuClass {
- GtkOptionMenuClass parent_class;
+ GtkMenuButtonClass parent_class;
};
@@ -88,7 +88,7 @@ dia_dynamic_menu_get_type(void)
(GInstanceInitFunc)dia_dynamic_menu_init,
};
us_type = g_type_register_static(
- gtk_option_menu_get_type(),
+ GTK_TYPE_MENU_BUTTON,
"DiaDynamicMenu",
&us_info, 0);
}
@@ -98,7 +98,7 @@ dia_dynamic_menu_get_type(void)
static void
dia_dynamic_menu_class_init(DiaDynamicMenuClass *class)
{
- GObjectClass *object_class = (GObjectClass*)class;
+ GtkWidgetClass *object_class = (GtkWidgetClass*)class;
object_class->destroy = dia_dynamic_menu_destroy;
@@ -114,13 +114,30 @@ dia_dynamic_menu_class_init(DiaDynamicMenuClass *class)
static void
dia_dynamic_menu_init(DiaDynamicMenu *self)
{
+ GtkWidget *pop, *box, *wrap;
+
+ pop = gtk_popover_new (GTK_WIDGET (self));
+
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_container_add (GTK_CONTAINER (pop), wrap);
+
+ self->list = dia_list_new ();
+
+ wrap = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (wrap), self->list);
+
+ gtk_container_add (GTK_CONTAINER (box), wrap);
+
+ gtk_widget_show_all (wrap);
+
+ gtk_menu_button_set_popover (GTK_MENU_BUTTON (self), pop);
}
void
dia_dynamic_menu_destroy(GObject *object)
{
DiaDynamicMenu *ddm = DIA_DYNAMIC_MENU(object);
- GObjectClass *parent_class = G_OBJECT_CLASS(g_type_class_peek_parent(G_OBJECT_GET_CLASS(object)));
+ GtkWidgetClass *parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent(G_OBJECT_GET_CLASS(object)));
if (ddm->active)
g_free(ddm->active);
@@ -142,7 +159,7 @@ dia_dynamic_menu_destroy(GObject *object)
GtkWidget *
dia_dynamic_menu_new(DDMCreateItemFunc create,
gpointer userdata,
- GtkMenuItem *otheritem, gchar *persist)
+ GtkWidget *otheritem, gchar *persist)
{
DiaDynamicMenu *ddm;
@@ -152,7 +169,7 @@ dia_dynamic_menu_new(DDMCreateItemFunc create,
ddm->create_func = create;
ddm->userdata = userdata;
- ddm->other_item = otheritem;
+ ddm->other = otheritem;
ddm->persistent_name = persist;
ddm->cols = 1;
@@ -163,31 +180,39 @@ dia_dynamic_menu_new(DDMCreateItemFunc create,
return GTK_WIDGET(ddm);
}
+void
+dia_dynamic_menu_set_active (DiaDynamicMenu *self, gint itm)
+{
+ dia_list_set_active (DIA_LIST (self->list), itm);
+ gtk_button_set_label (GTK_BUTTON (self),
+ dia_list_item_get_value (dia_list_get_selection (DIA_LIST (self->list))));
+}
+
/** Select the given entry, adding it if necessary */
void
dia_dynamic_menu_select_entry(DiaDynamicMenu *ddm, const gchar *name)
{
- gint add_result = dia_dynamic_menu_add_entry(ddm, name);
+ gint add_result = dia_dynamic_menu_add_entry (ddm, name);
if (add_result == 0) {
- GList *tmp;
- int i = 0;
- for (tmp = ddm->default_entries; tmp != NULL;
- tmp = g_list_next(tmp), i++) {
- if (!g_ascii_strcasecmp(tmp->data, name))
- gtk_option_menu_set_history(GTK_OPTION_MENU(ddm), i);
- }
- /* Not there after all? */
+ GList *tmp;
+ int i = 0;
+ for (tmp = ddm->default_entries; tmp != NULL;
+ tmp = g_list_next (tmp), i++) {
+ if (!g_ascii_strcasecmp (tmp->data, name))
+ dia_list_select_item (ddm->list, i);
+ }
+ /* Not there after all? */
} else {
if (ddm->default_entries != NULL)
- gtk_option_menu_set_history(GTK_OPTION_MENU(ddm),
- g_list_length(ddm->default_entries)+1);
+ dia_dynamic_menu_set_active (ddm,
+ g_list_length (ddm->default_entries) + 1);
else
- gtk_option_menu_set_history(GTK_OPTION_MENU(ddm), 0);
+ dia_dynamic_menu_set_active (ddm, 0);
}
- g_free(ddm->active);
- ddm->active = g_strdup(name);
- g_signal_emit(G_OBJECT(ddm), ddm_signals[DDM_VALUE_CHANGED], 0);
+ g_free (ddm->active);
+ ddm->active = g_strdup (name);
+ g_signal_emit (G_OBJECT (ddm), ddm_signals[DDM_VALUE_CHANGED], 0);
}
static void
@@ -198,27 +223,6 @@ dia_dynamic_menu_activate(GtkWidget *item, gpointer userdata)
dia_dynamic_menu_select_entry(ddm, name);
}
-static GtkWidget *
-dia_dynamic_menu_create_string_item(DiaDynamicMenu *ddm, gchar *string)
-{
- GtkWidget *item = gtk_menu_item_new_with_label(gettext(string));
- return item;
-}
-
-/** Utility function for dynamic menus that are entirely based on the
- * labels in the menu.
- */
-GtkWidget *
-dia_dynamic_menu_new_stringbased(GtkMenuItem *otheritem,
- gpointer userdata,
- gchar *persist)
-{
- GtkWidget *ddm = dia_dynamic_menu_new(dia_dynamic_menu_create_string_item,
- userdata,
- otheritem, persist);
- return ddm;
-}
-
/** Utility function for dynamic menus that are based on a submenu with
* many entries. This is useful for allowing the user to get a smaller
* subset menu out of a set too large to be easily handled by a menu.
@@ -229,7 +233,7 @@ dia_dynamic_menu_new_listbased(DDMCreateItemFunc create,
gchar *other_label, GList *items,
gchar *persist)
{
- GtkWidget *item = gtk_menu_item_new_with_label(other_label);
+ GtkWidget *item = dia_list_item_new_with_label(other_label);
GtkWidget *ddm = dia_dynamic_menu_new(create, userdata,
GTK_MENU_ITEM(item), persist);
dia_dynamic_menu_create_sublist(DIA_DYNAMIC_MENU(ddm), items, create);
@@ -238,25 +242,11 @@ dia_dynamic_menu_new_listbased(DDMCreateItemFunc create,
return ddm;
}
-/** Utility function for dynamic menus that allow selection from a large
- * number of strings.
- */
-GtkWidget *
-dia_dynamic_menu_new_stringlistbased(gchar *other_label,
- GList *items,
- gpointer userdata,
- gchar *persist)
-{
- return dia_dynamic_menu_new_listbased(dia_dynamic_menu_create_string_item,
- userdata,
- other_label, items, persist);
-}
-
static void
dia_dynamic_menu_create_sublist(DiaDynamicMenu *ddm,
GList *items, DDMCreateItemFunc create)
{
- GtkWidget *item = GTK_WIDGET(ddm->other_item);
+ GtkWidget *item = GTK_WIDGET(ddm->other);
GtkWidget *submenu = gtk_menu_new();
@@ -345,21 +335,10 @@ dia_dynamic_menu_get_entry(DiaDynamicMenu *ddm)
static void
dia_dynamic_menu_create_menu(DiaDynamicMenu *ddm)
{
- GtkWidget *sep;
GList *tmplist;
- GtkWidget *menu;
GtkWidget *item;
- g_object_ref(G_OBJECT(ddm->other_item));
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(ddm));
- if (menu != NULL) {
- gtk_container_remove(GTK_CONTAINER(menu), GTK_WIDGET(ddm->other_item));
- gtk_container_foreach(GTK_CONTAINER(menu),
- (GtkCallback)gtk_widget_destroy, NULL);
- gtk_option_menu_remove_menu(GTK_OPTION_MENU(ddm));
- }
-
- menu = gtk_menu_new();
+ dia_list_empty (DIA_LIST (ddm->list));
if (ddm->default_entries != NULL) {
for (tmplist = ddm->default_entries; tmplist != NULL; tmplist = g_list_next(tmplist)) {
@@ -367,12 +346,10 @@ dia_dynamic_menu_create_menu(DiaDynamicMenu *ddm)
g_object_set_data(G_OBJECT(item), "ddm_name", tmplist->data);
g_signal_connect(G_OBJECT(item), "activate",
G_CALLBACK(dia_dynamic_menu_activate), ddm);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ dia_list_add (DIA_LIST (ddm->list), GTK_LIST_BOX_ROW (item));
gtk_widget_show(item);
}
- sep = gtk_separator_menu_item_new();
- gtk_widget_show(sep);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);
+ dia_list_add_seperator (DIA_LIST (ddm->list));
}
for (tmplist = persistent_list_get_glist(ddm->persistent_name);
@@ -381,26 +358,17 @@ dia_dynamic_menu_create_menu(DiaDynamicMenu *ddm)
g_object_set_data(G_OBJECT(item), "ddm_name", tmplist->data);
g_signal_connect(G_OBJECT(item), "activate",
G_CALLBACK(dia_dynamic_menu_activate), ddm);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ dia_list_add (DIA_LIST (ddm->list), GTK_LIST_BOX_ROW (item));
gtk_widget_show(item);
}
- sep = gtk_separator_menu_item_new();
- gtk_widget_show(sep);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(ddm->other_item));
- g_object_unref(G_OBJECT(ddm->other_item));
- /* Eventually reset item here */
- gtk_widget_show(menu);
+ dia_list_add_seperator (DIA_LIST (ddm->list));
- item = gtk_menu_item_new_with_label(_("Reset menu"));
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ item = dia_list_item_new_with_label(_("Reset menu"));
+ dia_list_add (DIA_LIST (ddm->list), GTK_LIST_BOX_ROW (item));
g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(dia_dynamic_menu_reset), ddm);
gtk_widget_show(item);
- gtk_option_menu_set_menu(GTK_OPTION_MENU(ddm), menu);
-
- gtk_option_menu_set_history(GTK_OPTION_MENU(ddm), 0);
+ dia_dynamic_menu_set_active (ddm, 0);
}
/** Select the method used for sorting the non-default entries.
diff --git a/lib/diadynamicmenu.h b/lib/diadynamicmenu.h
index 436b6c99..2e3f706f 100644
--- a/lib/diadynamicmenu.h
+++ b/lib/diadynamicmenu.h
@@ -4,6 +4,8 @@
#include <gtk/gtk.h>
+#include "widgets/dialist.h"
+
/* DiaDynamicMenu */
#define DIA_DYNAMIC_MENU(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, dia_dynamic_menu_get_type(), DiaDynamicMenu)
@@ -29,18 +31,11 @@ GType dia_dynamic_menu_get_type (void);
GtkWidget *dia_dynamic_menu_new(DDMCreateItemFunc create,
gpointer userdata,
- GtkMenuItem *otheritem, gchar *persist);
-GtkWidget *dia_dynamic_menu_new_stringbased(GtkMenuItem *otheritem,
- gpointer userdata,
- gchar *persist);
+ GtkWidget *otheritem, gchar *persist);
GtkWidget *dia_dynamic_menu_new_listbased(DDMCreateItemFunc create,
gpointer userdata,
gchar *other_label,
GList *items, gchar *persist);
-GtkWidget *dia_dynamic_menu_new_stringlistbased(gchar *other_label,
- GList *items,
- gpointer userdata,
- gchar *persist);
void dia_dynamic_menu_add_default_entry(DiaDynamicMenu *ddm, const gchar *entry);
gint dia_dynamic_menu_add_entry(DiaDynamicMenu *ddm, const gchar *entry);
void dia_dynamic_menu_set_sorting_method(DiaDynamicMenu *ddm, DdmSortType sort);
@@ -49,6 +44,8 @@ void dia_dynamic_menu_set_max_entries(DiaDynamicMenu *ddm, gint max);
void dia_dynamic_menu_set_columns(DiaDynamicMenu *ddm, gint cols);
gchar *dia_dynamic_menu_get_entry(DiaDynamicMenu *ddm);
void dia_dynamic_menu_select_entry(DiaDynamicMenu *ddm, const gchar *entry);
+void dia_dynamic_menu_set_active (DiaDynamicMenu *ddm,
+ gint itm);
GList *dia_dynamic_menu_get_default_entries(DiaDynamicMenu *ddm);
const gchar *dia_dynamic_menu_get_persistent_name(DiaDynamicMenu *ddm);
diff --git a/lib/dialinechooser.c b/lib/dialinechooser.c
index 9f95d048..5a877a87 100644
--- a/lib/dialinechooser.c
+++ b/lib/dialinechooser.c
@@ -37,8 +37,8 @@ static void dia_line_preview_set(DiaLinePreview *line, LineStyle lstyle);
static void dia_line_preview_class_init (DiaLinePreviewClass *klass);
static void dia_line_preview_init (DiaLinePreview *arrow);
-static gint dia_line_preview_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint dia_line_preview_draw (GtkWidget *widget,
+ cairo_t *ctx);
GType
dia_line_preview_get_type (void)
@@ -70,20 +70,13 @@ dia_line_preview_class_init (DiaLinePreviewClass *class)
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS(class);
- widget_class->expose_event = dia_line_preview_expose;
+ widget_class->draw = dia_line_preview_draw;
}
static void
dia_line_preview_init (DiaLinePreview *line)
{
-#if GTK_CHECK_VERSION(2,18,0)
gtk_widget_set_has_window (GTK_WIDGET (line), FALSE);
-#else
- GTK_WIDGET_SET_FLAGS (line, GTK_NO_WINDOW);
-#endif
-
- GTK_WIDGET (line)->requisition.width = 30 + GTK_MISC (line)->xpad * 2;
- GTK_WIDGET (line)->requisition.height = 15 + GTK_MISC (line)->ypad * 2;
line->lstyle = LINESTYLE_SOLID;
}
@@ -112,32 +105,22 @@ dia_line_preview_set(DiaLinePreview *line, LineStyle lstyle)
}
static gint
-dia_line_preview_expose(GtkWidget *widget, GdkEventExpose *event)
+dia_line_preview_draw(GtkWidget *widget, cairo_t *ctx)
{
DiaLinePreview *line = DIA_LINE_PREVIEW(widget);
- GtkMisc *misc = GTK_MISC(widget);
+ GtkAllocation alloc;
gint width, height;
gint x, y;
- GdkWindow *win;
double dash_list[6];
- int line_width = 2;
- GtkStyle *style;
- GdkRGBA bg;
- GdkRGBA fg;
- cairo_t *ctx;
- if (gtk_widget_is_drawable(widget)) {
- width = widget->allocation.width - misc->xpad * 2;
- height = widget->allocation.height - misc->ypad * 2;
- x = (widget->allocation.x + misc->xpad);
- y = (widget->allocation.y + misc->ypad);
+ gtk_widget_get_allocation (widget, &alloc);
- win = gtk_widget_get_window (widget);
- style = gtk_widget_get_style (widget);
- bg = style->base[gtk_widget_get_state(widget)];
- fg = style->text[gtk_widget_get_state(widget)];
+ if (gtk_widget_is_drawable(widget)) {
+ width = alloc.width;
+ height = alloc.height;
+ x = alloc.x;
+ y = alloc.y;
- ctx = gdk_cairo_create (win);
cairo_set_line_cap (ctx, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join (ctx, CAIRO_LINE_JOIN_MITER);
diff --git a/lib/dialinestyleselector.c b/lib/dialinestyleselector.c
index 6c62e1d8..1d5a34bf 100644
--- a/lib/dialinestyleselector.c
+++ b/lib/dialinestyleselector.c
@@ -24,13 +24,14 @@
#include "intl.h"
#include "dialinechooser.h"
#include "widgets.h"
+#include "diaoptionmenu.h"
/************* DiaLineStyleSelector: ***************/
struct _DiaLineStyleSelector
{
GtkVBox vbox;
- GtkOptionMenu *omenu;
+ GtkWidget *omenu;
GtkMenu *linestyle_menu;
GtkLabel *lengthlabel;
GtkSpinButton *dashlength;
@@ -112,25 +113,18 @@ dia_line_style_selector_init (DiaLineStyleSelector *fs)
once = TRUE;
}
- menu = gtk_option_menu_new();
- fs->omenu = GTK_OPTION_MENU(menu);
+ menu = dia_option_menu_new();
+ fs->omenu = menu;
menu = gtk_menu_new ();
fs->linestyle_menu = GTK_MENU(menu);
for (i = 0; i <= LINESTYLE_DOTTED; i++) {
- menuitem = gtk_menu_item_new();
- gtk_widget_set_tooltip_text(menuitem, _line_style_names[i]);
- g_object_set_data(G_OBJECT(menuitem), "user_data", GINT_TO_POINTER(i));
- ln = dia_line_preview_new(i);
- gtk_container_add(GTK_CONTAINER(menuitem), ln);
- gtk_widget_show(ln);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show(menuitem);
+ dia_option_menu_add_item (fs->omenu, _line_style_names[i], i);
+ // TODO GTK3: Show previes: ln = dia_line_preview_new(i);
}
- gtk_menu_set_active(GTK_MENU (menu), DEFAULT_LINESTYLE);
- gtk_option_menu_set_menu (GTK_OPTION_MENU (fs->omenu), menu);
+ dia_option_menu_set_active (fs->omenu, DEFAULT_LINESTYLE);
g_signal_connect(G_OBJECT(menu), "selection-done",
G_CALLBACK(linestyle_type_change_callback), fs);
@@ -215,7 +209,7 @@ dia_line_style_selector_set_linestyle (DiaLineStyleSelector *as,
LineStyle linestyle, real dashlength)
{
gtk_menu_set_active(GTK_MENU (as->linestyle_menu), linestyle);
- gtk_option_menu_set_history (GTK_OPTION_MENU(as->omenu), linestyle);
+ dia_option_menu_set_active (as->omenu, linestyle);
/* TODO restore this later */
/* gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(gtk_menu_get_active(GTK_MENU(as->linestyle_menu))),
TRUE);*/
set_linestyle_sensitivity(DIALINESTYLESELECTOR(as));
diff --git a/lib/libdia.def b/lib/libdia.def
index 1f825d3a..4af8a80d 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -210,9 +210,7 @@ EXPORTS
dia_dynamic_menu_get_type
dia_dynamic_menu_new
- dia_dynamic_menu_new_stringbased
dia_dynamic_menu_new_listbased
- dia_dynamic_menu_new_stringlistbased
dia_dynamic_menu_add_default_entry
dia_dynamic_menu_add_entry
dia_dynamic_menu_set_sorting_method
diff --git a/lib/widgets/dialist.c b/lib/widgets/dialist.c
index b98b3b09..789b2838 100644
--- a/lib/widgets/dialist.c
+++ b/lib/widgets/dialist.c
@@ -11,210 +11,177 @@
typedef struct _DiaListPrivate DiaListPrivate;
struct _DiaListPrivate {
- GtkListBox* real;
+ GtkWidget *real;
};
G_DEFINE_TYPE_WITH_CODE (DiaList, dia_list, GTK_TYPE_FRAME,
- G_ADD_PRIVATE (DiaList))
-
-enum {
- DIA_LIST_0_PROPERTY,
- DIA_LIST_CHILDREN_PROPERTY,
- DIA_LIST_SELECTION_PROPERTY,
- DIA_LIST_SELECTION_MODE_PROPERTY,
- DIA_LIST_NUM_PROPERTIES
+ G_ADD_PRIVATE (DiaList))
+
+enum {
+ DIA_LIST_0_PROPERTY,
+ DIA_LIST_CHILDREN_PROPERTY,
+ DIA_LIST_SELECTION_PROPERTY,
+ DIA_LIST_SELECTION_MODE_PROPERTY,
+ DIA_LIST_NUM_PROPERTIES
};
-
static GParamSpec* dia_list_properties[DIA_LIST_NUM_PROPERTIES];
+enum {
+ DIA_LIST_CHILD_SELECTED_SIGNAL,
+ DIA_LIST_SELECTION_CHANGED_SIGNAL,
+ DIA_LIST_NUM_SIGNALS
+};
+static guint dia_list_signals[DIA_LIST_NUM_SIGNALS] = {0};
+
typedef struct _DiaListItemPrivate DiaListItemPrivate;
struct _DiaListItemPrivate {
- GtkLabel* label;
+ GtkWidget *label;
};
G_DEFINE_TYPE_WITH_CODE (DiaListItem, dia_list_item, GTK_TYPE_LIST_BOX_ROW,
- G_ADD_PRIVATE (DiaListItem))
+ G_ADD_PRIVATE (DiaListItem))
-enum {
- DIA_LIST_CHILD_SELECTED_SIGNAL,
- DIA_LIST_SELECTION_CHANGED_SIGNAL,
- DIA_LIST_NUM_SIGNALS
-};
-static guint dia_list_signals[DIA_LIST_NUM_SIGNALS] = {0};
-
-enum {
- DIA_LIST_ITEM_0_PROPERTY,
- DIA_LIST_ITEM_VALUE_PROPERTY,
- DIA_LIST_ITEM_NUM_PROPERTIES
+enum {
+ DIA_LIST_ITEM_0_PROPERTY,
+ DIA_LIST_ITEM_VALUE_PROPERTY,
+ DIA_LIST_ITEM_NUM_PROPERTIES
};
static GParamSpec* dia_list_item_properties[DIA_LIST_ITEM_NUM_PROPERTIES];
+enum {
+ DIA_LIST_ITEM_ACTIVATE_SIGNAL,
+ DIA_LIST_ITEM_NUM_SIGNALS
+};
+static guint dia_list_item_signals[DIA_LIST_ITEM_NUM_SIGNALS] = {0};
typedef struct _Block1Data Block1Data;
struct _Block1Data {
- int _ref_count_;
- DiaList* self;
- gint i;
+ int _ref_count_;
+ DiaList* self;
+ gint i;
};
-static void __lambda4_ (DiaList* self,
- DiaListItem* item);
-static void ___lambda4__gfunc (gpointer data,
- gpointer self);
-static Block1Data* block1_data_ref (Block1Data* _data1_);
-static void block1_data_unref (void * _userdata_);
-static void __lambda5_ (Block1Data* _data1_,
- DiaListItem* item);
-static void ___lambda5__gfunc (gpointer data,
- gpointer self);
static void __lambda6_ (DiaList* self,
DiaListItem* item);
static void ___lambda6__gfunc (gpointer data,
gpointer self);
-static void __lambda7_ (DiaList* self,
- GtkWidget* elm);
-static void ___lambda7__gtk_callback (GtkWidget* widget,
- gpointer self);
-static void _dia_list___lambda8_ (DiaList* self);
static void __dia_list___lambda8__gtk_list_box_row_selected (GtkListBox* _sender,
GtkListBoxRow* row,
gpointer self);
-static void _vala_dia_list_get_property (GObject * object,
- guint property_id,
- GValue * value,
- GParamSpec * pspec);
-static void _vala_dia_list_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec);
-static void _vala_dia_list_item_get_property (GObject * object,
- guint property_id,
- GValue * value,
- GParamSpec * pspec);
-static void _vala_dia_list_item_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec);
-static void
-dia_list_finalize (GObject * obj);
-static void
-dia_list_item_finalize (GObject * obj);
+static void dia_list_get_property (GObject * object,
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec);
+static void dia_list_set_property (GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void dia_list_item_get_property (GObject * object,
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec);
+static void dia_list_item_set_property (GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void dia_list_finalize (GObject * obj);
+static void dia_list_item_finalize (GObject * obj);
void
dia_list_select_child (DiaList* self,
DiaListItem* widget)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (widget != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_list_box_select_row (_tmp0_, (GtkListBoxRow*) widget);
- g_signal_emit (self, dia_list_signals[DIA_LIST_CHILD_SELECTED_SIGNAL], 0, widget);
-}
+ GtkWidget *list;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (widget != NULL);
+
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_list_box_select_row (GTK_LIST_BOX (list), GTK_LIST_BOX_ROW (widget));
+ g_signal_emit (self, dia_list_signals[DIA_LIST_CHILD_SELECTED_SIGNAL], 0, widget);
+}
void
dia_list_unselect_child (DiaList* self,
DiaListItem* widget)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (widget != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_list_box_unselect_row (_tmp0_, (GtkListBoxRow*) widget);
-}
+ GtkWidget *list;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (widget != NULL);
+
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_list_box_unselect_row (GTK_LIST_BOX (list), GTK_LIST_BOX_ROW (widget));
+}
static void
-__lambda4_ (DiaList* self,
- DiaListItem* item)
+append_item (gpointer item,
+ gpointer self)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (item != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_container_add ((GtkContainer*) _tmp0_, (GtkWidget*) item);
-}
+ GtkWidget *list;
+ g_return_if_fail (item != NULL);
-static void
-___lambda4__gfunc (gpointer data,
- gpointer self)
-{
- __lambda4_ ((DiaList*) self, (DiaListItem*) data);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (DIA_LIST (self)))->real;
+ gtk_container_add (GTK_CONTAINER (list), GTK_WIDGET (item));
}
-
void
dia_list_append_items (DiaList* self,
GList* items)
{
- g_return_if_fail (self != NULL);
- g_list_foreach (items, ___lambda4__gfunc, self);
+ g_return_if_fail (self != NULL);
+ g_list_foreach (items, append_item, self);
}
-
-static Block1Data*
-block1_data_ref (Block1Data* _data1_)
+void
+dia_list_set_active (DiaList *self, gint index)
{
- g_atomic_int_inc (&_data1_->_ref_count_);
- return _data1_;
-}
+ GtkWidget *list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ GtkListBoxRow *row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (list), index);
-
-static void
-block1_data_unref (void * _userdata_)
-{
- Block1Data* _data1_;
- _data1_ = (Block1Data*) _userdata_;
- if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
- DiaList* self;
- self = _data1_->self;
- g_object_unref (self);
- g_slice_free (Block1Data, _data1_);
- }
+ gtk_list_box_select_row (GTK_LIST_BOX (list), row);
}
-
static void
-__lambda5_ (Block1Data* _data1_,
- DiaListItem* item)
-{
- DiaList* self;
- GtkListBox* _tmp0_;
- gint _tmp1_;
- self = _data1_->self;
- g_return_if_fail (item != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- _tmp1_ = _data1_->i;
- _data1_->i = _tmp1_ + 1;
- gtk_list_box_insert (_tmp0_, (GtkWidget*) item, _tmp1_);
-}
+insert_items (gpointer item,
+ gpointer data)
+{
+ DiaList* self;
+ GtkWidget *list;
+ gint pos;
+ g_return_if_fail (item != NULL);
+ g_return_if_fail (data != NULL);
-static void
-___lambda5__gfunc (gpointer data,
- gpointer self)
-{
- __lambda5_ (self, (DiaListItem*) data);
+ self = ((Block1Data *) data)->self;
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ pos = ((Block1Data *) data)->i;
+ ((Block1Data *) data)->i = pos + 1;
+ gtk_list_box_insert (GTK_LIST_BOX (list), GTK_WIDGET (item), pos);
}
-
void
dia_list_insert_items (DiaList* self,
GList* items,
gint i)
{
- Block1Data* _data1_;
- g_return_if_fail (self != NULL);
- _data1_ = g_slice_new0 (Block1Data);
- _data1_->_ref_count_ = 1;
- _data1_->self = g_object_ref (self);
- _data1_->i = i;
- g_list_foreach (items, ___lambda5__gfunc, _data1_);
- block1_data_unref (_data1_);
- _data1_ = NULL;
+ Block1Data* _data1_;
+ g_return_if_fail (self != NULL);
+ _data1_ = g_slice_new0 (Block1Data);
+ _data1_->_ref_count_ = 1;
+ _data1_->self = g_object_ref (self);
+ _data1_->i = i;
+ g_list_foreach (items, insert_items, _data1_);
+ if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
+ DiaList* self;
+ self = _data1_->self;
+ g_object_unref (self);
+ g_slice_free (Block1Data, _data1_);
+ }
+ _data1_ = NULL;
}
@@ -222,369 +189,348 @@ static void
__lambda6_ (DiaList* self,
DiaListItem* item)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (item != NULL);
- _tmp0_ = ((DiaListPrivate *) ((DiaListPrivate *) dia_list_get_instance_private (self)))->real;
- gtk_container_remove ((GtkContainer*) _tmp0_, (GtkWidget*) item);
-}
+ GtkWidget *list;
+
+ g_return_if_fail (item != NULL);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_container_remove (GTK_CONTAINER (list), (GtkWidget*) item);
+}
static void
___lambda6__gfunc (gpointer data,
gpointer self)
{
- __lambda6_ ((DiaList*) self, (DiaListItem*) data);
+ __lambda6_ ((DiaList*) self, (DiaListItem*) data);
}
-
void
dia_list_remove_items (DiaList* self,
GList* items)
{
- g_return_if_fail (self != NULL);
- g_list_foreach (items, ___lambda6__gfunc, self);
+ g_return_if_fail (self != NULL);
+ g_list_foreach (items, ___lambda6__gfunc, self);
}
-
DiaListItem*
-dia_list_append (DiaList* self,
- const gchar* item)
+dia_list_append (DiaList *self,
+ const gchar *item)
{
- GtkWidget* row = NULL;
- GtkWidget* _tmp0_;
- GtkListBox* _tmp1_;
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (item != NULL, NULL);
- _tmp0_ = dia_list_item_new_with_label (item);
- g_object_ref_sink (_tmp0_);
- row = _tmp0_;
- gtk_widget_show_all ((GtkWidget*) row);
- _tmp1_ = ((DiaListPrivate *) ((DiaListPrivate *) dia_list_get_instance_private (self)))->real;
- gtk_container_add ((GtkContainer*) _tmp1_, (GtkWidget*) row);
- return (DiaListItem *) row;
-}
+ GtkWidget* row;
+ GtkWidget* list;
+
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (item != NULL, NULL);
+
+ row = dia_list_item_new_with_label (item);
+ gtk_widget_show_all (row);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_container_add (GTK_CONTAINER (list), row);
+ return DIA_LIST_ITEM (row);
+}
void
-dia_list_select_item (DiaList* self,
- gint i)
+dia_list_add (DiaList *self,
+ GtkListBoxRow *item)
{
- GtkListBox* _tmp0_;
- GtkListBoxRow* _tmp1_;
- g_return_if_fail (self != NULL);
- _tmp0_ = ((DiaListPrivate *) ((DiaListPrivate *) dia_list_get_instance_private (self)))->real;
- _tmp1_ = gtk_list_box_get_row_at_index (_tmp0_, i);
- dia_list_select_child (self, G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, DIA_TYPE_LIST_ITEM) ?
((DiaListItem*) _tmp1_) : NULL);
-}
+ GtkWidget* list;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (item != NULL, NULL);
-static void
-__lambda7_ (DiaList* self,
- GtkWidget* elm)
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_container_add (GTK_CONTAINER (list), item);
+}
+
+void
+dia_list_add_seperator (DiaList *self)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (elm != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_container_remove ((GtkContainer*) _tmp0_, elm);
+ GtkWidget *sep;
+ GtkWidget *list;
+
+ g_return_if_fail (self != NULL);
+
+ sep = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_show_all (sep);
+
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_container_add (GTK_CONTAINER (list), sep);
}
+void
+dia_list_select_item (DiaList *self,
+ gint i)
+{
+ GtkWidget *list;
+ GtkListBoxRow *tmp;
+
+ g_return_if_fail (self != NULL);
+
+ list = ((DiaListPrivate *) ((DiaListPrivate *) dia_list_get_instance_private (self)))->real;
+ tmp = gtk_list_box_get_row_at_index (GTK_LIST_BOX (list), i);
+ dia_list_select_child (self, G_TYPE_CHECK_INSTANCE_TYPE (tmp, DIA_TYPE_LIST_ITEM) ? (DIA_LIST_ITEM (tmp))
: NULL);
+}
static void
-___lambda7__gtk_callback (GtkWidget* widget,
- gpointer self)
+empty_widget (GtkWidget *elm,
+ gpointer self)
{
- __lambda7_ ((DiaList*) self, widget);
-}
+ GtkWidget *list;
+
+ g_return_if_fail (elm != NULL);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+
+ gtk_container_remove (GTK_CONTAINER (list), elm);
+}
void
-dia_list_empty (DiaList* self)
+dia_list_empty (DiaList *self)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_container_foreach ((GtkContainer*) _tmp0_, ___lambda7__gtk_callback, self);
-}
+ GtkWidget *list;
+
+ g_return_if_fail (self != NULL);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_container_foreach (GTK_CONTAINER (list), empty_widget, self);
+}
gint
-dia_list_child_position (DiaList* self,
- DiaListItem* row)
+dia_list_child_position (DiaList *self,
+ DiaListItem *row)
{
- gint result = 0;
- g_return_val_if_fail (self != NULL, 0);
- g_return_val_if_fail (row != NULL, 0);
- result = gtk_list_box_row_get_index ((GtkListBoxRow*) row);
- return result;
-}
+ g_return_val_if_fail (self != NULL, 0);
+ g_return_val_if_fail (row != NULL, 0);
+ return gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (row));
+}
void
-dia_list_unselect_all (DiaList* self)
+dia_list_unselect_all (DiaList *self)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_list_box_unselect_all (_tmp0_);
-}
+ GtkWidget *list;
+ g_return_if_fail (self != NULL);
+
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_list_box_unselect_all (GTK_LIST_BOX (list));
+}
void
dia_list_select_all (DiaList* self)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_list_box_select_all (_tmp0_);
-}
+ GtkWidget *list;
+ g_return_if_fail (self != NULL);
-DiaList*
-dia_list_construct (GType object_type)
-{
- DiaList * self = NULL;
- self = (DiaList*) g_object_new (object_type, NULL);
- return self;
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_list_box_select_all (GTK_LIST_BOX (list));
}
-
GtkWidget *
dia_list_new (void)
{
- return (GtkWidget *) dia_list_construct (DIA_TYPE_LIST);
+ return g_object_new (DIA_TYPE_LIST, NULL);
}
-
GList*
dia_list_get_children (DiaList* self)
{
- GList* result;
- GList* _tmp0_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = gtk_container_get_children ((GtkContainer*) self);
- result = _tmp0_;
- return result;
-}
+ GList* result;
+
+ g_return_val_if_fail (self != NULL, NULL);
+
+ result = gtk_container_get_children (GTK_CONTAINER (self));
+ return result;
+}
DiaListItem*
dia_list_get_selection (DiaList* self)
{
- DiaListItem* result;
- GtkListBox* _tmp0_;
- GtkListBoxRow* _tmp1_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- _tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
- result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, DIA_TYPE_LIST_ITEM) ? ((DiaListItem*) _tmp1_) : NULL;
- return result;
-}
+ GtkWidget *list;
+ GtkListBoxRow *tmp;
+ g_return_val_if_fail (self != NULL, NULL);
+
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ tmp = gtk_list_box_get_selected_row (GTK_LIST_BOX (list));
+ return G_TYPE_CHECK_INSTANCE_TYPE (tmp, DIA_TYPE_LIST_ITEM) ? (DIA_LIST_ITEM (tmp)) : NULL;
+}
GtkSelectionMode
dia_list_get_selection_mode (DiaList* self)
{
- GtkSelectionMode result;
- GtkListBox* _tmp0_;
- GtkSelectionMode _tmp1_;
- GtkSelectionMode _tmp2_;
- g_return_val_if_fail (self != NULL, 0);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- _tmp1_ = gtk_list_box_get_selection_mode (_tmp0_);
- _tmp2_ = _tmp1_;
- result = _tmp2_;
- return result;
-}
+ GtkWidget *list;
+
+ g_return_val_if_fail (self != NULL, 0);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+
+ return gtk_list_box_get_selection_mode (GTK_LIST_BOX (list));
+}
void
dia_list_set_selection_mode (DiaList* self,
GtkSelectionMode value)
{
- GtkListBox* _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_list_box_set_selection_mode (_tmp0_, value);
- g_object_notify_by_pspec ((GObject *) self, dia_list_properties[DIA_LIST_SELECTION_MODE_PROPERTY]);
-}
+ GtkWidget *list;
+ g_return_if_fail (self != NULL);
-static void
-_dia_list___lambda8_ (DiaList* self)
-{
- g_signal_emit (self, dia_list_signals[DIA_LIST_SELECTION_CHANGED_SIGNAL], 0);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), value);
+ g_object_notify_by_pspec (G_OBJECT (self), dia_list_properties[DIA_LIST_SELECTION_MODE_PROPERTY]);
}
-
static void
__dia_list___lambda8__gtk_list_box_row_selected (GtkListBox* _sender,
GtkListBoxRow* row,
gpointer self)
{
- _dia_list___lambda8_ ((DiaList*) self);
+ g_signal_emit (G_OBJECT (self), dia_list_signals[DIA_LIST_SELECTION_CHANGED_SIGNAL], 0);
+ if (DIA_IS_LIST_ITEM (row)) {
+ g_signal_emit (G_OBJECT (row), dia_list_item_signals[DIA_LIST_ITEM_ACTIVATE_SIGNAL], 0);
+ }
}
-
static GObject *
dia_list_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam * construct_properties)
{
- GObject * obj;
- GObjectClass * parent_class;
- DiaList * self;
- GtkListBox* _tmp0_;
- GtkListBox* _tmp1_;
- parent_class = G_OBJECT_CLASS (dia_list_parent_class);
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST, DiaList);
- _tmp0_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp0_);
- _tmp1_ = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- g_signal_connect_object (_tmp1_, "row-selected", (GCallback)
__dia_list___lambda8__gtk_list_box_row_selected, self, 0);
- return obj;
-}
+ GObject * obj;
+ GObjectClass * parent_class;
+ DiaList * self;
+ GtkWidget *list;
+
+ parent_class = G_OBJECT_CLASS (dia_list_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST, DiaList);
+ list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
+ gtk_container_add (GTK_CONTAINER (self), list);
+ g_signal_connect_object (list, "row-selected", (GCallback)
__dia_list___lambda8__gtk_list_box_row_selected, self, 0);
+
+ return obj;
+}
static void
dia_list_class_init (DiaListClass * klass)
{
- dia_list_parent_class = g_type_class_peek_parent (klass);
- G_OBJECT_CLASS (klass)->get_property = _vala_dia_list_get_property;
- G_OBJECT_CLASS (klass)->set_property = _vala_dia_list_set_property;
- G_OBJECT_CLASS (klass)->constructor = dia_list_constructor;
- G_OBJECT_CLASS (klass)->finalize = dia_list_finalize;
- g_object_class_install_property (G_OBJECT_CLASS (klass), DIA_LIST_CHILDREN_PROPERTY,
dia_list_properties[DIA_LIST_CHILDREN_PROPERTY] = g_param_spec_pointer ("children", "children", "children",
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), DIA_LIST_SELECTION_PROPERTY,
dia_list_properties[DIA_LIST_SELECTION_PROPERTY] = g_param_spec_object ("selection", "selection",
"selection", DIA_TYPE_LIST_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), DIA_LIST_SELECTION_MODE_PROPERTY,
dia_list_properties[DIA_LIST_SELECTION_MODE_PROPERTY] = g_param_spec_enum ("selection-mode",
"selection-mode", "selection-mode", gtk_selection_mode_get_type (), 0, G_PARAM_STATIC_STRINGS |
G_PARAM_READABLE | G_PARAM_WRITABLE));
- dia_list_signals[DIA_LIST_CHILD_SELECTED_SIGNAL] = g_signal_new ("child-selected", DIA_TYPE_LIST,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DIA_TYPE_LIST_ITEM);
- dia_list_signals[DIA_LIST_SELECTION_CHANGED_SIGNAL] = g_signal_new ("selection-changed",
DIA_TYPE_LIST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-}
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = dia_list_get_property;
+ object_class->set_property = dia_list_set_property;
+ object_class->constructor = dia_list_constructor;
+ object_class->finalize = dia_list_finalize;
+
+ g_object_class_install_property (object_class, DIA_LIST_CHILDREN_PROPERTY,
dia_list_properties[DIA_LIST_CHILDREN_PROPERTY] = g_param_spec_pointer ("children", "children", "children",
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+ g_object_class_install_property (object_class, DIA_LIST_SELECTION_PROPERTY,
dia_list_properties[DIA_LIST_SELECTION_PROPERTY] = g_param_spec_object ("selection", "selection",
"selection", DIA_TYPE_LIST_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+ g_object_class_install_property (object_class, DIA_LIST_SELECTION_MODE_PROPERTY,
dia_list_properties[DIA_LIST_SELECTION_MODE_PROPERTY] = g_param_spec_enum ("selection-mode",
"selection-mode", "selection-mode", gtk_selection_mode_get_type (), 0, G_PARAM_STATIC_STRINGS |
G_PARAM_READABLE | G_PARAM_WRITABLE));
+ dia_list_signals[DIA_LIST_CHILD_SELECTED_SIGNAL] = g_signal_new ("child-selected", DIA_TYPE_LIST,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DIA_TYPE_LIST_ITEM);
+ dia_list_signals[DIA_LIST_SELECTION_CHANGED_SIGNAL] = g_signal_new ("selection-changed", DIA_TYPE_LIST,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+}
static void
dia_list_init (DiaList * self)
{
- GtkListBox* _tmp0_;
- _tmp0_ = (GtkListBox*) gtk_list_box_new ();
- g_object_ref_sink (_tmp0_);
- ((DiaListPrivate *) dia_list_get_instance_private (self))->real = _tmp0_;
+ ((DiaListPrivate *) dia_list_get_instance_private (self))->real = gtk_list_box_new ();
}
-
static void
dia_list_finalize (GObject * obj)
{
- DiaList * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST, DiaList);
- g_object_unref (((DiaListPrivate *) dia_list_get_instance_private (self))->real);
- G_OBJECT_CLASS (dia_list_parent_class)->finalize (obj);
+ DiaList * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST, DiaList);
+ g_object_unref (((DiaListPrivate *) dia_list_get_instance_private (self))->real);
+ G_OBJECT_CLASS (dia_list_parent_class)->finalize (obj);
}
static void
-_vala_dia_list_get_property (GObject * object,
- guint property_id,
- GValue * value,
- GParamSpec * pspec)
-{
- DiaList * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST, DiaList);
- switch (property_id) {
- case DIA_LIST_CHILDREN_PROPERTY:
- g_value_set_pointer (value, dia_list_get_children (self));
- break;
- case DIA_LIST_SELECTION_PROPERTY:
- g_value_set_object (value, dia_list_get_selection (self));
- break;
- case DIA_LIST_SELECTION_MODE_PROPERTY:
- g_value_set_enum (value, dia_list_get_selection_mode (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+dia_list_get_property (GObject * object,
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
+ DiaList * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST, DiaList);
+ switch (property_id) {
+ case DIA_LIST_CHILDREN_PROPERTY:
+ g_value_set_pointer (value, dia_list_get_children (self));
+ break;
+ case DIA_LIST_SELECTION_PROPERTY:
+ g_value_set_object (value, dia_list_get_selection (self));
+ break;
+ case DIA_LIST_SELECTION_MODE_PROPERTY:
+ g_value_set_enum (value, dia_list_get_selection_mode (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-_vala_dia_list_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec)
-{
- DiaList * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST, DiaList);
- switch (property_id) {
- case DIA_LIST_SELECTION_MODE_PROPERTY:
- dia_list_set_selection_mode (self, g_value_get_enum (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+dia_list_set_property (GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
+ DiaList * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST, DiaList);
+ switch (property_id) {
+ case DIA_LIST_SELECTION_MODE_PROPERTY:
+ dia_list_set_selection_mode (self, g_value_get_enum (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
-
-DiaListItem*
-dia_list_item_construct_with_label (GType object_type,
- const gchar* lbl)
-{
- DiaListItem * self = NULL;
- g_return_val_if_fail (lbl != NULL, NULL);
- self = (DiaListItem*) g_object_new (object_type, NULL);
- dia_list_item_set_value (self, lbl);
- return self;
-}
-
-
GtkWidget *
dia_list_item_new_with_label (const gchar* lbl)
{
- return (GtkWidget *) dia_list_item_construct_with_label (DIA_TYPE_LIST_ITEM, lbl);
+ return g_object_new (DIA_TYPE_LIST_ITEM,
+ "value", lbl,
+ NULL);
}
-
-DiaListItem*
-dia_list_item_construct (GType object_type)
-{
- DiaListItem * self = NULL;
- self = (DiaListItem*) g_object_new (object_type, NULL);
- return self;
-}
-
-
GtkWidget *
dia_list_item_new (void)
{
- return (GtkWidget *) dia_list_item_construct (DIA_TYPE_LIST_ITEM);
+ return g_object_new (DIA_TYPE_LIST_ITEM, NULL);
}
-
const gchar*
dia_list_item_get_value (DiaListItem* self)
{
- const gchar* result;
- GtkLabel* _tmp0_;
- const gchar* _tmp1_;
- const gchar* _tmp2_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label;
- _tmp1_ = gtk_label_get_label (_tmp0_);
- _tmp2_ = _tmp1_;
- result = _tmp2_;
- return result;
-}
+ const gchar *result;
+ GtkWidget *label;
+
+ g_return_val_if_fail (self != NULL, NULL);
+ label = ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label;
+ result = gtk_label_get_label (GTK_LABEL (label));
+
+ return result;
+}
void
dia_list_item_set_value (DiaListItem* self,
const gchar* value)
{
- GtkLabel* _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label;
- gtk_label_set_label (_tmp0_, value);
- g_object_notify_by_pspec ((GObject *) self, dia_list_item_properties[DIA_LIST_ITEM_VALUE_PROPERTY]);
+ GtkWidget *label;
+
+ g_return_if_fail (self != NULL);
+
+ label = ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label;
+ gtk_label_set_label (GTK_LABEL (label), value);
+
+ g_object_notify_by_pspec ((GObject *) self, dia_list_item_properties[DIA_LIST_ITEM_VALUE_PROPERTY]);
}
@@ -593,86 +539,86 @@ dia_list_item_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam * construct_properties)
{
- GObject * obj;
- GObjectClass * parent_class;
- DiaListItem * self;
- GtkLabel* _tmp0_;
- parent_class = G_OBJECT_CLASS (dia_list_item_parent_class);
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST_ITEM, DiaListItem);
- _tmp0_ = ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label;
- gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp0_);
- return obj;
-}
+ GObject * obj;
+ GObjectClass * parent_class;
+ DiaListItem * self;
+ GtkWidget *label;
+ parent_class = G_OBJECT_CLASS (dia_list_item_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST_ITEM, DiaListItem);
+ label = ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label;
+ gtk_container_add (GTK_CONTAINER (self), label);
+ return obj;
+}
static void
dia_list_item_class_init (DiaListItemClass * klass)
{
- dia_list_item_parent_class = g_type_class_peek_parent (klass);
- G_OBJECT_CLASS (klass)->get_property = _vala_dia_list_item_get_property;
- G_OBJECT_CLASS (klass)->set_property = _vala_dia_list_item_set_property;
- G_OBJECT_CLASS (klass)->constructor = dia_list_item_constructor;
- G_OBJECT_CLASS (klass)->finalize = dia_list_item_finalize;
- g_object_class_install_property (G_OBJECT_CLASS (klass), DIA_LIST_ITEM_VALUE_PROPERTY,
dia_list_item_properties[DIA_LIST_ITEM_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value",
NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = dia_list_item_get_property;
+ object_class->set_property = dia_list_item_set_property;
+ object_class->constructor = dia_list_item_constructor;
+ object_class->finalize = dia_list_item_finalize;
+ g_object_class_install_property (object_class, DIA_LIST_ITEM_VALUE_PROPERTY,
dia_list_item_properties[DIA_LIST_ITEM_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value",
NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ dia_list_item_signals[DIA_LIST_ITEM_ACTIVATE_SIGNAL] =
+ g_signal_new ("activate",
+ DIA_TYPE_LIST, G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
-
static void
-dia_list_item_init (DiaListItem * self)
+dia_list_item_init (DiaListItem *self)
{
- GtkLabel* _tmp0_;
- _tmp0_ = (GtkLabel*) gtk_label_new (NULL);
- g_object_ref_sink (_tmp0_);
- ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label = _tmp0_;
+ ((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label = gtk_label_new (NULL);
}
-
static void
-dia_list_item_finalize (GObject * obj)
+dia_list_item_finalize (GObject *obj)
{
- DiaListItem * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST_ITEM, DiaListItem);
- g_object_unref (((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label);
- G_OBJECT_CLASS (dia_list_item_parent_class)->finalize (obj);
+ DiaListItem * self;
+
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIA_TYPE_LIST_ITEM, DiaListItem);
+
+ g_object_unref (((DiaListItemPrivate *) dia_list_item_get_instance_private (self))->label);
+
+ G_OBJECT_CLASS (dia_list_item_parent_class)->finalize (obj);
}
static void
-_vala_dia_list_item_get_property (GObject * object,
- guint property_id,
- GValue * value,
- GParamSpec * pspec)
-{
- DiaListItem * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST_ITEM, DiaListItem);
- switch (property_id) {
- case DIA_LIST_ITEM_VALUE_PROPERTY:
- g_value_set_string (value, dia_list_item_get_value (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+dia_list_item_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ DiaListItem * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST_ITEM, DiaListItem);
+ switch (property_id) {
+ case DIA_LIST_ITEM_VALUE_PROPERTY:
+ g_value_set_string (value, dia_list_item_get_value (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
-
static void
-_vala_dia_list_item_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec)
-{
- DiaListItem * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST_ITEM, DiaListItem);
- switch (property_id) {
- case DIA_LIST_ITEM_VALUE_PROPERTY:
- dia_list_item_set_value (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+dia_list_item_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ DiaListItem * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, DIA_TYPE_LIST_ITEM, DiaListItem);
+ switch (property_id) {
+ case DIA_LIST_ITEM_VALUE_PROPERTY:
+ dia_list_item_set_value (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
-
-
-
diff --git a/lib/widgets/dialist.h b/lib/widgets/dialist.h
index be9e1f0e..2f4fe553 100644
--- a/lib/widgets/dialist.h
+++ b/lib/widgets/dialist.h
@@ -36,6 +36,11 @@ void dia_list_remove_items (DiaList *self,
GList *items);
DiaListItem *dia_list_append (DiaList *self,
const gchar *item);
+void dia_list_add (DiaList *self,
+ GtkListBoxRow *itm);
+void dia_list_set_active (DiaList *self,
+ gint index);
+void dia_list_add_seperator (DiaList *self);
void dia_list_select_item (DiaList *self,
gint i);
void dia_list_empty (DiaList *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]