chiark / gitweb /
Track window size between main and compact mode.
authorRichard Kettlewell <rjk@greenend.org.uk>
Tue, 1 Dec 2009 18:49:20 +0000 (18:49 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Tue, 1 Dec 2009 18:49:20 +0000 (18:49 +0000)
Enable compact mode support.

CHANGES.html
disobedience/disobedience.c
disobedience/menu.c

index b9ed4e3..17da951 100644 (file)
@@ -99,7 +99,8 @@ span.command {
       &ldquo;Recent&rdquo;, &ldquo;Added&rdquo; and &ldquo;Choose&rdquo; tabs
       to the queue.</p>
 
-      <p>Disobedience now supports playlist editing.</p>
+      <p>Disobedience now supports playlist editing and has a compact mode,
+      available from the <b>Control</b> menu.</p>
 
       <p>Disobedience has a <a href="disobedience/manual/index.html">new
       manual</a>.</p>
index 95949f6..8ca36e5 100644 (file)
@@ -172,6 +172,10 @@ static GtkWidget *notebook(void) {
   return tabs;
 }
 
+/* Tracking of window sizes */
+static int toplevel_width = 640, toplevel_height = 480;
+static int mini_width = 480, mini_height = 140;
+
 static void main_minimode(const char attribute((unused)) *event,
                           void attribute((unused)) *evendata,
                           void attribute((unused)) *callbackdata) {
@@ -180,9 +184,24 @@ static void main_minimode(const char attribute((unused)) *event,
     gtk_widget_hide(playing_mini);
     /* Show the queue (bit confusing otherwise!) */
     gtk_notebook_set_current_page(GTK_NOTEBOOK(tabs), 0);
+    gtk_window_resize(GTK_WINDOW(toplevel), toplevel_width, toplevel_height);
   } else {
     gtk_widget_hide(tabs);
     gtk_widget_show(playing_mini);
+    gtk_window_resize(GTK_WINDOW(toplevel), mini_width, mini_height);
+  }
+}
+
+/* Called when the window size is allocate */
+static void toplevel_size_allocate(GtkWidget attribute((unused)) *w,
+                                   GtkAllocation *a,
+                                   gpointer attribute((unused)) user_data) {
+  if(full_mode) {
+    toplevel_width = a->width;
+    toplevel_height = a->height;
+  } else {
+    mini_width = a->width;
+    mini_height = a->height;
   }
 }
 
@@ -194,10 +213,14 @@ static void make_toplevel_window(void) {
   D(("top_window"));
   toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   /* default size is too small */
-  gtk_window_set_default_size(GTK_WINDOW(toplevel), 640, 480);
+  gtk_window_set_default_size(GTK_WINDOW(toplevel),
+                              toplevel_width, toplevel_height);
   /* terminate on close */
   g_signal_connect(G_OBJECT(toplevel), "delete_event",
                    G_CALLBACK(delete_event), NULL);
+  /* track size */
+  g_signal_connect(G_OBJECT(toplevel), "size-allocate",
+                   G_CALLBACK(toplevel_size_allocate), NULL);
   /* lay out the window */
   gtk_window_set_title(GTK_WINDOW(toplevel), "Disobedience");
   gtk_container_add(GTK_CONTAINER(toplevel), vbox);
index f54fe4a..8947426 100644 (file)
@@ -352,7 +352,6 @@ GtkWidget *menubar(GtkWidget *w) {
       (char *)"<CheckItem>",            /* item_type */
       0                                 /* extra_data */
     },
-#if 0
     {
       (char *)"/Control/Compact mode",  /* path */
       (char *)"<CTRL>M",                /* accelerator */
@@ -361,7 +360,6 @@ GtkWidget *menubar(GtkWidget *w) {
       (char *)"<CheckItem>",            /* item_type */
       0                                 /* extra_data */
     },
-#endif
     {
       (char *)"/Control/Activate playlist", /* path */
       0,                                /* accelerator */