chiark / gitweb /
Mini-mode now hides/shows tab group widget and has a separate label
authorRichard Kettlewell <rjk@greenend.org.uk>
Mon, 30 Nov 2009 20:10:32 +0000 (20:10 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Mon, 30 Nov 2009 20:10:32 +0000 (20:10 +0000)
for the currently playing track (which is currently not well
implemented or updated, but never mind...)

disobedience/disobedience.c
disobedience/disobedience.h
disobedience/queue.c

index 10b62eb..95949f6 100644 (file)
@@ -44,6 +44,9 @@ GtkWidget *report_label;
 /** @brief Main tab group */
 GtkWidget *tabs;
 
+/** @brief Mini-mode widget for playing track */
+GtkWidget *playing_mini;
+
 /** @brief Main client */
 disorder_eclient *client;
 
@@ -104,8 +107,6 @@ static GtkWidget *queue;
 
 static GtkWidget *notebook_box;
 
-static int main_current_fullmode = 1;
-
 static void check_rtp_address(const char *event,
                               void *eventdata,
                               void *callbackdata);
@@ -174,33 +175,15 @@ static GtkWidget *notebook(void) {
 static void main_minimode(const char attribute((unused)) *event,
                           void attribute((unused)) *evendata,
                           void attribute((unused)) *callbackdata) {
-  if(full_mode == main_current_fullmode)
-    return;
   if(full_mode) {
-    /* Remove queue from display */
-    g_object_ref(queue);
-    gtk_container_remove(GTK_CONTAINER(notebook_box), queue);
-    /* Add queue to notebook */
-    gtk_notebook_prepend_page(GTK_NOTEBOOK(tabs), queue,
-                              gtk_label_new("Queue"));
-    g_object_unref(queue);
-    /* Add notebook to display */
-    gtk_container_add(GTK_CONTAINER(notebook_box), tabs);
-    g_object_unref(tabs);
+    gtk_widget_show(tabs);
+    gtk_widget_hide(playing_mini);
     /* Show the queue (bit confusing otherwise!) */
     gtk_notebook_set_current_page(GTK_NOTEBOOK(tabs), 0);
   } else {
-    /* Remove notebook from display */
-    g_object_ref(tabs);
-    gtk_container_remove(GTK_CONTAINER(notebook_box), tabs);
-    /* Remove queue from notebook */
-    g_object_ref(queue);
-    gtk_container_remove(GTK_CONTAINER(tabs), queue);
-    /* Add queue to display */
-    gtk_container_add(GTK_CONTAINER(notebook_box), queue);
-    g_object_unref(queue);
+    gtk_widget_hide(tabs);
+    gtk_widget_show(playing_mini);
   }
-  main_current_fullmode = full_mode;
 }
 
 /** @brief Create and populate the main window */
@@ -229,6 +212,12 @@ static void make_toplevel_window(void) {
                      FALSE,             /* expand */
                      FALSE,             /* fill */
                      0);
+  playing_mini = playing_widget();
+  gtk_box_pack_start(GTK_BOX(vbox),
+                     playing_mini,
+                     FALSE,
+                     FALSE,
+                     0);
   notebook_box = gtk_vbox_new(FALSE, 0);
   gtk_container_add(GTK_CONTAINER(notebook_box), notebook());
   gtk_container_add(GTK_CONTAINER(vbox), notebook_box);
@@ -518,6 +507,7 @@ int main(int argc, char **argv) {
   /* reset styles now everything has its name */
   gtk_rc_reset_styles(gtk_settings_get_for_screen(gdk_screen_get_default()));
   gtk_widget_show_all(toplevel);
+  gtk_widget_hide(playing_mini);
   /* issue a NOP every so often */
   g_timeout_add_full(G_PRIORITY_LOW,
                      2000/*interval, ms*/,
index a804863..719eea4 100644 (file)
@@ -180,6 +180,7 @@ extern int suppress_actions;
 /* Queue/Recent/Added */
 
 GtkWidget *queue_widget(void);
+GtkWidget *playing_widget(void);
 GtkWidget *recent_widget(void);
 GtkWidget *added_widget(void);
 /* Create widgets for displaying the queue, the recently played list and the
index d378899..7c0855f 100644 (file)
@@ -55,8 +55,7 @@ static void queue_playing_changed(void) {
         break;
     if(q) {
       disorder_eclient_playing(client, playing_completed, 0);
-      if(full_mode)
-        disorder_eclient_queue(client, queue_completed, 0);
+      disorder_eclient_queue(client, queue_completed, 0);
       return;
     }
   }
@@ -73,7 +72,7 @@ static void queue_playing_changed(void) {
   ql_new_queue(&ql_queue, q);
   /* Tell anyone who cares */
   event_raise("queue-list-changed", q);
-  event_raise("playing-track-changed", q);
+  event_raise("playing-track-changed", playing_track);
 }
 
 /** @brief Update the queue itself */
@@ -84,10 +83,7 @@ static void queue_completed(void attribute((unused)) *v,
     popup_protocol_error(0, err);
     return;
   }
-  if(full_mode)
-    actual_queue = q;
-  else
-    actual_queue = NULL;
+  actual_queue = q;
   queue_playing_changed();
 }
 
@@ -112,8 +108,6 @@ static void queue_changed(const char attribute((unused)) *event,
                            void  attribute((unused)) *eventdata,
                            void  attribute((unused)) *callbackdata) {
   D(("queue_changed"));
-  if(!full_mode)
-    return;
   gtk_label_set_text(GTK_LABEL(report_label), "updating queue");
   disorder_eclient_queue(client, queue_completed, 0);
 }
@@ -293,27 +287,12 @@ static gboolean queue_key_press(GtkWidget attribute((unused)) *widget,
   return FALSE;                         /* Propagate */
 }
 
-static void queue_minimode(const char attribute((unused)) *event,
-                           void attribute((unused)) *evendata,
-                           void attribute((unused)) *callbackdata) {
-  if(full_mode) {
-    /* We will need to refetch the queue */
-    disorder_eclient_queue(client, queue_completed, 0);
-  } else {
-    /* We will need to hide the queue */
-    if(actual_queue)
-      queue_completed(NULL, NULL, NULL);
-  }
-}
-
 GtkWidget *queue_widget(void) {
   GtkWidget *const w = init_queuelike(&ql_queue);
 
   /* Catch keypresses */
   g_signal_connect(ql_queue.view, "key-press-event",
                    G_CALLBACK(queue_key_press), &ql_queue);
-  
-  event_register("mini-mode-changed", queue_minimode, 0);
   return w;
 }
 
@@ -330,6 +309,31 @@ int queued(const char *track) {
   return 0;
 }
 
+/* Playing widget for mini-mode */
+
+static void queue_set_playing_widget(const char attribute((unused)) *event,
+                                     void *eventdata,
+                                     void *callbackdata) {
+  GtkLabel *w = callbackdata;
+  struct queue_entry *p = eventdata;
+
+  if(p) {
+    const char *title = namepart(p->track, "display", "title");
+    gtk_label_set_text(w, title);
+    // TODO handle namepart updates
+    // TODO include played-so-far
+  } else
+    gtk_label_set_text(w, "");
+}
+
+GtkWidget *playing_widget(void) {
+  GtkWidget *w = gtk_label_new("");
+  event_register("playing-track-changed",
+                 queue_set_playing_widget,
+                 w);
+  return w;
+}
+
 /*
 Local Variables:
 c-basic-offset:2