/pidgin/main: ea40288b061e: Make some VV pref variables global.
Elliott Sales de Andrade
qulogic at pidgin.im
Fri Feb 14 04:26:28 EST 2014
Changeset: ea40288b061e58a10ab0f7c76f96f46f68ec391d
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2014-02-14 03:18 -0500
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/ea40288b061e
Description:
Make some VV pref variables global.
To be used in future changes.
diffstat:
pidgin/gtkprefs.c | 69 ++++++++++++++++++++++++++++--------------------------
1 files changed, 36 insertions(+), 33 deletions(-)
diffs (174 lines):
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -179,13 +179,12 @@ static const gchar *VIDEO_SINK_PLUGINS[]
NULL
};
-typedef struct {
- GtkWidget *level;
- GtkWidget *threshold;
- GtkWidget *volume;
-} BusCbCtx;
-
+static GtkWidget *voice_level;
+static GtkWidget *voice_threshold;
+static GtkWidget *voice_volume;
static GstElement *voice_pipeline;
+
+static GtkWidget *video_drawing_area;
static GstElement *video_pipeline;
#endif
@@ -562,6 +561,13 @@ delete_prefs(GtkWidget *asdf, void *gdsa
sample_webview = NULL;
+#if USE_VV
+ voice_level = NULL;
+ voice_threshold = NULL;
+ voice_volume = NULL;
+ video_drawing_area = NULL;
+#endif
+
notebook_page = 0;
prefsnotebook = NULL;
prefs = NULL;
@@ -3736,13 +3742,14 @@ create_voice_pipeline(void)
}
static void
-on_volume_change_cb(GtkWidget *w, gdouble value, GstBin *pipeline)
+on_volume_change_cb(GtkWidget *w, gdouble value, gpointer data)
{
GstElement *volume;
- g_return_if_fail(pipeline != NULL);
-
- volume = gst_bin_get_by_name(pipeline, "volume");
+ if (!voice_pipeline)
+ return;
+
+ volume = gst_bin_get_by_name(GST_BIN(voice_pipeline), "volume");
g_object_set(volume, "volume",
gtk_scale_button_get_value(GTK_SCALE_BUTTON(w)) * 10.0, NULL);
}
@@ -3769,7 +3776,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
static gboolean
-gst_bus_cb(GstBus *bus, GstMessage *msg, BusCbCtx *ctx)
+gst_bus_cb(GstBus *bus, GstMessage *msg, gpointer data)
{
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ELEMENT &&
gst_structure_has_name(gst_message_get_structure(msg), "level")) {
@@ -3783,13 +3790,13 @@ gst_bus_cb(GstBus *bus, GstMessage *msg,
GstElement *valve;
percent = gst_msg_db_to_percent(msg, "rms");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ctx->level), percent);
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(voice_level), percent);
percent = gst_msg_db_to_percent(msg, "decay");
- threshold = gtk_range_get_value(GTK_RANGE(ctx->threshold)) / 100.0;
+ threshold = gtk_range_get_value(GTK_RANGE(voice_threshold)) / 100.0;
valve = gst_bin_get_by_name(GST_BIN(GST_ELEMENT_PARENT(src)), "valve");
g_object_set(valve, "drop", (percent < threshold), NULL);
- g_object_set(ctx->level, "text",
+ g_object_set(voice_level, "text",
(percent < threshold) ? _("DROP") : " ", NULL);
}
@@ -3813,28 +3820,27 @@ voice_test_destroy_cb(GtkWidget *w, gpoi
static void
toggle_voice_test_cb(GtkToggleButton *test, gpointer data)
{
- BusCbCtx *ctx = data;
GstBus *bus;
if (gtk_toggle_button_get_active(test)) {
- gtk_widget_set_sensitive(ctx->level, TRUE);
+ gtk_widget_set_sensitive(voice_level, TRUE);
voice_pipeline = create_voice_pipeline();
bus = gst_pipeline_get_bus(GST_PIPELINE(voice_pipeline));
gst_bus_add_signal_watch(bus);
- g_signal_connect(bus, "message", G_CALLBACK(gst_bus_cb), ctx);
+ g_signal_connect(bus, "message", G_CALLBACK(gst_bus_cb), NULL);
gst_object_unref(bus);
- g_signal_connect(ctx->volume, "value-changed",
- G_CALLBACK(on_volume_change_cb), voice_pipeline);
+ g_signal_connect(voice_volume, "value-changed",
+ G_CALLBACK(on_volume_change_cb), NULL);
g_signal_connect(test, "destroy",
G_CALLBACK(voice_test_destroy_cb), NULL);
g_signal_connect(prefsnotebook, "switch-page",
G_CALLBACK(vv_test_switch_page_cb), test);
} else {
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ctx->level), 0.0);
- gtk_widget_set_sensitive(ctx->level, FALSE);
- g_object_disconnect(ctx->volume, "any-signal::value-changed",
- G_CALLBACK(on_volume_change_cb), voice_pipeline,
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(voice_level), 0.0);
+ gtk_widget_set_sensitive(voice_level, FALSE);
+ g_object_disconnect(voice_volume, "any-signal::value-changed",
+ G_CALLBACK(on_volume_change_cb), NULL,
NULL);
g_object_disconnect(test, "any-signal::destroy",
G_CALLBACK(voice_test_destroy_cb), NULL,
@@ -3875,7 +3881,6 @@ make_voice_test(GtkWidget *vbox)
GtkWidget *level;
GtkWidget *volume;
GtkWidget *threshold;
- BusCbCtx *ctx;
char *tmp;
label = gtk_label_new(NULL);
@@ -3914,12 +3919,11 @@ make_voice_test(GtkWidget *vbox)
gtk_box_pack_start(GTK_BOX(vbox), level, FALSE, FALSE, 0);
gtk_widget_set_sensitive(level, FALSE);
- ctx = g_new(BusCbCtx, 1);
- ctx->volume = volume;
- ctx->level = level;
- ctx->threshold = threshold;
+ voice_volume = volume;
+ voice_level = level;
+ voice_threshold = threshold;
g_signal_connect(test, "toggled",
- G_CALLBACK(toggle_voice_test_cb), ctx);
+ G_CALLBACK(toggle_voice_test_cb), NULL);
}
static GstElement *
@@ -3983,11 +3987,10 @@ window_id_cb(GstBus *bus, GstMessage *ms
static void
toggle_video_test_cb(GtkToggleButton *test, gpointer data)
{
- GtkWidget *video = data;
GstBus *bus;
if (gtk_toggle_button_get_active(test)) {
- GdkWindow *window = gtk_widget_get_window(video);
+ GdkWindow *window = gtk_widget_get_window(video_drawing_area);
gulong window_id = 0;
#ifdef GDK_WINDOWING_WIN32
@@ -4051,7 +4054,7 @@ make_video_test(GtkWidget *vbox)
GdkColor color = {0, 0, 0, 0};
#endif
- video = gtk_drawing_area_new();
+ video_drawing_area = video = gtk_drawing_area_new();
gtk_box_pack_start(GTK_BOX(vbox), video, TRUE, TRUE, 0);
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_override_background_color(video, GTK_STATE_FLAG_NORMAL, &color);
@@ -4064,7 +4067,7 @@ make_video_test(GtkWidget *vbox)
gtk_box_pack_start(GTK_BOX(vbox), test, FALSE, FALSE, 0);
g_signal_connect(test, "toggled",
- G_CALLBACK(toggle_video_test_cb), video);
+ G_CALLBACK(toggle_video_test_cb), NULL);
}
static GtkWidget *
More information about the Commits
mailing list