summaryrefslogtreecommitdiff
path: root/mate-dictionary/libgdict/gdict-defbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-dictionary/libgdict/gdict-defbox.c')
-rw-r--r--mate-dictionary/libgdict/gdict-defbox.c168
1 files changed, 4 insertions, 164 deletions
diff --git a/mate-dictionary/libgdict/gdict-defbox.c b/mate-dictionary/libgdict/gdict-defbox.c
index 7ce0cb57..29c304f9 100644
--- a/mate-dictionary/libgdict/gdict-defbox.c
+++ b/mate-dictionary/libgdict/gdict-defbox.c
@@ -52,10 +52,6 @@
#define QUERY_MARGIN 48
#define ERROR_MARGIN 24
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gdk_cursor_unref g_object_unref
-#endif
-
typedef struct
{
GdictDefinition *definition;
@@ -63,11 +59,6 @@ typedef struct
gint begin;
} Definition;
-#if !GTK_CHECK_VERSION(3,0,0)
-#define GDICT_DEFBOX_GET_PRIVATE(obj) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDICT_TYPE_DEFBOX, GdictDefboxPrivate))
-#endif
-
struct _GdictDefboxPrivate
{
GtkWidget *text_view;
@@ -131,16 +122,8 @@ enum
};
static guint gdict_defbox_signals[LAST_SIGNAL] = { 0 };
-#if GTK_CHECK_VERSION(3,0,0)
-G_DEFINE_TYPE_WITH_PRIVATE (GdictDefbox, gdict_defbox, GTK_TYPE_BOX)
-#else
-static GdkColor default_link_color = { 0, 0, 0, 0xeeee };
-static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
-
-
-G_DEFINE_TYPE (GdictDefbox, gdict_defbox, GTK_TYPE_BOX);
-#endif
+G_DEFINE_TYPE_WITH_PRIVATE (GdictDefbox, gdict_defbox, GTK_TYPE_BOX)
static Definition *
definition_new (void)
@@ -201,19 +184,19 @@ gdict_defbox_dispose (GObject *gobject)
if (priv->busy_cursor)
{
- gdk_cursor_unref (priv->busy_cursor);
+ g_object_unref (priv->busy_cursor);
priv->busy_cursor = NULL;
}
if (priv->hand_cursor)
{
- gdk_cursor_unref (priv->hand_cursor);
+ g_object_unref (priv->hand_cursor);
priv->hand_cursor = NULL;
}
if (priv->regular_cursor)
{
- gdk_cursor_unref (priv->regular_cursor);
+ g_object_unref (priv->regular_cursor);
priv->regular_cursor = NULL;
}
@@ -1309,18 +1292,10 @@ create_find_pane (GdictDefbox *defbox)
priv = defbox->priv;
-#if GTK_CHECK_VERSION (3, 0, 0)
find_pane = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- find_pane = gtk_hbox_new (FALSE, 0);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (find_pane), 0);
-#if GTK_CHECK_VERSION (3, 0, 0)
hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-#else
- hbox1 = gtk_hbox_new (FALSE, 6);
-#endif
gtk_box_pack_start (GTK_BOX (find_pane), hbox1, TRUE, TRUE, 0);
gtk_widget_show (hbox1);
@@ -1334,11 +1309,7 @@ create_find_pane (GdictDefbox *defbox)
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
gtk_widget_show (button);
-#if GTK_CHECK_VERSION (3, 0, 0)
hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
-#else
- hbox2 = gtk_hbox_new (FALSE, 12);
-#endif
gtk_box_pack_start (GTK_BOX (hbox1), hbox2, TRUE, TRUE, 0);
gtk_widget_show (hbox2);
@@ -1351,11 +1322,7 @@ create_find_pane (GdictDefbox *defbox)
gtk_box_pack_start (GTK_BOX (hbox2), priv->find_entry, TRUE, TRUE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->find_entry);
-#if GTK_CHECK_VERSION (3, 0, 0)
sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
-#else
- sep = gtk_vseparator_new ();
-#endif
gtk_box_pack_start (GTK_BOX (hbox1), sep, FALSE, FALSE, 0);
gtk_widget_show (sep);
@@ -1387,9 +1354,6 @@ static void
gdict_defbox_init_tags (GdictDefbox *defbox)
{
GdictDefboxPrivate *priv = defbox->priv;
-#if !GTK_CHECK_VERSION(3,0,0)
- GdkColor *link_color, *visited_link_color;
-#endif
g_assert (GTK_IS_TEXT_BUFFER (priv->buffer));
@@ -1410,7 +1374,6 @@ gdict_defbox_init_tags (GdictDefbox *defbox)
"scale", PANGO_SCALE_SMALL,
NULL);
-#if GTK_CHECK_VERSION(3,0,0)
{
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (defbox));
gboolean prefer_dark = FALSE;
@@ -1443,35 +1406,6 @@ gdict_defbox_init_tags (GdictDefbox *defbox)
"foreground-rgba", &rgba,
NULL);
}
-#else
- link_color = visited_link_color = NULL;
- gtk_widget_style_get (GTK_WIDGET (defbox),
- "link-color", &link_color,
- "visited-link-color", &visited_link_color,
- NULL);
- if (!link_color)
- link_color = &default_link_color;
-
- if (!visited_link_color)
- visited_link_color = &default_visited_link_color;
-
- priv->link_tag =
- gtk_text_buffer_create_tag (priv->buffer, "link",
- "underline", PANGO_UNDERLINE_SINGLE,
- "foreground-gdk", link_color,
- NULL);
- priv->visited_link_tag =
- gtk_text_buffer_create_tag (priv->buffer, "visited-link",
- "underline", PANGO_UNDERLINE_SINGLE,
- "foreground-gdk", visited_link_color,
- NULL);
-
- if (link_color != &default_link_color)
- gdk_color_free (link_color);
-
- if (visited_link_color != &default_visited_link_color)
- gdk_color_free (visited_link_color);
-#endif
gtk_text_buffer_create_tag (priv->buffer, "phonetic",
"foreground", "dark gray",
@@ -1594,24 +1528,16 @@ set_cursor_if_appropriate (GdictDefbox *defbox,
priv = defbox->priv;
if (!priv->hand_cursor)
-#if GTK_CHECK_VERSION(3,0,0)
{
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (defbox));
priv->hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
}
-#else
- priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
-#endif
if (!priv->regular_cursor)
-#if GTK_CHECK_VERSION(3,0,0)
{
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (defbox));
priv->regular_cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
}
-#else
- priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
-#endif
gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
@@ -1667,10 +1593,6 @@ defbox_motion_notify_cb (GtkWidget *text_view,
set_cursor_if_appropriate (defbox, GTK_TEXT_VIEW (text_view), bx, by);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gdk_window_get_pointer (gtk_widget_get_window (text_view), NULL, NULL, NULL);
-#endif
-
return FALSE;
}
@@ -1679,22 +1601,16 @@ defbox_visibility_notify_cb (GtkWidget *text_view,
GdkEventVisibility *event,
GdictDefbox *defbox)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
GdkDeviceManager *device_manager;
GdkDevice *pointer;
-#endif
gint wx, wy;
gint bx, by;
-#if GTK_CHECK_VERSION (3, 0, 0)
display = gdk_window_get_display (event->window);
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
gdk_window_get_device_position (gtk_widget_get_window (text_view), pointer, &wx, &wy, NULL);
-#else
- gdk_window_get_pointer (gtk_widget_get_window (text_view), &wx, &wy, NULL);
-#endif
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
GTK_TEXT_WINDOW_WIDGET,
@@ -1722,17 +1638,8 @@ gdict_defbox_constructor (GType type,
defbox = GDICT_DEFBOX (object);
priv = defbox->priv;
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_push_composite_child ();
-#endif
-
sw = gtk_scrolled_window_new (NULL, NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_vexpand (sw, TRUE);
-#endif
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_composite_name (sw, "gdict-defbox-scrolled-window");
-#endif
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -1745,18 +1652,12 @@ gdict_defbox_constructor (GType type,
gdict_defbox_init_tags (defbox);
priv->text_view = gtk_text_view_new_with_buffer (priv->buffer);
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_composite_name (priv->text_view, "gdict-defbox-text-view");
-#endif
gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->text_view), FALSE);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->text_view), 4);
gtk_container_add (GTK_CONTAINER (sw), priv->text_view);
gtk_widget_show (priv->text_view);
priv->find_pane = create_find_pane (defbox);
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_composite_name (priv->find_pane, "gdict-defbox-find-pane");
-#endif
gtk_box_pack_end (GTK_BOX (defbox), priv->find_pane, FALSE, FALSE, 0);
/* stuff to make the link machinery work */
@@ -1770,51 +1671,9 @@ gdict_defbox_constructor (GType type,
G_CALLBACK (defbox_visibility_notify_cb),
defbox);
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_pop_composite_child ();
-#endif
-
return object;
}
-#if !GTK_CHECK_VERSION(3,0,0)
-static void
-gdict_defbox_style_set (GtkWidget *widget,
- GtkStyle *old_style)
-{
- GdictDefboxPrivate *priv = GDICT_DEFBOX (widget)->priv;
- GdkColor *link_color, *visited_link_color;
-
- if (GTK_WIDGET_CLASS (gdict_defbox_parent_class)->style_set)
- GTK_WIDGET_CLASS (gdict_defbox_parent_class)->style_set (widget, old_style);
-
- link_color = visited_link_color = NULL;
- gtk_widget_style_get (widget,
- "link-color", &link_color,
- "visited-link-color", &visited_link_color,
- NULL);
- if (!link_color)
- link_color = &default_link_color;
-
- if (!visited_link_color)
- visited_link_color = &default_visited_link_color;
-
- g_object_set (G_OBJECT (priv->link_tag),
- "foreground-gdk", link_color,
- NULL);
-
- g_object_set (G_OBJECT (priv->visited_link_tag),
- "foreground-gdk", visited_link_color,
- NULL);
-
- if (link_color != &default_link_color)
- gdk_color_free (link_color);
-
- if (visited_link_color != &default_visited_link_color)
- gdk_color_free (visited_link_color);
-}
-#endif
-
/* we override the GtkWidget::show_all method since we have widgets
* we don't want to show, such as the find pane
*/
@@ -1884,9 +1743,6 @@ gdict_defbox_class_init (GdictDefboxClass *klass)
gobject_class->finalize = gdict_defbox_finalize;
widget_class->show_all = gdict_defbox_show_all;
-#if !GTK_CHECK_VERSION(3,0,0)
- widget_class->style_set = gdict_defbox_style_set;
-#endif
/**
* GdictDefbox:word:
@@ -2011,10 +1867,6 @@ gdict_defbox_class_init (GdictDefboxClass *klass)
GDK_KEY_Escape, 0,
"hide-find",
0);
-
-#if !GTK_CHECK_VERSION(3,0,0)
- g_type_class_add_private (klass, sizeof (GdictDefboxPrivate));
-#endif
}
static void
@@ -2025,11 +1877,7 @@ gdict_defbox_init (GdictDefbox *defbox)
gtk_orientable_set_orientation (GTK_ORIENTABLE (defbox), GTK_ORIENTATION_VERTICAL);
gtk_box_set_spacing (GTK_BOX (defbox), 6);
-#if GTK_CHECK_VERSION(3,0,0)
priv = gdict_defbox_get_instance_private (defbox);
-#else
- priv = GDICT_DEFBOX_GET_PRIVATE (defbox);
-#endif
defbox->priv = priv;
priv->context = NULL;
@@ -2262,14 +2110,10 @@ lookup_start_cb (GdictContext *context,
priv->is_searching = TRUE;
if (!priv->busy_cursor)
-#if GTK_CHECK_VERSION(3,0,0)
{
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (defbox));
priv->busy_cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
}
-#else
- priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
-#endif
window = gtk_text_view_get_window (GTK_TEXT_VIEW (priv->text_view),
GTK_TEXT_WINDOW_WIDGET);
@@ -2975,11 +2819,7 @@ gdict_defbox_set_font_name (GdictDefbox *defbox,
else
font_desc = NULL;
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_override_font (priv->text_view, font_desc);
-#else
- gtk_widget_modify_font (priv->text_view, font_desc);
-#endif
if (font_desc)
pango_font_description_free (font_desc);