Index: mixer-prefbox.gob =================================================================== --- mixer-prefbox.gob (revision 25708) +++ mixer-prefbox.gob (working copy) @@ -43,6 +43,10 @@ /*protected GtkEntry *execu_entry;*/ /*protected GtkCheckButton *startup_nf_c;*/ /*protected GtkCheckButton *in_terminal_c;*/ + protected GtkCheckButton *launcher_show_c; + protected GtkWidget *color_button; + protected GtkWidget *color_da; + protected GdkColor *bar_color; private delayer_t device_entry_delayer = 0 destroy { delayer_free (VAR); }; protected LauncherEntry *launcher_entry = NULL; @@ -52,6 +56,11 @@ { launcher_entry_set_command (self->launcher_entry, "xfce4-mixer", FALSE, TRUE); gtk_entry_set_text (GTK_ENTRY (self->device_cb->entry), ""); + if (self->bar_color == NULL) { + self->bar_color = g_new(GdkColor, 1); + } + gdk_color_parse("#00c000", self->bar_color); + gtk_widget_modify_bg(self->color_da, GTK_STATE_NORMAL, self->bar_color); emit self_device_changed (self); } @@ -171,15 +180,26 @@ gtk_box_set_spacing (GTK_BOX (self), 5); self->device_cb = GTK_COMBO (gtk_combo_new ()); self->master_om = GTK_OPTION_MENU (gtk_option_menu_new ()); + self->launcher_show_c = GTK_CHECK_BUTTON (gtk_check_button_new ()); - gtk_container_set_border_width (GTK_CONTAINER (self), 5); gtk_box_pack_start (GTK_BOX (self), twocol_label (_("Device:"), GTK_WIDGET (self->device_cb)), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (self), twocol_label (_("Wannabe Master:"), GTK_WIDGET (self->master_om)), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (self), twocol_label (_("Show icon"), GTK_WIDGET (self->launcher_show_c)), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (self), headline (_("When clicked"), &self->click_b), FALSE, FALSE, 0); + self->color_button = gtk_button_new (); + self->color_da = gtk_drawing_area_new (); + gtk_widget_set_size_request (self->color_da, 64, 12); + gtk_widget_show (GTK_WIDGET (self->color_da)); + gtk_container_add(GTK_CONTAINER (self->color_button), + self->color_da); + /*gtk_widget_show (GTK_WIDGET (color_button));*/ + gtk_box_pack_start (GTK_BOX (self), twocol_label (_("Bar color:"), GTK_WIDGET (self->color_button)), FALSE, FALSE, 0); + + gtk_entry_set_max_length (GTK_ENTRY (self->device_cb->entry), 50); gtk_combo_set_value_in_list (GTK_COMBO (self->device_cb), FALSE, TRUE); @@ -193,6 +213,8 @@ dentry = GTK_WIDGET (self->device_cb->entry); g_signal_connect_swapped (G_OBJECT (dentry), "changed", G_CALLBACK (self_device_changed_cb), self); + g_signal_connect_swapped (G_OBJECT (self->color_button), "clicked", G_CALLBACK (self_change_color_cb), self); + if (self->execu_cb && g_find_program_in_path ("xfce4-mixer")) { item = gtk_list_item_new_with_label ("xfce4-mixer"); gtk_widget_show (item); @@ -228,6 +250,35 @@ ); } + protected void change_color_cb (self) + { + GtkWidget *dialog; + GtkColorSelection *colorsel; + gint response; + + dialog = gtk_color_selection_dialog_new(_("Select color")); + gtk_window_set_transient_for(GTK_WINDOW(dialog), + GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(self)))); + colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel); + gtk_color_selection_set_previous_color(colorsel, + self->bar_color); + gtk_color_selection_set_current_color(colorsel, + self->bar_color); + gtk_color_selection_set_has_palette(colorsel, TRUE); + + response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_OK) + { + gtk_color_selection_get_current_color(colorsel, + self->bar_color); + gtk_widget_modify_bg(self->color_da, + GTK_STATE_NORMAL, + self->bar_color); + } + + gtk_widget_destroy(dialog); + } + public XfceMixerPrefbox *new(void) { XfceMixerPrefbox* w; @@ -243,6 +294,7 @@ gboolean launcher_run_in_terminal; gboolean launcher_use_startup_notification; gchar* device; + gboolean launcher_show; gchar* master_control; launcher_command = NULL; @@ -256,15 +308,27 @@ return; } + if (self->bar_color) { + gdk_color_free (self->bar_color); + } + g_object_get (G_OBJECT (p), "launcher_command", &launcher_command, "launcher_run_in_terminal", &launcher_run_in_terminal, "launcher_use_startup_notification", &launcher_use_startup_notification, + "launcher_show", &launcher_show, + "bar_color", &self->bar_color, "device", &device, "master", &master_control, NULL ); + if (!self->bar_color) { + self->bar_color = g_new(GdkColor, 1); + gdk_color_parse("#00c000", self->bar_color); + } + gtk_widget_modify_bg(self->color_da, GTK_STATE_NORMAL, self->bar_color); + launcher_entry_set_command (self->launcher_entry, nvl (launcher_command, "xfce4-mixer"), launcher_run_in_terminal, @@ -272,6 +336,7 @@ ); gtk_entry_set_text (GTK_ENTRY (self->device_cb->entry), nvl (device, "")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(self->launcher_show_c), launcher_show); omi = self_find_master_by_name (self, master_control); @@ -303,6 +368,7 @@ gchar *master; gboolean startup_nf; gboolean in_terminal; + gboolean launcher_show; if (!p) return; @@ -315,12 +381,16 @@ launcher_entry_get_command (self->launcher_entry, &execu, &in_terminal, &startup_nf); + launcher_show = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->launcher_show_c)); + g_object_set (G_OBJECT (p), "device", device, "launcher_command", execu, "master", master, "launcher_use_startup_notification", startup_nf, "launcher_run_in_terminal", in_terminal, + "launcher_show", launcher_show, + "bar_color", self->bar_color, NULL ); @@ -331,4 +401,3 @@ g_free (master); } } - Index: mixer-preferences.gob =================================================================== --- mixer-preferences.gob (revision 25708) +++ mixer-preferences.gob (working copy) @@ -47,6 +47,8 @@ } }; + private gboolean launcher_show = TRUE; + private gchar *launcher_command = NULL destroy { if (VAR) { @@ -58,6 +60,14 @@ private gboolean launcher_run_in_terminal = FALSE; private gboolean launcher_use_startup_notification = FALSE; + private GdkColor *bar_color = NULL + destroy { + if (VAR) { + gdk_color_free (VAR); + VAR = NULL; + } + }; + protected GList *master_lst = NULL destroy { stringlist_free(VAR); @@ -118,6 +128,10 @@ g_value_set_string (VAL, selfp->launcher_command); }; + property BOOLEAN launcher_show + (nick = "show icon", + blurb = "show icon", link); + property BOOLEAN launcher_run_in_terminal (nick = "start the program in a terminal", blurb = "start the program in a terminal", link); @@ -126,6 +140,27 @@ (nick = "use startup notification", blurb = "use startup notification", link); + property POINTER bar_color + (nick = "bar color", + blurb = "color to paint the volume bar") + set { + GdkColor* val = g_value_peek_pointer (VAL); + if (selfp->bar_color) { + gdk_color_free (selfp->bar_color); + selfp->bar_color = NULL; + } + if (val) { + selfp->bar_color = gdk_color_copy (val); + } + } + get { + if (selfp->bar_color) { + GdkColor* val = gdk_color_copy (selfp->bar_color); + g_value_set_pointer (VAL, val); + } else + g_value_set_pointer (VAL, NULL); + }; + public XfceMixerPreferences *new(void) { return XFCE_MIXER_PREFERENCES (GET_NEW); @@ -208,14 +243,24 @@ gchar const* launcher_command; gboolean launcher_run_in_terminal; gboolean launcher_use_startup_notification; + gboolean launcher_show; gchar const* master_control; + gchar const* bar_color_s; + GdkColor* bar_color; device = xfce_rc_read_entry (rc, "Device", NULL); launcher_command = xfce_rc_read_entry (rc, "LauncherCommand", NULL); launcher_run_in_terminal = xfce_rc_read_bool_entry (rc, "LauncherRunInTerminal", FALSE); launcher_use_startup_notification = xfce_rc_read_bool_entry (rc, "LauncherUseStartupNotification", FALSE); + launcher_show = xfce_rc_read_bool_entry (rc, "LauncherShow", TRUE); master_control = xfce_rc_read_entry (rc, "MasterControl", NULL); + if ((bar_color_s = xfce_rc_read_entry (rc, "BarColor", NULL))) { + bar_color = g_new(GdkColor, 1); + gdk_color_parse(bar_color_s, bar_color); + } else + bar_color = NULL; + if (device) { g_object_set (G_OBJECT (self), "device", device, NULL); } @@ -224,6 +269,8 @@ "launcher_command", launcher_command, "launcher_run_in_terminal", (gboolean) launcher_run_in_terminal, "launcher_use_startup_notification", (gboolean) launcher_use_startup_notification, + "launcher_show", (gboolean) launcher_show, + "bar_color", bar_color, NULL); if (master_control) { @@ -245,14 +292,27 @@ gboolean launcher_run_in_terminal; gboolean launcher_use_startup_notification; gchar const* device; + gboolean launcher_show; gchar const* master_control; + gchar bar_color[8]; launcher_command = self->_priv->launcher_command; launcher_run_in_terminal = self->_priv->launcher_run_in_terminal; launcher_use_startup_notification = self->_priv->launcher_use_startup_notification; + launcher_show = self->_priv->launcher_show; device = self->_priv->device; master_control = self->_priv->master; + if (self->_priv->bar_color != NULL) { + g_snprintf(bar_color, 8, "#%02X%02X%02X", + (guint)self->_priv->bar_color->red >> 8, + (guint)self->_priv->bar_color->green >> 8, + (guint)self->_priv->bar_color->blue >> 8); + xfce_rc_write_entry (rc, "BarColor", bar_color); + } else { + xfce_rc_delete_entry (rc, "BarColor", FALSE); + } + if (device != NULL) { xfce_rc_write_entry (rc, "Device", device); } else { @@ -267,12 +327,12 @@ xfce_rc_write_bool_entry (rc, "LauncherRunInTerminal", launcher_run_in_terminal); xfce_rc_write_bool_entry (rc, "LauncherUseStartupNotification", launcher_use_startup_notification); + xfce_rc_write_bool_entry (rc, "LauncherShow", launcher_show); if (master_control != NULL) { xfce_rc_write_entry (rc, "MasterControl", master_control); } else { xfce_rc_delete_entry (rc, "MasterControl", FALSE); } - } } Index: mixer-slider-tiny.gob =================================================================== --- mixer-slider-tiny.gob (revision 25708) +++ mixer-slider-tiny.gob (working copy) @@ -93,7 +93,7 @@ y = (int)b->y; - if (b->button == 3 || b->button == 2) { + if (b->button == 2) { if (b->type == GDK_BUTTON_PRESS) { y = 0; } else { @@ -124,6 +124,11 @@ return XFCE_MIXER_CONTROL(GET_NEW); } + public void set_color (self, GdkColor *color) + { + gtk_widget_modify_bg(self->progress, GTK_STATE_PRELIGHT, color); + } + override (Xfce:Mixer:Control) void value_changed (Xfce:Mixer:Control *pself (check null type)) { Index: plugin.c =================================================================== --- plugin.c (revision 25708) +++ plugin.c (working copy) @@ -23,6 +23,7 @@ #define PLUGIN_NAME "xfce4-mixer-plugin" #define MIXER_RC_GROUP "mixer-plugin" +#define BORDER 8 /* Panel Plugin Interface */ static void mixer_construct (XfcePanelPlugin *plugin); @@ -60,7 +61,7 @@ DBG ("mixer_orientation_changed"); size = xfce_panel_plugin_get_size (plugin); - slider_width = 8; /* + 2 * size;*/ + slider_width = 8 + BORDER; /* + 2 * size;*/ if (orientation == GTK_ORIENTATION_VERTICAL) { gtk_widget_set_size_request (GTK_WIDGET(plugin), size, size); @@ -125,6 +126,8 @@ static void response_cb(GtkDialog* dialog, gint arg1, gpointer user_data) { + gboolean launcher_show; + GdkColor *bar_color; t_mixer *mixer = (t_mixer *) user_data; xfce_mixer_prefbox_save_preferences (mixer->prefbox, mixer->prefs); @@ -135,6 +138,19 @@ gtk_container_remove (GTK_CONTAINER(dialog->vbox), GTK_WIDGET(mixer->prefbox)); gtk_widget_destroy (GTK_WIDGET(dialog)); + + g_object_get (G_OBJECT (mixer->prefs), + "launcher_show", &launcher_show, + "bar_color", &bar_color, + NULL); + + if(launcher_show) + gtk_widget_show (GTK_WIDGET (mixer->ib)); + else + gtk_widget_hide (GTK_WIDGET (mixer->ib)); + + xfce_mixer_slider_tiny_set_color(XFCE_MIXER_SLIDER_TINY (mixer->slider), + bar_color); } static void @@ -228,6 +244,7 @@ xfce_mixer_prefbox_fill_defaults (mixer->prefbox); + /*gtk_container_set_border_width(GTK_CONTAINER(mixer->box), BORDER / 2);*/ gtk_widget_show (mixer->box); if ((gtk_major_version == 2 && gtk_minor_version >= 6) || @@ -438,10 +455,9 @@ t_mixer *mixer; GdkPixbuf *pb; GtkWidget *align; - + mixer = g_new0 (t_mixer, 1); - mixer->prefs = XFCE_MIXER_PREFERENCES (xfce_mixer_preferences_new ()); mixer->box = gtk_hbox_new (FALSE, 0); @@ -469,8 +485,10 @@ G_CALLBACK (mixer_value_changed_cb), mixer ); + gtk_container_set_border_width(GTK_CONTAINER(mixer->slider), + BORDER / 2); gtk_widget_show (GTK_WIDGET (mixer->slider)); - gtk_box_pack_start (GTK_BOX (mixer->box), GTK_WIDGET (mixer->slider), FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (mixer->box), GTK_WIDGET (mixer->slider), FALSE, FALSE, 0); g_signal_connect_swapped ( G_OBJECT (mixer->ib), "scroll-event",