chiark / gitweb /
A bit of work towards a mini-Disobedience mode (issue #30). Nowhere
authorRichard Kettlewell <rjk@greenend.org.uk>
Fri, 27 Nov 2009 21:03:16 +0000 (21:03 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Fri, 27 Nov 2009 21:03:16 +0000 (21:03 +0000)
near finished so the menu item is not added for now.

disobedience/control.c
disobedience/disobedience.h
disobedience/menu.c

index 931746a..e371ca9 100644 (file)
@@ -51,6 +51,9 @@ static void icon_changed(const char *event,
 static void volume_changed(const char *event,
                            void *eventdata,
                            void *callbackdata);
+static void control_minimode(const char *event,
+                             void *eventdata,
+                             void *callbackdata);
 
 /* Control bar ------------------------------------------------------------- */
 
@@ -308,27 +311,28 @@ GtkWidget *control_widget(void) {
                    G_CALLBACK(format_balance), 0);
   event_register("volume-changed", volume_changed, 0);
   event_register("rtp-changed", volume_changed, 0);
+  event_register("mini-mode-changed", control_minimode, 0);
   return hbox;
 }
 
+/** @brief Return TRUE if volume setting is supported */
+static int volume_supported(void) {
+  /* TODO: if the server doesn't know how to set the volume [but isn't using
+   * network play] then we should have volume_supported = FALSE */
+  return (!rtp_supported
+          || (rtp_supported && backend && backend->set_volume));
+}
+
 /** @brief Update the volume control when it changes */
 static void volume_changed(const char attribute((unused)) *event,
                            void attribute((unused)) *eventdata,
                            void attribute((unused)) *callbackdata) {
   double l, r;
-  gboolean volume_supported;
 
   D(("volume_changed"));
   ++suppress_actions;
   /* Only display volume/balance controls if they will work */
-  if(!rtp_supported
-     || (rtp_supported && backend && backend->set_volume))
-    volume_supported = TRUE;
-  else
-    volume_supported = FALSE;
-  /* TODO: if the server doesn't know how to set the volume [but isn't using
-   * network play] then we should have volume_supported = FALSE */
-  if(volume_supported) {
+  if(volume_supported()) {
     gtk_widget_show(volume_widget);
     gtk_widget_show(balance_widget);
     l = volume_l / 100.0;
@@ -559,6 +563,15 @@ static int disable_rtp(disorder_eclient attribute((unused)) *c,
   return 0;
 }
 
+static void control_minimode(const char attribute((unused)) *event,
+                             void attribute((unused)) *evendata,
+                             void attribute((unused)) *callbackdata) {
+  if(full_mode && volume_supported())
+    gtk_widget_show(balance_widget);
+  else
+    gtk_widget_hide(balance_widget);
+}
+
 /*
 Local Variables:
 c-basic-offset:2
index 8ce1601..a804863 100644 (file)
@@ -166,6 +166,7 @@ void all_update(void);
 
 GtkWidget *menubar(GtkWidget *w);
 /* Create the menu bar */
+int full_mode;
 
 void users_set_sensitive(int sensitive);
 
index 86ea177..d248b3f 100644 (file)
 
 #include "disobedience.h"
 
+static void toggled_minimode(GtkCheckMenuItem *item, gpointer userdata);
+
 static GtkWidget *selectall_widget;
 static GtkWidget *selectnone_widget;
 static GtkWidget *properties_widget;
 GtkWidget *menu_playlists_widget;
 GtkWidget *playlists_menu;
 GtkWidget *menu_editplaylists_widget;
+static GtkWidget *menu_minimode_widget;
 
 /** @brief Main menu widgets */
 GtkItemFactory *mainmenufactory;
 
+/** @brief Set for full mode, clear for mini mode */
+int full_mode;
+
 static void about_popup_got_version(void *v,
                                     const char *err,
                                     const char *value);
@@ -346,6 +352,16 @@ GtkWidget *menubar(GtkWidget *w) {
       (char *)"<CheckItem>",            /* item_type */
       0                                 /* extra_data */
     },
+#if 0
+    {
+      (char *)"/Control/Compact mode",  /* path */
+      (char *)"<CTRL>M",                /* accelerator */
+      0,                                /* callback */
+      0,                                /* callback_action */
+      (char *)"<CheckItem>",            /* item_type */
+      0                                 /* extra_data */
+    },
+#endif
     {
       (char *)"/Control/Activate playlist", /* path */
       0,                                /* accelerator */
@@ -404,6 +420,8 @@ GtkWidget *menubar(GtkWidget *w) {
                                                "<GdisorderMain>/Control/Activate playlist");
   menu_editplaylists_widget = gtk_item_factory_get_widget(mainmenufactory,
                                                      "<GdisorderMain>/Edit/Edit playlists");
+  menu_minimode_widget = gtk_item_factory_get_widget(mainmenufactory,
+                                                     "<GdisorderMain>/Control/Compact mode");
   assert(selectall_widget != 0);
   assert(selectnone_widget != 0);
   assert(properties_widget != 0);
@@ -420,9 +438,18 @@ GtkWidget *menubar(GtkWidget *w) {
   m = gtk_item_factory_get_widget(mainmenufactory,
                                   "<GdisorderMain>");
   set_tool_colors(m);
+  if(menu_minimode_widget)
+    g_signal_connect(G_OBJECT(menu_minimode_widget), "toggled",
+                     G_CALLBACK(toggled_minimode), NULL);
   return m;
 }
 
+static void toggled_minimode(GtkCheckMenuItem  *item,
+                             gpointer attribute((unused)) userdata) {
+  full_mode = !gtk_check_menu_item_get_active(item);
+  event_raise("mini-mode-changed", NULL);
+}
+
 /*
 Local Variables:
 c-basic-offset:2