diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | gst-mixer/src/preferences.c | 2 | ||||
-rw-r--r-- | gst-mixer/src/track.c | 6 | ||||
-rw-r--r-- | gst-mixer/src/volume.c | 99 | ||||
-rw-r--r-- | gst-mixer/src/window.c | 9 |
5 files changed, 111 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index b7b67f7..5ea73d6 100644 --- a/configure.ac +++ b/configure.ac @@ -66,7 +66,7 @@ AC_MSG_RESULT([$with_gtk]) case "$with_gtk" in 2.0) GTK_API_VERSION=2.0 - GTK_REQUIRED_VERSION=2.18.0 + GTK_REQUIRED_VERSION=2.24.0 CANBERRA_API_VERSION= UNIQUE_API_VERSION=1.0 ;; diff --git a/gst-mixer/src/preferences.c b/gst-mixer/src/preferences.c index b84b264..76fbcf9 100644 --- a/gst-mixer/src/preferences.c +++ b/gst-mixer/src/preferences.c @@ -103,7 +103,9 @@ mate_volume_control_preferences_init (MateVolumeControlPreferences *prefs) /* make window look cute */ gtk_window_set_title (GTK_WINDOW (prefs), _("Volume Control Preferences")); +#if !GTK_CHECK_VERSION (3, 0, 0) gtk_dialog_set_has_separator (GTK_DIALOG (prefs), FALSE); +#endif gtk_container_set_border_width (GTK_CONTAINER (prefs), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefs))), 2); gtk_dialog_add_buttons (GTK_DIALOG (prefs), diff --git a/gst-mixer/src/track.c b/gst-mixer/src/track.c index 2eb13cc..1861cfd 100644 --- a/gst-mixer/src/track.c +++ b/gst-mixer/src/track.c @@ -116,7 +116,7 @@ cb_option_changed (GtkComboBox *box, MateVolumeControlTrack *ctrl = data; gchar *opt; - opt = gtk_combo_box_get_active_text (box); + opt = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (box)); if (opt) gst_mixer_set_option (ctrl->mixer, GST_MIXER_OPTIONS (ctrl->track), opt); g_free (opt); @@ -542,13 +542,13 @@ mate_volume_control_track_add_option (GtkTable *table, /* optionmenu */ active_opt = gst_mixer_get_option (mixer, options); if (active_opt != NULL) { - ctrl->options = gtk_combo_box_new_text (); + ctrl->options = gtk_combo_box_text_new (); opts = gst_mixer_options_get_values (options); for (opt = opts; opt != NULL; opt = opt->next, i++) { if (opt->data == NULL) continue; - gtk_combo_box_append_text (GTK_COMBO_BOX (ctrl->options), opt->data); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (ctrl->options), opt->data); if (g_str_equal (active_opt, opt->data)) { gtk_combo_box_set_active (GTK_COMBO_BOX (ctrl->options), i); diff --git a/gst-mixer/src/volume.c b/gst-mixer/src/volume.c index 3df721f..9a1aaac 100644 --- a/gst-mixer/src/volume.c +++ b/gst-mixer/src/volume.c @@ -40,12 +40,26 @@ static void mate_volume_control_volume_class_init (MateVolumeControlVolumeClass static void mate_volume_control_volume_init (MateVolumeControlVolume *el); static void mate_volume_control_volume_dispose (GObject *object); +#if GTK_CHECK_VERSION (3, 0, 0) +static void mate_volume_control_volume_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); +static void mate_volume_control_volume_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height); +#else static void mate_volume_control_volume_size_req (GtkWidget *widget, GtkRequisition *req); +#endif static void mate_volume_control_volume_size_alloc (GtkWidget *widget, GtkAllocation *alloc); +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean mate_volume_control_volume_draw (GtkWidget *widget, + cairo_t *cr); +#else static gboolean mate_volume_control_volume_expose (GtkWidget *widget, GdkEventExpose *expose); +#endif static void cb_volume_changed (GtkAdjustment *adj, gpointer data); @@ -63,8 +77,14 @@ mate_volume_control_volume_class_init (MateVolumeControlVolumeClass *klass) gobject_class->dispose = mate_volume_control_volume_dispose; gtkwidget_class->size_allocate = mate_volume_control_volume_size_alloc; +#if GTK_CHECK_VERSION (3, 0, 0) + gtkwidget_class->get_preferred_width = mate_volume_control_volume_get_preferred_width; + gtkwidget_class->get_preferred_height = mate_volume_control_volume_get_preferred_height; + gtkwidget_class->draw = mate_volume_control_volume_draw; +#else gtkwidget_class->size_request = mate_volume_control_volume_size_req; gtkwidget_class->expose_event = mate_volume_control_volume_expose; +#endif } static void @@ -91,7 +111,11 @@ get_scale (MateVolumeControlVolume *vol, gint volume) { GtkWidget *slider; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkAdjustment *adj; +#else GtkObject *adj; +#endif AtkObject *accessible; gchar *accessible_name; @@ -101,7 +125,11 @@ get_scale (MateVolumeControlVolume *vol, (vol->track->max_volume - vol->track->min_volume) / 10.0, 0.0); g_signal_connect (adj, "value_changed", G_CALLBACK (cb_volume_changed), vol); +#if GTK_CHECK_VERSION (3, 0, 0) + slider = gtk_vscale_new (adj); +#else slider = gtk_vscale_new (GTK_ADJUSTMENT (adj)); +#endif gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE); gtk_range_set_inverted (GTK_RANGE (slider), TRUE); @@ -283,9 +311,14 @@ mate_volume_control_volume_size_req (GtkWidget *widget, GtkRequisition but_req, scale_req; /* request size of kids */ +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_get_preferred_size (vol->button, &but_req, NULL); + gtk_widget_get_preferred_size (vol->scales->data, &scale_req, NULL); +#else GTK_WIDGET_GET_CLASS (vol->button)->size_request (vol->button, &but_req); GTK_WIDGET_GET_CLASS (vol->scales->data)->size_request (vol->scales->data, &scale_req); +#endif if (scale_req.height < 100) scale_req.height = 100; @@ -295,6 +328,28 @@ mate_volume_control_volume_size_req (GtkWidget *widget, req->height = scale_req.height + but_req.height /*+ vol->padding*/; } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +mate_volume_control_volume_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + mate_volume_control_volume_size_req (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +mate_volume_control_volume_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + mate_volume_control_volume_size_req (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void mate_volume_control_volume_size_alloc (GtkWidget *widget, GtkAllocation *alloc) @@ -315,9 +370,14 @@ mate_volume_control_volume_size_alloc (GtkWidget *widget, return; /* request size of kids */ +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_get_preferred_size (vol->button, &but_req, NULL); + gtk_widget_get_preferred_size (vol->scales->data, &scale_req, NULL); +#else GTK_WIDGET_GET_CLASS (vol->button)->size_request (vol->button, &but_req); GTK_WIDGET_GET_CLASS (vol->scales->data)->size_request (vol->scales->data, &scale_req); +#endif /* calculate */ x_offset = (alloc->width - ((vol->track->num_channels * scale_req.width) + @@ -349,17 +409,24 @@ mate_volume_control_volume_size_alloc (GtkWidget *widget, } static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) +mate_volume_control_volume_draw (GtkWidget *widget, + cairo_t *cr) +#else mate_volume_control_volume_expose (GtkWidget *widget, GdkEventExpose *expose) +#endif { GtkAllocation allocation; MateVolumeControlVolume *vol = MATE_VOLUME_CONTROL_VOLUME (widget); +#if !GTK_CHECK_VERSION (3, 0, 0) /* clear background */ gtk_widget_get_allocation (widget, &allocation); gdk_window_clear_area (gtk_widget_get_window (widget), 0, 0, allocation.width, allocation.height); +#endif if (vol->track->num_channels > 1) { gint x_offset, y_offset, height, width; @@ -369,9 +436,14 @@ mate_volume_control_volume_expose (GtkWidget *widget, GtkStateType state; /* request size of kids */ +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_get_preferred_size (vol->button, &but_req, NULL); + gtk_widget_get_preferred_size (vol->scales->data, &scale_req, NULL); +#else GTK_WIDGET_GET_CLASS (vol->button)->size_request (vol->button, &but_req); GTK_WIDGET_GET_CLASS (vol->scales->data)->size_request (vol->scales->data, &scale_req); +#endif /* calculate */ gtk_widget_get_allocation (widget, &allocation); @@ -390,23 +462,50 @@ mate_volume_control_volume_expose (GtkWidget *widget, points[0].x = points[1].x = x_offset + 3; points[2].x = points[0].x + width - 6; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_move_to (cr, points[0].x, points[0].x); + cairo_line_to (cr, points[1].x, points[1].x); + cairo_move_to (cr, points[1].x, points[1].x); + cairo_line_to (cr, points[2].x, points[2].x); + cairo_move_to (cr, points[0].x, points[0].x); +#else gtk_paint_polygon (style, gtk_widget_get_window (widget), state, GTK_SHADOW_ETCHED_IN, &expose->area, widget, "hseparator", points, 3, FALSE); +#endif points[0].x = points[1].x = allocation.width - x_offset - 3; points[2].x = points[0].x - width + 6; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_move_to (cr, points[0].x, points[0].x); + cairo_line_to (cr, points[1].x, points[1].x); + cairo_move_to (cr, points[1].x, points[1].x); + cairo_line_to (cr, points[2].x, points[2].x); + cairo_move_to (cr, points[0].x, points[0].x); +#else gtk_paint_polygon (style, gtk_widget_get_window (widget), state, GTK_SHADOW_ETCHED_IN, &expose->area, widget, "hseparator", points, 3, FALSE); +#endif + +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_set_line_width (cr, 1.0); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_stroke (cr); +#endif } /* take care of redrawing the kids */ +#if GTK_CHECK_VERSION (3, 0, 0) + return GTK_WIDGET_CLASS (mate_volume_control_volume_parent_class)->draw (widget, cr); +#else return GTK_WIDGET_CLASS (mate_volume_control_volume_parent_class)->expose_event (widget, expose); +#endif } /* diff --git a/gst-mixer/src/window.c b/gst-mixer/src/window.c index c266ee0..58188c6 100644 --- a/gst-mixer/src/window.c +++ b/gst-mixer/src/window.c @@ -27,6 +27,9 @@ #include <gtk/gtk.h> #include <gio/gio.h> #include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkkeysyms-compat.h> +#endif #include "schemas.h" #include "preferences.h" @@ -61,7 +64,7 @@ cb_change (GtkComboBox *widget, { gchar *device_name; - device_name = gtk_combo_box_get_active_text (widget); + device_name = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget)); g_return_if_fail (device_name != NULL); g_settings_set_string (win->settings, MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, device_name); @@ -340,7 +343,7 @@ mate_volume_control_window_new (GList *elements) } active_element_num = count; - combo_box = gtk_combo_box_new_text (); + combo_box = gtk_combo_box_text_new (); renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box)); @@ -350,7 +353,7 @@ mate_volume_control_window_new (GList *elements) const gchar *name; name = g_object_get_data (item->data, "mate-volume-control-name"); - gtk_combo_box_append_text(GTK_COMBO_BOX (combo_box), name); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (combo_box), name); } gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), active_element_num); g_signal_connect (combo_box, "changed", G_CALLBACK (cb_change), win); |