[tbo] Migrated code from gtk2 to gtk3
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tbo] Migrated code from gtk2 to gtk3
- Date: Sun, 10 Apr 2011 12:10:10 +0000 (UTC)
commit 256a8fda68c08af2b3f865aa1e5393a82000b612
Author: danigm <danigm wadobo com>
Date: Sun Apr 10 14:09:14 2011 +0200
Migrated code from gtk2 to gtk3
configure.ac | 4 ++--
src/comic-new-dialog.c | 8 ++++----
src/dnd.c | 14 +++++++-------
src/export.c | 10 +++++-----
src/tbo-drawing.c | 21 +++++++++++++--------
src/tbo-tool-doodle.c | 2 +-
src/tbo-tool-selector.c | 14 +++++++-------
src/tbo-tooltip.c | 6 ++++--
src/tbo-ui-utils.c | 2 +-
src/tbo-window.c | 20 ++++++++++----------
10 files changed, 54 insertions(+), 47 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f63446b..b6549cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,8 +11,8 @@ AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LIBTOOL
-AM_PATH_GTK_2_0([2.10.0],,AC_MSG_ERROR([Gtk+ 2.10.0 or higher required.]))
-PKG_CHECK_MODULES(PACKAGE, "gtk+-2.0 cairo librsvg-2.0")
+AM_PATH_GTK_3_0([3.0.0],,AC_MSG_ERROR([Gtk+ 3.0.0 or higher required.]))
+PKG_CHECK_MODULES(PACKAGE, "gtk+-3.0 cairo librsvg-2.0")
# *******************************
# Internationalization
diff --git a/src/comic-new-dialog.c b/src/comic-new-dialog.c
index 62fc285..d577ee8 100644
--- a/src/comic-new-dialog.c
+++ b/src/comic-new-dialog.c
@@ -32,7 +32,7 @@ tbo_comic_new_dialog (GtkWidget *widget, TboWindow *window)
GtkWidget *label;
GtkWidget *spin_w;
GtkWidget *spin_h;
- GtkObject *adjustment;
+ GtkAdjustment *adjustment;
gint response;
int width;
@@ -46,9 +46,9 @@ tbo_comic_new_dialog (GtkWidget *widget, TboWindow *window)
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
NULL);
-
- vbox = (GTK_DIALOG (dialog))->vbox;
-
+
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
hbox = gtk_hbox_new (FALSE, FALSE);
label = gtk_label_new (_("width: "));
gtk_widget_set_size_request (label, 60, -1);
diff --git a/src/dnd.c b/src/dnd.c
index a8b3e92..1864995 100644
--- a/src/dnd.c
+++ b/src/dnd.c
@@ -38,27 +38,27 @@ drag_data_received_handl (GtkWidget *widget,
{
GtkAdjustment *adj;
float zoom = tbo_drawing_get_zoom (TBO_DRAWING (tbo->drawing));
- gchar *_sdata;
+ const gchar *_sdata;
gboolean dnd_success = FALSE;
gboolean delete_selection_data = FALSE;
/* Deal with what we are given from source */
- if ((selection_data != NULL) && (selection_data->length >= 0))
+ if ((selection_data != NULL) && (gtk_selection_data_get_length (selection_data) >= 0))
{
- if (context-> action == GDK_ACTION_ASK)
+ if (gdk_drag_context_get_selected_action (context) == GDK_ACTION_ASK)
{
/* Ask the user to move or copy, then set the context action. */
}
- if (context-> action == GDK_ACTION_MOVE)
+ if (gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE)
delete_selection_data = TRUE;
/* Check that we got the format we can use */
switch (target_type)
{
case TARGET_STRING:
- _sdata = (gchar*)selection_data->data;
+ _sdata = gtk_selection_data_get_data (selection_data);
Frame *frame = tbo_drawing_get_current_frame (TBO_DRAWING (tbo->drawing));
adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (tbo->dw_scroll));
@@ -66,7 +66,7 @@ drag_data_received_handl (GtkWidget *widget,
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tbo->dw_scroll));
int ry = tbo_frame_get_base_y ((y + gtk_adjustment_get_value(adj)) / zoom);
- TboObjectSvg *svgimage = TBO_OBJECT_SVG (tbo_object_svg_new_with_params (rx, ry, 0, 0, _sdata));
+ TboObjectSvg *svgimage = TBO_OBJECT_SVG (tbo_object_svg_new_with_params (rx, ry, 0, 0, (gchar*)_sdata));
tbo_drawing_update (TBO_DRAWING (tbo->drawing));
tbo_frame_add_obj (frame, TBO_OBJECT_BASE (svgimage));
@@ -99,7 +99,7 @@ drag_data_get_handl (GtkWidget *widget,
{
case TARGET_STRING:
gtk_selection_data_set (selection_data,
- selection_data->target,
+ gtk_selection_data_get_target (selection_data),
8*sizeof(char),
(guchar*) svg,
strlen (svg));
diff --git a/src/export.c b/src/export.c
index f856c49..777be1b 100644
--- a/src/export.c
+++ b/src/export.c
@@ -157,11 +157,11 @@ tbo_export (TboWindow *tbo)
spin_args2.scale = &scale;
g_signal_connect (spinh, "value-changed", G_CALLBACK (export_size_cb), &spin_args2);
- combobox = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("guess by extension"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), ".png");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), ".pdf");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), ".svg");
+ combobox = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), _("guess by extension"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), ".png");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), ".pdf");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), ".svg");
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
gtk_container_add (GTK_CONTAINER (vbox), combobox);
diff --git a/src/tbo-drawing.c b/src/tbo-drawing.c
index 4d1e9f5..f5d9ac5 100644
--- a/src/tbo-drawing.c
+++ b/src/tbo-drawing.c
@@ -35,14 +35,15 @@ G_DEFINE_TYPE (TboDrawing, tbo_drawing, GTK_TYPE_LAYOUT);
/* private methods */
static gboolean
-expose_event (GtkWidget *widget, GdkEventExpose *event)
+expose_event (GtkWidget *widget, cairo_t *cr1, gpointer dara)
{
cairo_t *cr;
gint w, h;
TboDrawing *self = TBO_DRAWING (widget);
- cr = gdk_cairo_create(GTK_LAYOUT (widget)->bin_window);
- gdk_drawable_get_size (GDK_DRAWABLE (GTK_LAYOUT (widget)->bin_window), &w, &h);
+ cr = gdk_cairo_create(gtk_layout_get_bin_window (GTK_LAYOUT (widget)));
+ w = gdk_window_get_width (gtk_layout_get_bin_window (GTK_LAYOUT (widget)));
+ h = gdk_window_get_height (gtk_layout_get_bin_window (GTK_LAYOUT (widget)));
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, w, h);
@@ -145,7 +146,7 @@ tbo_drawing_class_init (TboDrawingClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- widget_class->expose_event = expose_event;
+ widget_class->draw = expose_event;
widget_class->motion_notify_event = motion_notify_event;
widget_class->button_press_event = button_press_event;
widget_class->button_release_event = button_release_event;
@@ -176,10 +177,12 @@ tbo_drawing_new_with_params (Comic *comic)
void
tbo_drawing_update (TboDrawing *self)
{
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
gtk_widget_queue_draw_area (GTK_WIDGET (self),
0, 0,
- GTK_WIDGET (self)->allocation.width,
- GTK_WIDGET (self)->allocation.height);
+ alloc.width,
+ alloc.height);
}
void
@@ -278,8 +281,10 @@ tbo_drawing_zoom_fit (TboDrawing *self)
{
float z1, z2;
int w, h;
- w = GTK_WIDGET (self)->allocation.width;
- h = GTK_WIDGET (self)->allocation.height;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
+ w = alloc.width;
+ h = alloc.height;
z1 = fabs ((float)w / (float)self->comic->width);
z2 = fabs ((float)h / (float)self->comic->height);
diff --git a/src/tbo-tool-doodle.c b/src/tbo-tool-doodle.c
index 1afbf10..78f418f 100644
--- a/src/tbo-tool-doodle.c
+++ b/src/tbo-tool-doodle.c
@@ -76,7 +76,7 @@ on_unselect (TboToolBase *tool)
TboToolDoodle *self = TBO_TOOL_DOODLE (tool);
TboWindow *tbo = tool->tbo;
- if (GTK_IS_WIDGET (self->tree) && self->tree->parent == GTK_WIDGET (tbo->toolarea))
+ if (GTK_IS_WIDGET (self->tree) && gtk_widget_get_parent (self->tree) == GTK_WIDGET (tbo->toolarea))
{
adjust = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (tbo->scroll2));
self->hadjust = gtk_adjustment_get_value (adjust);
diff --git a/src/tbo-tool-selector.c b/src/tbo-tool-selector.c
index 201f635..9b50517 100644
--- a/src/tbo-tool-selector.c
+++ b/src/tbo-tool-selector.c
@@ -547,7 +547,7 @@ frame_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
TboObjectBase *current_obj = self->selected_object;
TboDrawing *drawing = TBO_DRAWING (tool->tbo->drawing);
- if (self->selected_frame != NULL && event->keyval == GDK_Escape)
+ if (self->selected_frame != NULL && event->keyval == GDK_KEY_Escape)
{
tbo_tool_selector_set_selected (self, NULL);
tbo_drawing_set_current_frame (drawing, NULL);
@@ -559,22 +559,22 @@ frame_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
{
switch (event->keyval)
{
- case GDK_less:
+ case GDK_KEY_less:
tbo_object_base_resize (current_obj, RESIZE_LESS);
break;
- case GDK_greater:
+ case GDK_KEY_greater:
tbo_object_base_resize (current_obj, RESIZE_GREATER);
break;
- case GDK_Up:
+ case GDK_KEY_Up:
tbo_object_base_move (current_obj, MOVE_UP);
break;
- case GDK_Down:
+ case GDK_KEY_Down:
tbo_object_base_move (current_obj, MOVE_DOWN);
break;
- case GDK_Left:
+ case GDK_KEY_Left:
tbo_object_base_move (current_obj, MOVE_LEFT);
break;
- case GDK_Right:
+ case GDK_KEY_Right:
tbo_object_base_move (current_obj, MOVE_RIGHT);
break;
default:
diff --git a/src/tbo-tooltip.c b/src/tbo-tooltip.c
index 06467cd..9b56cd1 100644
--- a/src/tbo-tooltip.c
+++ b/src/tbo-tooltip.c
@@ -153,8 +153,10 @@ void
tbo_tooltip_set_center_timeout (const char *tooltip, int timeout, TboWindow *tbo)
{
int x, y;
- x = tbo->drawing->allocation.width / 2;
- y = tbo->drawing->allocation.height / 2;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (tbo->drawing, &alloc);
+ x = alloc.width / 2;
+ y = alloc.height / 2;
tbo_tooltip_set (tooltip, x, y, tbo);
g_timeout_add (timeout, quit_tooltip_cb, tbo);
diff --git a/src/tbo-ui-utils.c b/src/tbo-ui-utils.c
index a0f14c0..0a90926 100644
--- a/src/tbo-ui-utils.c
+++ b/src/tbo-ui-utils.c
@@ -25,7 +25,7 @@ add_spin_with_label (GtkWidget *container, const gchar *string, gint value)
{
GtkWidget *label;
GtkWidget *spin;
- GtkObject *adjustment;
+ GtkAdjustment *adjustment;
GtkWidget *hpanel;
hpanel = gtk_hbox_new (FALSE, 0);
diff --git a/src/tbo-window.c b/src/tbo-window.c
index 83af9c9..bb7f489 100644
--- a/src/tbo-window.c
+++ b/src/tbo-window.c
@@ -36,7 +36,7 @@ static gboolean KEY_BINDER = TRUE;
static gboolean
notebook_switch_page_cb (GtkNotebook *notebook,
- GtkNotebookPage *page,
+ gpointer *page,
guint page_num,
TboWindow *tbo)
{
@@ -66,31 +66,31 @@ on_key_cb (GtkWidget *widget,
{
switch (event->keyval)
{
- case GDK_plus:
+ case GDK_KEY_plus:
tbo_drawing_zoom_in (drawing);
break;
- case GDK_minus:
+ case GDK_KEY_minus:
tbo_drawing_zoom_out (drawing);
break;
- case GDK_1:
+ case GDK_KEY_1:
tbo_drawing_zoom_100 (drawing);
break;
- case GDK_2:
+ case GDK_KEY_2:
tbo_drawing_zoom_fit (drawing);
break;
- case GDK_s:
+ case GDK_KEY_s:
tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_SELECTOR);
break;
- case GDK_t:
+ case GDK_KEY_t:
tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_TEXT);
break;
- case GDK_d:
+ case GDK_KEY_d:
tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_DOODLE);
break;
- case GDK_b:
+ case GDK_KEY_b:
tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_BUBBLE);
break;
- case GDK_f:
+ case GDK_KEY_f:
tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_FRAME);
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]