]> Dogcows Code - chaz/openbox/commitdiff
add the client_list_menu plugin
authorDana Jansens <danakj@orodu.net>
Thu, 14 Aug 2003 06:01:39 +0000 (06:01 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 14 Aug 2003 06:01:39 +0000 (06:01 +0000)
Makefile.am
openbox/plugin.c
plugins/menu/.cvsignore
plugins/menu/client_list_menu.c [new file with mode: 0644]

index 0b485927bcc7c84e1bd5bc8476e849dd9fe3a8ec..ae8cf62e23fb71affcce9b6bae3f9af4fa25341a 100644 (file)
@@ -30,7 +30,8 @@ plugin_LTLIBRARIES = \
        plugins/menu/timed_menu.la \
        plugins/menu/fifo_menu.la \
        plugins/menu/client_menu.la \
-       plugins/menu/include_menu.la
+       plugins/menu/include_menu.la \
+       plugins/menu/client_list_menu.la
 
 if OBCONF
 bin_PROGRAMS += \
@@ -265,6 +266,19 @@ plugins_menu_include_menu_la_LDFLAGS = \
 plugins_menu_include_menu_la_SOURCES = \
        plugins/menu/include_menu.c
 
+plugins_menu_client_list_menu_la_CPPFLAGS = \
+       $(XFT_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       $(LIBSN_CFLAGS) \
+       $(XML_CFLAGS) \
+       -DPLUGINDIR=\"$(plugindir)\" \
+       -DG_LOG_DOMAIN=\"Plugin-Client-List-Menu\"
+plugins_menu_client_list_menu_la_LDFLAGS = \
+       -module \
+       -avoid-version
+plugins_menu_client_list_menu_la_SOURCES = \
+       plugins/menu/client_list_menu.c
+
 
 ## obconf ##
 
index 18c55064e6651be18802cdfe6d4975ddb729a012..411eb6fbee5086a385f16174a365be9c08759be5 100644 (file)
@@ -161,6 +161,7 @@ void plugin_loadall(ObParseInst *i)
 
         /* XXX rm me when the parser loads me magically */
         plugin_open("client_menu", i);
+        plugin_open("client_list_menu", i);
     } else {
         /* load the plugins in the rc file */
         while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
index c5ffa0195fd377889a720dada22ae8025f6522fe..de4383e59dc520ba55a8633df8a547e005172a7d 100644 (file)
@@ -3,9 +3,11 @@
 timed_menu.la
 fifo_menu.la
 client_menu.la
+client_list_menu.la
 include_menu.la
 .dirstamp
 plugins_menu_client_menu_la-client_menu.lo
+plugins_menu_client_list_menu_la-client_list_menu.lo
 plugins_menu_fifo_menu_la-fifo_menu.lo
 plugins_menu_timed_menu_la-timed_menu.lo
 plugins_menu_include_menu_la-include_menu.lo
diff --git a/plugins/menu/client_list_menu.c b/plugins/menu/client_list_menu.c
new file mode 100644 (file)
index 0000000..166ac71
--- /dev/null
@@ -0,0 +1,142 @@
+#include "kernel/openbox.h"
+#include "kernel/menu.h"
+#include "kernel/action.h"
+#include "kernel/screen.h"
+#include "kernel/client.h"
+#include "kernel/focus.h"
+
+#include "render/theme.h"
+
+#include <glib.h>
+
+static char *PLUGIN_NAME = "client_list_menu";
+
+typedef struct {
+    GSList *submenus;
+} Client_List_Menu_Data;
+
+typedef struct {
+    guint desktop;
+} Client_List_Desktop_Menu_Data;
+
+#define CLIENT_LIST_MENU(m) ((ObMenu *)m)
+#define CLIENT_LIST_MENU_DATA(m) ((Client_List_Menu_Data *)((ObMenu *)m)->plugin_data)
+
+#define CLIENT_LIST_DESKTOP_MENU(m) ((ObMenu *)m)
+#define CLIENT_LIST_DESKTOP_MENU_DATA(m) ((Client_List_Desktop_Menu_Data *)((ObMenu *)m)->plugin_data)
+
+static void self_update(ObMenu *self);
+static void self_destroy(ObMenu *self);
+
+void plugin_setup_config() { }
+void plugin_shutdown() { }
+void plugin_destroy (ObMenu *m) { }
+
+void *plugin_create()
+{
+    ObMenu *menu = menu_new_full("Desktops", "client-list-menu", NULL,
+                                 NULL, self_update, NULL,
+                                 NULL, NULL, self_destroy);
+
+    menu->plugin = PLUGIN_NAME;
+    menu->plugin_data = g_new(Client_List_Menu_Data, 1);
+    CLIENT_LIST_MENU_DATA(menu)->submenus = NULL;
+
+    return (void *)menu;
+}
+
+void plugin_startup()
+{
+    plugin_create("client_list_menu");
+}
+
+
+static void desk_update(ObMenu *self)
+{
+    GList *it;
+    guint desk;
+
+    menu_clear(self);
+
+    desk = CLIENT_LIST_DESKTOP_MENU_DATA(self)->desktop;
+
+    for (it = focus_order[desk]; it; it = g_list_next(it)) {
+        ObClient *c = (ObClient *)it->data;
+        if (client_normal(c)) {
+            ObAction* a = action_from_string("activate");
+            a->data.activate.c = c;
+            menu_add_entry(self, menu_entry_new((c->iconic ?
+                                                 c->icon_title :
+                                                 c->title), a));
+        }
+    }
+
+    menu_render(self);
+}
+
+static void desk_selected(ObMenuEntry *entry,
+                          unsigned int button, unsigned int x, unsigned int y)
+{
+    entry->action->data.activate.here = (button == 2);
+    entry->parent->client = entry->action->data.activate.c;
+    menu_entry_fire(entry, button, x, y);
+}
+
+static void desk_destroy(ObMenu *self)
+{
+    g_free(self->plugin_data);
+}
+
+static void self_update(ObMenu *self)
+{
+    guint i, n;
+    ObMenu *deskmenu;
+    gchar *s;
+    GList *eit, *enext;
+    GSList *sit, *snext;
+
+    n = g_slist_length(CLIENT_LIST_MENU_DATA(self)->submenus);
+
+    for (i = 0; i < screen_num_desktops; ++i) {
+        if (i >= n) {
+            s = g_strdup_printf("client-list-menu-desktop-%d", i);
+            deskmenu = menu_new_full(screen_desktop_names[i], s, self,
+                                     NULL,
+                                     desk_update, desk_selected, NULL, NULL,
+                                     desk_destroy);
+            g_free(s);
+
+            deskmenu->plugin = PLUGIN_NAME;
+            deskmenu->plugin_data = g_new(Client_List_Desktop_Menu_Data, 1);
+            CLIENT_LIST_DESKTOP_MENU_DATA(deskmenu)->desktop = i;
+
+            CLIENT_LIST_MENU_DATA(self)->submenus =
+                g_slist_append(CLIENT_LIST_MENU_DATA(self)->submenus,
+                               deskmenu);
+        }
+
+        menu_add_entry(self, menu_entry_new_submenu(screen_desktop_names[i],
+                                                    deskmenu));
+    }
+
+    for (eit = g_list_nth(self->entries, i); eit; eit = enext) {
+        enext = g_list_next(eit);
+       menu_entry_free(eit->data);
+        self->entries = g_list_delete_link(self->entries, eit);
+    }
+
+    for (sit = g_slist_nth(CLIENT_LIST_MENU_DATA(self)->submenus, i);
+         sit; sit = snext) {
+        snext = g_slist_next(sit);
+        menu_free(sit->data);
+        CLIENT_LIST_MENU_DATA(self)->submenus = 
+            g_slist_delete_link(CLIENT_LIST_MENU_DATA(self)->submenus, sit);
+    }
+
+    menu_render(self);
+}
+
+static void self_destroy(ObMenu *self)
+{
+    g_free(self->plugin_data);
+}
This page took 0.029389 seconds and 4 git commands to generate.