summaryrefslogtreecommitdiff
path: root/logview/src
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-11-22 15:49:16 +0300
committermonsta <[email protected]>2016-11-22 15:49:16 +0300
commitea481767c4e3ec19136a5b61ad46f244a9a5ffa7 (patch)
treebbcceb1d2a0be587e7127109f57e41e9e9b43f98 /logview/src
parent8f9a34f003061d7c5e6cfe8a8cb64ec6e98d7c4a (diff)
downloadmate-utils-ea481767c4e3ec19136a5b61ad46f244a9a5ffa7.tar.bz2
mate-utils-ea481767c4e3ec19136a5b61ad46f244a9a5ffa7.tar.xz
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require mate-panel >= 1.17
Diffstat (limited to 'logview/src')
-rw-r--r--logview/src/logview-filter-manager.c67
-rw-r--r--logview/src/logview-findbar.c20
-rw-r--r--logview/src/logview-prefs.c57
-rw-r--r--logview/src/logview-window.c85
4 files changed, 1 insertions, 228 deletions
diff --git a/logview/src/logview-filter-manager.c b/logview/src/logview-filter-manager.c
index 080e012a..bcfef5a9 100644
--- a/logview/src/logview-filter-manager.c
+++ b/logview/src/logview-filter-manager.c
@@ -213,7 +213,6 @@ on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id,
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color))) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground))) {
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA foreground_color;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (color_foreground),
&foreground_color);
@@ -229,23 +228,6 @@ on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id,
g_object_set (tag,
"paragraph-background-rgba", &background_color,
"paragraph-background-set", TRUE, NULL);
-#else
- GdkColor foreground_color;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (color_foreground),
- &foreground_color);
- g_object_set (G_OBJECT (tag),
- "foreground-gdk", &foreground_color,
- "foreground-set", TRUE, NULL);
- }
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) {
- GdkColor background_color;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (color_background),
- &background_color);
- g_object_set (tag,
- "paragraph-background-gdk", &background_color,
- "paragraph-background-set", TRUE, NULL);
-#endif
}
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground))
@@ -368,7 +350,6 @@ run_add_edit_dialog (LogviewFilterManager *manager, LogviewFilter *filter)
gtk_entry_set_text (GTK_ENTRY(entry_regex), regex);
if (foreground_set) {
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA *foreground;
g_object_get (tag, "foreground-rgba", &foreground, NULL);
@@ -390,29 +371,6 @@ run_add_edit_dialog (LogviewFilterManager *manager, LogviewFilter *filter)
TRUE);
gdk_rgba_free (background);
-#else
- GdkColor *foreground;
-
- g_object_get (tag, "foreground-gdk", &foreground, NULL);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (color_foreground),
- foreground);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_foreground),
- TRUE);
-
- gdk_color_free (foreground);
- }
-
- if (background_set) {
- GdkColor *background;
-
- g_object_get (tag, "paragraph-background-gdk", &background, NULL);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (color_background),
- background);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_background),
- TRUE);
-
- gdk_color_free (background);
-#endif
}
if (background_set || foreground_set) {
@@ -496,11 +454,7 @@ on_tree_selection_changed (GtkTreeSelection *selection, LogviewFilterManager *ma
static void
logview_filter_manager_init (LogviewFilterManager *manager)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *grid;
-#else
- GtkWidget *table;
-#endif
GtkWidget *scrolled_window;
GtkTreeViewColumn *column;
GtkCellRenderer *text_renderer;
@@ -524,13 +478,9 @@ logview_filter_manager_init (LogviewFilterManager *manager)
G_TYPE_OBJECT));
logview_filter_manager_update_model (manager);
-#if GTK_CHECK_VERSION (3, 0, 0)
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
-#else
- table = gtk_table_new (3, 2, FALSE);
-#endif
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -573,7 +523,6 @@ logview_filter_manager_init (LogviewFilterManager *manager)
"changed", G_CALLBACK (on_tree_selection_changed),
manager);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_hexpand (scrolled_window, TRUE);
gtk_widget_set_vexpand (scrolled_window, TRUE);
gtk_grid_attach (GTK_GRID (grid), scrolled_window, 0, 0, 1, 3);
@@ -585,22 +534,6 @@ logview_filter_manager_init (LogviewFilterManager *manager)
gtk_grid_attach (GTK_GRID (grid), priv->remove_button, 1, 2, 1, 1);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (manager))),
grid, TRUE, TRUE, 5);
-#else
- gtk_table_attach_defaults (GTK_TABLE (table),
- scrolled_window,
- 0, 1, 0, 3);
- gtk_table_attach (GTK_TABLE (table),
- priv->add_button,
- 1, 2, 0, 1, GTK_FILL, 0, 5, 5);
- gtk_table_attach (GTK_TABLE (table),
- priv->edit_button,
- 1, 2, 1, 2, GTK_FILL, 0, 5, 5);
- gtk_table_attach (GTK_TABLE (table),
- priv->remove_button,
- 1, 2, 2, 3, GTK_FILL, 0, 5, 5);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (manager))),
- table, TRUE, TRUE, 5);
-#endif
gtk_widget_show_all (GTK_WIDGET (manager));
}
diff --git a/logview/src/logview-findbar.c b/logview/src/logview-findbar.c
index ece45651..bf71a260 100644
--- a/logview/src/logview-findbar.c
+++ b/logview/src/logview-findbar.c
@@ -139,11 +139,7 @@ unbold_timeout_cb (gpointer user_data)
PangoFontDescription *desc;
desc = pango_font_description_new ();
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_override_font (findbar->priv->message, desc);
-#else
- gtk_widget_modify_font (findbar->priv->message, desc);
-#endif
pango_font_description_free (desc);
findbar->priv->status_bold_id = 0;
@@ -171,11 +167,7 @@ logview_findbar_init (LogviewFindbar *findbar)
w = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 2, 2);
-#if GTK_CHECK_VERSION (3, 0, 0)
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
-#else
- box = gtk_hbox_new (FALSE, 12);
-#endif
gtk_container_add (GTK_CONTAINER (w), box);
label = gtk_label_new_with_mnemonic (_("_Find:"));
@@ -192,11 +184,7 @@ logview_findbar_init (LogviewFindbar *findbar)
gtk_widget_show_all (GTK_WIDGET (item));
/* "Previous" and "Next" buttons */
-#if GTK_CHECK_VERSION (3, 0, 0)
w = gtk_image_new_from_icon_name ("pan-start-symbolic", GTK_ICON_SIZE_BUTTON);
-#else
- w = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
-#endif
priv->back_button = gtk_tool_button_new (w, _("Find Previous"));
gtk_tool_item_set_is_important (priv->back_button, TRUE);
gtk_tool_item_set_tooltip_text (priv->back_button,
@@ -204,11 +192,7 @@ logview_findbar_init (LogviewFindbar *findbar)
gtk_toolbar_insert (gtoolbar, priv->back_button, -1);
gtk_widget_show_all (GTK_WIDGET (priv->back_button));
-#if GTK_CHECK_VERSION (3, 0, 0)
w = gtk_image_new_from_icon_name ("pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
-#else
- w = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
-#endif
priv->forward_button = gtk_tool_button_new (w, _("Find Next"));
gtk_tool_item_set_is_important (priv->forward_button, TRUE);
gtk_tool_item_set_tooltip_text (priv->forward_button,
@@ -360,11 +344,7 @@ logview_findbar_set_message (LogviewFindbar *findbar,
if (text) {
desc = pango_font_description_new ();
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_override_font (findbar->priv->message, desc);
-#else
- gtk_widget_modify_font (findbar->priv->message, desc);
-#endif
pango_font_description_free (desc);
findbar->priv->status_bold_id = g_timeout_add (600, unbold_timeout_cb, findbar);
diff --git a/logview/src/logview-prefs.c b/logview/src/logview-prefs.c
index 2cf8a366..e0fe79c2 100644
--- a/logview/src/logview-prefs.c
+++ b/logview/src/logview-prefs.c
@@ -154,11 +154,7 @@ load_filters (LogviewPrefs *prefs)
const gchar *str;
LogviewFilter *filter;
GtkTextTag *tag;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA color;
-#else
- GdkColor color;
-#endif
gint idx;
filters = g_settings_get_strv (prefs->priv->logview_prefs,
@@ -178,7 +174,6 @@ load_filters (LogviewPrefs *prefs)
g_str_equal (tokens[FILTER_INVISIBLE], "1"), NULL);
if (strlen (tokens[FILTER_FOREGROUND])) {
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_rgba_parse (&color, tokens[FILTER_FOREGROUND]);
g_object_set (tag, "foreground-rgba", &color,
"foreground-set", TRUE, NULL);
@@ -187,16 +182,6 @@ load_filters (LogviewPrefs *prefs)
if (strlen (tokens[FILTER_BACKGROUND])) {
gdk_rgba_parse (&color, tokens[FILTER_BACKGROUND]);
g_object_set (tag, "paragraph-background-rgba", &color,
-#else
- gdk_color_parse (tokens[FILTER_FOREGROUND], &color);
- g_object_set (tag, "foreground-gdk", &color,
- "foreground-set", TRUE, NULL);
- }
-
- if (strlen (tokens[FILTER_BACKGROUND])) {
- gdk_color_parse (tokens[FILTER_BACKGROUND], &color);
- g_object_set (tag, "paragraph-background-gdk", &color,
-#endif
"paragraph-background-set", TRUE, NULL);
}
@@ -219,15 +204,9 @@ save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data)
GPtrArray *filters;
const gchar *name;
LogviewFilter *filter;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA *foreground;
gboolean foreground_set;
GdkRGBA *background;
-#else
- GdkColor *foreground;
- gboolean foreground_set;
- GdkColor *background;
-#endif
gboolean background_set;
gchar *regex, *color;
gboolean invisible;
@@ -247,7 +226,6 @@ save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data)
"texttag", &tag,
NULL);
g_object_get (tag,
-#if GTK_CHECK_VERSION (3, 0, 0)
"foreground-set", &foreground_set,
"foreground-rgba", &foreground,
"paragraph-background-set", &background_set,
@@ -281,41 +259,6 @@ save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data)
if (background) {
gdk_rgba_free (background);
}
-#else
- "foreground-gdk", &foreground,
- "paragraph-background-gdk", &background,
- "foreground-set", &foreground_set,
- "paragraph-background-set", &background_set,
- "invisible", &invisible, NULL);
-
- if (invisible) {
- g_string_append (prefs_string, "1" DELIMITER);
- } else {
- g_string_append (prefs_string, "0" DELIMITER);
- }
-
- if (foreground_set) {
- color = gdk_color_to_string (foreground);
- g_string_append (prefs_string, color);
- g_free (color);
- }
-
- if (foreground) {
- gdk_color_free (foreground);
- }
-
- g_string_append (prefs_string, DELIMITER);
-
- if (background_set) {
- color = gdk_color_to_string (background);
- g_string_append (prefs_string, color);
- g_free (color);
- }
-
- if (background) {
- gdk_color_free (background);
- }
-#endif
g_string_append (prefs_string, DELIMITER);
g_string_append (prefs_string, regex);
diff --git a/logview/src/logview-window.c b/logview/src/logview-window.c
index ad48aefc..d53c9577 100644
--- a/logview/src/logview-window.c
+++ b/logview/src/logview-window.c
@@ -145,7 +145,6 @@ populate_tag_table (GtkTextTagTable *tag_table)
gtk_text_tag_table_add (tag_table, tag);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
populate_style_tag_table (LogviewWindow *logview)
{
@@ -172,28 +171,6 @@ populate_style_tag_table (LogviewWindow *logview)
gtk_text_tag_table_add (tag_table, tag);
}
-#else
-static void
-populate_style_tag_table (GtkStyle *style,
- GtkTextTagTable *tag_table)
-{
- GtkTextTag *tag;
- GdkColor color;
-
- tag = gtk_text_tag_table_lookup (tag_table, "gray");
-
- if (tag) {
- /* FIXME: do we need a way to update the buffer/view? */
- gtk_text_tag_table_remove (tag_table, tag);
- }
-
- tag = gtk_text_tag_new ("gray");
- color = style->text[GTK_STATE_INSENSITIVE];
- g_object_set (tag, "foreground-gdk", &color, "foreground-set", TRUE, NULL);
-
- gtk_text_tag_table_add (tag_table, tag);
-}
-#endif
static void
_gtk_text_buffer_apply_tag_to_rectangle (GtkTextBuffer *buffer, int line_start, int line_end,
@@ -267,11 +244,7 @@ logview_set_font (LogviewWindow *logview,
font_desc = pango_font_description_from_string (fontname);
if (font_desc) {
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_override_font (logview->priv->text_view, font_desc);
-#else
- gtk_widget_modify_font (logview->priv->text_view, font_desc);
-#endif
pango_font_description_free (font_desc);
}
}
@@ -286,11 +259,7 @@ logview_set_fontsize (LogviewWindow *logview, gboolean store)
context = gtk_widget_get_pango_context (priv->text_view);
fontdesc = pango_context_get_font_description (context);
pango_font_description_set_size (fontdesc, (priv->fontsize) * PANGO_SCALE);
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_override_font (priv->text_view, fontdesc);
-#else
- gtk_widget_modify_font (priv->text_view, fontdesc);
-#endif
if (store) {
logview_prefs_store_fontsize (logview->priv->prefs, priv->fontsize);
@@ -1159,19 +1128,6 @@ tearoff_changed_cb (LogviewPrefs *prefs,
gtk_ui_manager_set_add_tearoffs (window->priv->ui_manager, have_tearoffs);
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void
-style_set_cb (GtkWidget *widget,
- GtkStyle *prev,
- gpointer user_data)
-{
- LogviewWindow *logview = user_data;
- GtkStyle *style = gtk_widget_get_style (widget);
-
- populate_style_tag_table (style, logview->priv->tag_table);
-}
-#endif
-
static const struct {
guint keyval;
GdkModifierType modifier;
@@ -1220,29 +1176,17 @@ message_area_create_error_box (LogviewWindow *window,
GtkWidget *primary_label;
GtkWidget *secondary_label;
-#if GTK_CHECK_VERSION (3, 0, 0)
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
-#else
- hbox_content = gtk_hbox_new (FALSE, 8);
-#endif
gtk_widget_show (hbox_content);
image = gtk_image_new_from_icon_name ("dialog-error",
GTK_ICON_SIZE_DIALOG);
gtk_widget_show (image);
gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
gtk_widget_set_valign (image, GTK_ALIGN_START);
-#else
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-#else
- vbox = gtk_vbox_new (FALSE, 6);
-#endif
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
@@ -1351,11 +1295,7 @@ logview_window_init (LogviewWindow *logview)
logview_prefs_get_stored_window_size (priv->prefs, &width, &height);
gtk_window_set_default_size (GTK_WINDOW (logview), width, height);
-#if GTK_CHECK_VERSION (3, 0, 0)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-#else
- vbox = gtk_vbox_new (FALSE, 0);
-#endif
gtk_container_add (GTK_CONTAINER (logview), vbox);
/* create menus */
@@ -1390,21 +1330,13 @@ logview_window_init (LogviewWindow *logview)
gtk_widget_show (w);
/* panes */
-#if GTK_CHECK_VERSION (3, 0, 0)
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
-#else
- hpaned = gtk_hpaned_new ();
-#endif
gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
priv->hpaned = hpaned;
gtk_widget_show (hpaned);
/* first pane : sidebar (list of logs) */
-#if GTK_CHECK_VERSION (3, 0, 0)
priv->sidebar = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-#else
- priv->sidebar = gtk_vbox_new (FALSE, 0);
-#endif
gtk_widget_show (priv->sidebar);
/* first pane: log list */
@@ -1427,11 +1359,7 @@ logview_window_init (LogviewWindow *logview)
G_CALLBACK (loglist_day_cleared_cb), logview);
/* second pane: log */
-#if GTK_CHECK_VERSION (3, 0, 0)
main_view = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-#else
- main_view = gtk_vbox_new (FALSE, 0);
-#endif
gtk_paned_pack2 (GTK_PANED (hpaned), main_view, TRUE, TRUE);
/* second pane: error message area */
@@ -1454,9 +1382,7 @@ logview_window_init (LogviewWindow *logview)
priv->text_view = gtk_text_view_new ();
g_object_set (priv->text_view, "editable", FALSE, NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
populate_style_tag_table (logview);
-#endif
gtk_container_add (GTK_CONTAINER (w), priv->text_view);
gtk_widget_show (priv->text_view);
@@ -1482,11 +1408,7 @@ logview_window_init (LogviewWindow *logview)
}
/* version selector */
-#if GTK_CHECK_VERSION (3, 0, 0)
priv->version_bar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- priv->version_bar = gtk_hbox_new (FALSE, 0);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (priv->version_bar), 3);
priv->version_selector = gtk_combo_box_text_new ();
g_signal_connect (priv->version_selector, "changed",
@@ -1520,19 +1442,14 @@ logview_window_init (LogviewWindow *logview)
G_CALLBACK (tearoff_changed_cb), logview);
g_signal_connect (priv->manager, "active-changed",
G_CALLBACK (active_log_changed_cb), logview);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- g_signal_connect (logview, "style-set",
- G_CALLBACK (style_set_cb), logview);
-#endif
g_signal_connect (logview, "key-press-event",
G_CALLBACK (key_press_event_cb), logview);
/* status area at bottom */
priv->statusbar = gtk_statusbar_new ();
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_margin_top (GTK_WIDGET (logview->priv->statusbar), 0);
gtk_widget_set_margin_bottom (GTK_WIDGET (logview->priv->statusbar), 0);
-#endif
+
gtk_box_pack_start (GTK_BOX (vbox), priv->statusbar, FALSE, FALSE, 0);
gtk_widget_show (priv->statusbar);