From ac9049029faddf79272076e79c3f4ab33da778a6 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sat, 28 Nov 2009 16:04:45 +0000 Subject: [PATCH] More compact mode support. The notebook will disappear and is replaced by the queue. It's still disabled by default. Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/disobedience.c | 45 +++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 96bf5c6..10b62eb 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -100,6 +100,12 @@ const char *server_version; /** @brief Parsed server version */ long server_version_bytes; +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); @@ -154,7 +160,7 @@ static GtkWidget *notebook(void) { * produces not too dreadful appearance */ gtk_widget_set_style(tabs, tool_style); g_signal_connect(tabs, "switch-page", G_CALLBACK(tab_switched), 0); - gtk_notebook_append_page(GTK_NOTEBOOK(tabs), queue_widget(), + gtk_notebook_append_page(GTK_NOTEBOOK(tabs), queue = queue_widget(), gtk_label_new("Queue")); gtk_notebook_append_page(GTK_NOTEBOOK(tabs), recent_widget(), gtk_label_new("Recent")); @@ -165,6 +171,38 @@ static GtkWidget *notebook(void) { return tabs; } +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); + /* 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); + } + main_current_fullmode = full_mode; +} + /** @brief Create and populate the main window */ static void make_toplevel_window(void) { GtkWidget *const vbox = gtk_vbox_new(FALSE, 1); @@ -191,13 +229,16 @@ static void make_toplevel_window(void) { FALSE, /* expand */ FALSE, /* fill */ 0); - gtk_container_add(GTK_CONTAINER(vbox), notebook()); + notebook_box = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(notebook_box), notebook()); + gtk_container_add(GTK_CONTAINER(vbox), notebook_box); gtk_box_pack_end(GTK_BOX(vbox), rb, FALSE, /* expand */ FALSE, /* fill */ 0); gtk_widget_set_style(toplevel, tool_style); + event_register("mini-mode-changed", main_minimode, 0); } static void userinfo_rights_completed(void attribute((unused)) *v, -- [mdw]