[gnome-applets] Port mixer applet to GTK 3
- From: Josselin Mouette <jmouette src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] Port mixer applet to GTK 3
- Date: Thu, 28 Apr 2011 20:12:29 +0000 (UTC)
commit 99c787526f4745001cdcff9891ba25a1040e51ec
Author: Josselin Mouette <joss debian org>
Date: Thu Apr 28 22:11:27 2011 +0200
Port mixer applet to GTK 3
https://bugzilla.gnome.org/show_bug.cgi?id=645463
mixer/Makefile.am | 2 +-
mixer/applet.c | 88 +++++++++++++-------------------------------------
mixer/dock.c | 5 ++-
mixer/preferences.c | 5 +--
4 files changed, 29 insertions(+), 71 deletions(-)
---
diff --git a/mixer/Makefile.am b/mixer/Makefile.am
index 27ea8bf..8b944e8 100644
--- a/mixer/Makefile.am
+++ b/mixer/Makefile.am
@@ -45,7 +45,7 @@ org.gnome.panel.applet.MixerAppletFactory.service: $(service_in_files)
-e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
$< > $@
-uidir = $(datadir)/gnome-2.0/ui
+uidir = $(pkgdatadir)/ui
ui_DATA = mixer-applet-menu.xml
schemasdir = @GCONF_SCHEMA_FILE_DIR@
diff --git a/mixer/applet.c b/mixer/applet.c
index 8d53dfc..f8a3a08 100644
--- a/mixer/applet.c
+++ b/mixer/applet.c
@@ -69,10 +69,6 @@ gboolean gnome_volume_applet_key (GtkWidget *widget,
static gdouble gnome_volume_applet_get_volume (GstMixer *mixer,
GstMixerTrack *track);
-static void gnome_volume_applet_background (PanelApplet *panel_applet,
- PanelAppletBackgroundType type,
- GdkColor *colour,
- GdkPixmap *pixmap);
static void gnome_volume_applet_orientation (PanelApplet *applet,
PanelAppletOrient orient);
@@ -156,7 +152,6 @@ gnome_volume_applet_class_init (GnomeVolumeAppletClass *klass)
gtkwidget_class->scroll_event = gnome_volume_applet_scroll;
gtkwidget_class->size_allocate = gnome_volume_applet_size_allocate;
panelapplet_class->change_orient = gnome_volume_applet_orientation;
- panelapplet_class->change_background = gnome_volume_applet_background;
/* FIXME:
* - style-set.
@@ -629,7 +624,6 @@ gnome_volume_applet_get_dock_position (GnomeVolumeApplet *applet,
static void
gnome_volume_applet_popup_dock (GnomeVolumeApplet *applet)
{
- GtkWidget *widget = GTK_WIDGET (applet);
gint x, y;
/* Get it in just about the right position so that it
@@ -657,13 +651,11 @@ gnome_volume_applet_popup_dock (GnomeVolumeApplet *applet)
static void
gnome_volume_applet_popdown_dock (GnomeVolumeApplet *applet)
{
- GtkWidget *widget = GTK_WIDGET (applet);
-
if (!applet->pop)
return;
/* hide */
- gtk_widget_hide_all (GTK_WIDGET (applet->dock));
+ gtk_widget_hide (GTK_WIDGET (applet->dock));
/* set menu item as active */
gtk_widget_set_state (GTK_WIDGET (applet), GTK_STATE_NORMAL);
@@ -741,9 +733,9 @@ void
gnome_volume_applet_run_mixer (GnomeVolumeApplet *applet)
{
GError *error = NULL;
-
- gdk_spawn_command_line_on_screen (gtk_widget_get_screen (GTK_WIDGET (applet)),
- "gnome-volume-control", &error);
+ char *argv[] = { "gnome-volume-control", NULL };
+ g_spawn_async (g_get_home_dir(), argv, NULL,
+ G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
if (error) {
GtkWidget *dialog;
@@ -870,49 +862,49 @@ gnome_volume_applet_key (GtkWidget *widget,
if (!applet->mixer) {
show_no_mixer_dialog (applet);
} else switch (event->keyval) {
- case GDK_KP_Enter:
- case GDK_ISO_Enter:
- case GDK_3270_Enter:
- case GDK_Return:
- case GDK_space:
- case GDK_KP_Space:
+ case GDK_KEY_KP_Enter:
+ case GDK_KEY_ISO_Enter:
+ case GDK_KEY_3270_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_space:
+ case GDK_KEY_KP_Space:
gnome_volume_applet_pop_dock (applet);
return TRUE;
- case GDK_m:
+ case GDK_KEY_m:
if (event->state == GDK_CONTROL_MASK) {
gnome_volume_applet_toggle_mute (applet);
return TRUE;
}
break;
- case GDK_o:
+ case GDK_KEY_o:
if (event->state == GDK_CONTROL_MASK) {
gnome_volume_applet_run_mixer (applet);
return TRUE;
}
break;
- case GDK_Escape:
+ case GDK_KEY_Escape:
gnome_volume_applet_popdown_dock (applet);
return TRUE;
- case GDK_Page_Up:
- case GDK_Page_Down:
- case GDK_Left:
- case GDK_Right:
- case GDK_Up:
- case GDK_Down: {
+ case GDK_KEY_Page_Up:
+ case GDK_KEY_Page_Down:
+ case GDK_KEY_Left:
+ case GDK_KEY_Right:
+ case GDK_KEY_Up:
+ case GDK_KEY_Down: {
gdouble volume = gtk_adjustment_get_value (applet->adjustment);
gdouble increment;
if (event->state != 0)
break;
- if (event->keyval == GDK_Up || event->keyval == GDK_Down
- ||event->keyval == GDK_Left)
+ if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_Down
+ ||event->keyval == GDK_KEY_Left)
increment = gtk_adjustment_get_step_increment (applet->adjustment);
else
increment = gtk_adjustment_get_page_increment (applet->adjustment);
- if (event->keyval == GDK_Page_Up || event->keyval == GDK_Up
- ||event->keyval == GDK_Right) {
+ if (event->keyval == GDK_KEY_Page_Up || event->keyval == GDK_KEY_Up
+ ||event->keyval == GDK_KEY_Right) {
volume += increment;
if (volume > gtk_adjustment_get_upper (applet->adjustment))
volume = gtk_adjustment_get_upper (applet->adjustment);
@@ -995,40 +987,6 @@ void gnome_volume_applet_size_allocate (GtkWidget *widget,
gnome_volume_applet_refresh (applet, TRUE, -1, -1);
}
-static void
-gnome_volume_applet_background (PanelApplet *_applet,
- PanelAppletBackgroundType type,
- GdkColor *colour,
- GdkPixmap *pixmap)
-{
- GnomeVolumeApplet *applet = GNOME_VOLUME_APPLET (_applet);
- GtkRcStyle *rc_style;
- GtkStyle *style;
-
- /* reset style */
- gtk_widget_set_style (GTK_WIDGET (applet), NULL);
- rc_style = gtk_rc_style_new ();
- gtk_widget_modify_style (GTK_WIDGET (applet), rc_style);
- g_object_unref (rc_style);
-
- switch (type) {
- case PANEL_NO_BACKGROUND:
- break;
- case PANEL_COLOR_BACKGROUND:
- gtk_widget_modify_bg (GTK_WIDGET (applet),
- GTK_STATE_NORMAL, colour);
- break;
- case PANEL_PIXMAP_BACKGROUND:
- style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (applet)));
- if (style->bg_pixmap[GTK_STATE_NORMAL])
- g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]);
- style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap);
- gtk_widget_set_style (GTK_WIDGET (applet), style);
- g_object_unref (style);
- break;
- }
-}
-
/*
* This needs to be here because not all tracks have the same volume range,
* so you can send this function the track and a new volume and it will be
diff --git a/mixer/dock.c b/mixer/dock.c
index 776f939..0fc8565 100644
--- a/mixer/dock.c
+++ b/mixer/dock.c
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include "dock.h"
+#include "applet.h"
static void gnome_volume_applet_dock_class_init (GnomeVolumeAppletDockClass *klass);
static void gnome_volume_applet_dock_init (GnomeVolumeAppletDock *applet);
@@ -142,7 +143,7 @@ gnome_volume_applet_dock_new (GtkOrientation orientation,
boxes (a "horizontal" orientation - the meaning is reversed for
historical reasons. */
- GtkWidget *button, *scale, *mute, *more, *label;
+ GtkWidget *button, *scale, *more;
GtkWidget *container, *outerline, *innerline, *frame;
GnomeVolumeAppletDock *dock;
gint i;
@@ -324,7 +325,7 @@ cb_key_press (GtkWidget *widget,
{
/* Trap the escape key to popdown the dock. */
- if (event->keyval == GDK_Escape) {
+ if (event->keyval == GDK_KEY_Escape) {
/* This is trickier than it looks. The main applet is watching for
* this widget to loose focus. Hiding the widget causes a
* focus-loss, thus the applet gets the focus-out signal and all
diff --git a/mixer/preferences.c b/mixer/preferences.c
index 745a416..4f7ba73 100644
--- a/mixer/preferences.c
+++ b/mixer/preferences.c
@@ -88,7 +88,6 @@ gnome_volume_applet_preferences_init (GnomeVolumeAppletPreferences *prefs)
/* make window look cute */
gtk_window_set_title (GTK_WINDOW (prefs), _("Volume Control Preferences"));
- gtk_dialog_set_has_separator (GTK_DIALOG (prefs), FALSE);
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),
@@ -106,7 +105,7 @@ gnome_volume_applet_preferences_init (GnomeVolumeAppletPreferences *prefs)
gtk_widget_show (label);
/* optionmenu */
- prefs->optionmenu = gtk_combo_box_new_text ();
+ prefs->optionmenu = GTK_WIDGET(gtk_combo_box_text_new ());
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (prefs->optionmenu));
g_object_set (G_OBJECT (cells->data), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
g_list_free (cells);
@@ -170,7 +169,7 @@ gnome_volume_applet_preferences_new (PanelApplet *applet,
for ( ; elements != NULL; elements = elements->next) {
gchar *name = g_object_get_data (G_OBJECT (elements->data),
"gnome-volume-applet-name");
- gtk_combo_box_append_text (GTK_COMBO_BOX (prefs->optionmenu), name);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (prefs->optionmenu), name);
}
gnome_volume_applet_preferences_change (prefs, mixer, tracks);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]