Patch for Close All, Minimize All, Restore All for Grouped tasklists



Hi,

I have attached a patch, that will provide a button to close, minimize,
restore group of same tasks in libWNCK:tasklist.

Review it and provide me comments for improvisation.
I have also attached a screen shot of how it will look like.

Thanks
Srini.
Index: tasklist.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/tasklist.c,v
retrieving revision 1.56
diff -u -r1.56 tasklist.c
--- tasklist.c	10 Dec 2003 11:39:39 -0000	1.56
+++ tasklist.c	29 Jan 2004 06:41:38 -0000
@@ -248,6 +248,13 @@
                                                         WnckWindow     *window);
 #endif
 
+static void wnck_task_closeall(GtkMenuItem *menu_item,
+			  gpointer     data);
+static void wnck_task_minimizeall(GtkMenuItem *menu_item,
+			  gpointer     data);
+static void wnck_task_maximizeall(GtkMenuItem *menu_item,
+			  gpointer     data);
+
 
 static gpointer task_parent_class;
 static gpointer tasklist_parent_class;
@@ -1851,7 +1858,7 @@
   GtkWidget *menu_item;
   GtkWidget *image;
   GList *l, *list;
-  
+ 
   if (task->class_group == NULL)
     return;
   
@@ -1872,8 +1879,8 @@
   g_list_free (list);
   
   l = task->windows;
-  while (l)
-    {
+  while (l) 
+	{
       win_task = WNCK_TASK (l->data);
       
       text = wnck_task_get_text (win_task);
@@ -1881,21 +1888,21 @@
       g_free (text);
       
       pixbuf = wnck_task_get_icon (win_task);
-      if (pixbuf)
-	{
-	  image = gtk_image_new_from_pixbuf (pixbuf);
-	  gtk_widget_show (image);
-	  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
-					 image);
-	  g_object_unref (pixbuf);
-	}
+      if (pixbuf) 
+		{
+	  	  image = gtk_image_new_from_pixbuf (pixbuf);
+	  	  gtk_widget_show (image);
+	  	  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
+		  				  				 image);
+	  	  g_object_unref (pixbuf);	
+	  	}
       
       gtk_widget_show (menu_item);
 
-       if (action_submenu)
+      if (action_submenu)
          gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item),
                                     wnck_create_window_action_menu (win_task->window));
-       else
+      else
          g_signal_connect_object (G_OBJECT (menu_item), "activate",
                                   G_CALLBACK (wnck_task_menu_activated),
                                   G_OBJECT (win_task),
@@ -1906,16 +1913,112 @@
       l = l->next;
     }
 
-  gtk_menu_set_screen (GTK_MENU (menu),
-		       _wnck_screen_get_gdk_screen (task->tasklist->priv->screen));
+	/* In case of Right click, show Close All, Minimize All, Maximize All*/
+	if (action_submenu) 
+		{
+		  GtkWidget * separator;
+	  	  GtkWidget *image;
+		
+	  	  separator = gtk_separator_menu_item_new ();
+	  	  gtk_widget_show (separator);
+	  	  gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
+	    
+		  menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Minimize all"));
+		  image = gtk_image_new_from_stock (WNCK_STOCK_MINIMIZE, GTK_ICON_SIZE_MENU);
+		  gtk_widget_show (image);
+		  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);  	
+		  gtk_widget_show (menu_item);
+		  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+		  g_signal_connect_object (G_OBJECT (menu_item), "activate",
+							   G_CALLBACK (wnck_task_minimizeall),
+							   G_OBJECT (task),
+							   0);
+		
+		
+		  menu_item =  gtk_image_menu_item_new_with_mnemonic (_("_Restore all"));
+		  image = gtk_image_new_from_stock (WNCK_STOCK_MAXIMIZE, GTK_ICON_SIZE_MENU);
+		  gtk_widget_show (image);
+		  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);  	
+		  gtk_widget_show (menu_item);
+		  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+			
+		  g_signal_connect_object (G_OBJECT (menu_item), "activate",
+								   G_CALLBACK (wnck_task_maximizeall),
+								   G_OBJECT (task),
+								   0);
+			
+		  separator = gtk_separator_menu_item_new ();
+		  gtk_widget_show (separator);
+		  gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+								 separator);
+				
+		  menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Close all"));
+		  image = gtk_image_new_from_stock (WNCK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
+		  gtk_widget_show (image);
+		  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);    
+		  gtk_widget_show (menu_item);
+		  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+		  
+		  g_signal_connect_object (G_OBJECT (menu_item), "activate",
+								   G_CALLBACK (wnck_task_closeall),
+								   G_OBJECT (task),
+								   0);
+		}
+    gtk_menu_set_screen (GTK_MENU (menu),
+	  	       _wnck_screen_get_gdk_screen (task->tasklist->priv->screen));
   
-  gtk_widget_show (menu);
-  gtk_menu_popup (GTK_MENU (menu),
-		  NULL, NULL,
+    gtk_widget_show (menu);
+    gtk_menu_popup (GTK_MENU (menu),
+	  	  NULL, NULL,
 		  wnck_task_position_menu, task->button,
 		  1, gtk_get_current_event_time ());
 }
 
+static void wnck_task_closeall(GtkMenuItem *menu_item,
+			  gpointer     data)
+{
+  WnckTask *task = WNCK_TASK (data);
+  GList *l;
+
+  l = task->windows;
+  while (l)
+    {
+      WnckTask *child = WNCK_TASK(l->data);
+	  wnck_window_close (child->window);
+      l = l->next;
+    }
+}
+
+static void wnck_task_maximizeall(GtkMenuItem *menu_item,
+			  gpointer     data)
+{
+  WnckTask *task = WNCK_TASK (data);
+  GList *l;
+
+  l = task->windows;
+  while (l)
+    {
+      WnckTask *child = WNCK_TASK(l->data);
+	  wnck_window_unminimize (child->window);
+      l = l->next;
+    }
+}
+
+static void wnck_task_minimizeall(GtkMenuItem *menu_item,
+			  gpointer     data)
+{
+  WnckTask *task = WNCK_TASK (data);
+  GList *l;
+
+  l = task->windows;
+  while (l)
+    {
+      WnckTask *child = WNCK_TASK(l->data);
+	  wnck_window_minimize (child->window);
+      l = l->next;
+    }
+}
+
 static void
 wnck_task_button_toggled (GtkButton *button,
 			  WnckTask  *task)

Attachment: All.png
Description: PNG image



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]