static void logview_filter_finalize (GObject *object) { LogviewFilterPrivate *priv = LOGVIEW_FILTER (object)->priv; if (priv->tag) { g_object_unref (priv->tag); } g_regex_unref (priv->regex); g_free (priv->name); G_OBJECT_CLASS (logview_filter_parent_class)->finalize (object); }
static void logview_filter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { LogviewFilterPrivate* priv = LOGVIEW_FILTER (object)->priv; switch (prop_id) { case PROP_REGEX: g_value_set_string (value, g_regex_get_pattern (priv->regex)); break; case PROP_NAME: g_value_set_string (value, priv->name); break; case PROP_TEXTTAG: g_value_set_object (value, priv->tag); break; } }
static void logview_filter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { LogviewFilterPrivate* priv = LOGVIEW_FILTER (object)->priv; switch (prop_id) { case PROP_NAME: priv->name = g_value_dup_string (value); break; case PROP_REGEX: { GError* err; const gchar* regex; err = NULL; regex = g_value_get_string (value); priv->regex = g_regex_new (regex, 0, 0, &err); if (err) { g_regex_unref (priv->regex); priv->regex = NULL; g_warning ("Couldn't create GRegex object: %s", err->message); g_error_free (err); } break; } case PROP_TEXTTAG: { if (priv->tag) { g_object_unref (priv->tag); } priv->tag = g_value_dup_object (value); break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data) { GPtrArray *filters; const gchar *name; LogviewFilter *filter; GdkRGBA *foreground; gboolean foreground_set; GdkRGBA *background; gboolean background_set; gchar *regex, *color; gboolean invisible; GtkTextTag *tag; GString *prefs_string; filters = user_data; filter = LOGVIEW_FILTER (value); name = key; color = NULL; prefs_string = g_string_new (name); g_string_append (prefs_string, DELIMITER); g_object_get (filter, "regex", ®ex, "texttag", &tag, NULL); g_object_get (tag, "foreground-set", &foreground_set, "foreground-rgba", &foreground, "paragraph-background-set", &background_set, "paragraph-background-rgba", &background, "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_rgba_to_string (foreground); g_string_append (prefs_string, color); g_free (color); } if (foreground) { gdk_rgba_free (foreground); } g_string_append (prefs_string, DELIMITER); if (background_set) { color = gdk_rgba_to_string (background); g_string_append (prefs_string, color); g_free (color); } if (background) { gdk_rgba_free (background); } g_string_append (prefs_string, DELIMITER); g_string_append (prefs_string, regex); g_free (regex); g_object_unref (tag); g_ptr_array_add (filters, g_string_free (prefs_string, FALSE)); }