Mercurial > pidgin
changeset 14335:b1b76fb9c739
[gaim-migrate @ 17031]
Add a sample window-manager. This one removes the border and shadows from
the buddylist, shows the conversation windows at the right-end of the screen,
and puts all the rest of the dialogs in the middle of the screen.
I was not planning on committing this just yet, but I accidentally included the
change in configure.ac, and I don't want to get yelled at ;)
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 25 Aug 2006 18:21:22 +0000 |
parents | 17eba43f98a9 |
children | f3ef96e8428f |
files | console/libgnt/Makefile.am console/libgnt/gntmain.c console/libgnt/gntstyle.c console/libgnt/gntstyle.h console/libgnt/gntwidget.c console/libgnt/gntwidget.h console/libgnt/gntwm.h console/libgnt/wms/Makefile.am console/libgnt/wms/s.c |
diffstat | 9 files changed, 136 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/console/libgnt/Makefile.am Fri Aug 25 18:17:22 2006 +0000 +++ b/console/libgnt/Makefile.am Fri Aug 25 18:21:22 2006 +0000 @@ -1,3 +1,4 @@ +SUBDIRS = wms pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = gnt.pc
--- a/console/libgnt/gntmain.c Fri Aug 25 18:17:22 2006 +0000 +++ b/console/libgnt/gntmain.c Fri Aug 25 18:21:22 2006 +0000 @@ -4,12 +4,15 @@ #include <panel.h> #endif +#include <gmodule.h> + #include "gnt.h" #include "gntbox.h" #include "gntcolors.h" #include "gntkeys.h" #include "gntstyle.h" #include "gnttree.h" +#include "gntwm.h" #include <stdio.h> #include <stdlib.h> @@ -38,6 +41,8 @@ static gboolean ascii_only; static gboolean mouse_enabled; +static GntWM wm; + static GMainLoop *loop; static struct { @@ -846,6 +851,24 @@ } #endif +static void +init_wm() +{ + const char *name = gnt_style_get(GNT_STYLE_WM); + gpointer handle; + + if (!name || !*name) + return; + + handle = g_module_open(name, G_MODULE_BIND_LAZY); + if (handle) { + gboolean (*init)(GntWM *); + if (g_module_symbol(handle, "gntwm_init", &init)) { + init(&wm); + } + } +} + void gnt_init() { static GIOChannel *channel = NULL; @@ -915,6 +938,8 @@ #endif g_type_init(); + + init_wm(); } void gnt_main() @@ -999,7 +1024,10 @@ node = g_hash_table_lookup(nodes, widget); if (node && !node->panel) { - node->panel = new_panel(node->me->window); + if (wm.new_window) + node->panel = wm.new_window(node->me); + else + node->panel = new_panel(node->me->window); if (!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT)) { bottom_panel(node->panel); /* New windows should not grab focus */
--- a/console/libgnt/gntstyle.c Fri Aug 25 18:17:22 2006 +0000 +++ b/console/libgnt/gntstyle.c Fri Aug 25 18:21:22 2006 +0000 @@ -143,6 +143,7 @@ } styles[] = {{"shadow", GNT_STYLE_SHADOW}, {"customcolor", GNT_STYLE_COLOR}, {"mouse", GNT_STYLE_MOUSE}, + {"wm", GNT_STYLE_WM}, {NULL, 0}}; if (error)
--- a/console/libgnt/gntstyle.h Fri Aug 25 18:17:22 2006 +0000 +++ b/console/libgnt/gntstyle.h Fri Aug 25 18:21:22 2006 +0000 @@ -5,12 +5,12 @@ GNT_STYLE_SHADOW = 0, GNT_STYLE_COLOR = 1, GNT_STYLE_MOUSE = 2, + GNT_STYLE_WM = 3, GNT_STYLES } GntStyle; void gnt_style_read_configure_file(const char *filename); -/* Returned strings are all lowercase */ const char *gnt_style_get(GntStyle style); gboolean gnt_style_get_bool(GntStyle style, gboolean def);
--- a/console/libgnt/gntwidget.c Fri Aug 25 18:17:22 2006 +0000 +++ b/console/libgnt/gntwidget.c Fri Aug 25 18:21:22 2006 +0000 @@ -545,6 +545,11 @@ widget->priv.name = g_strdup(name); } +const char *gnt_widget_get_name(GntWidget *widget) +{ + return widget->priv.name; +} + void gnt_widget_activate(GntWidget *widget) { g_signal_emit(widget, signals[SIG_ACTIVATE], 0);
--- a/console/libgnt/gntwidget.h Fri Aug 25 18:17:22 2006 +0000 +++ b/console/libgnt/gntwidget.h Fri Aug 25 18:21:22 2006 +0000 @@ -126,6 +126,8 @@ void gnt_widget_set_name(GntWidget *widget, const char *name); +const char *gnt_widget_get_name(GntWidget *widget); + /* Widget-subclasses should call this from the draw-callback. * Applications should just call gnt_widget_draw instead of this. */ void gnt_widget_queue_update(GntWidget *widget);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/gntwm.h Fri Aug 25 18:21:22 2006 +0000 @@ -0,0 +1,18 @@ +#ifdef HAVE_NCURSESW_INC +#include <ncursesw/panel.h> +#else +#include <panel.h> +#endif + +#include "gntwidget.h" + +typedef struct _GntWM GntWM; + +struct _GntWM +{ + PANEL *(*new_window)(GntWidget *win); + gboolean (*key_pressed)(const char *key); + gboolean (*mouse_clicked)(void); /* XXX: haven't decided yet */ + void (*gntwm_uninit)(); +}; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/wms/Makefile.am Fri Aug 25 18:21:22 2006 +0000 @@ -0,0 +1,23 @@ +s_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS) + +if PLUGINS + +plugin_LTLIBRARIES = \ + s.la + +plugindir = $(libdir)/gaim + +s_la_SOURCES = s.c + +endif # PLUGINS + +EXTRA_DIST = + +AM_CPPFLAGS = \ + -DDATADIR=\"$(datadir)\" \ + -DVERSION=\"$(VERSION)\" \ + -I$(top_srcdir)/console/libgnt \ + $(DEBUG_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(PLUGIN_CFLAGS) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/wms/s.c Fri Aug 25 18:21:22 2006 +0000 @@ -0,0 +1,56 @@ +#include "gntbox.h" +#include "gntwm.h" + +#include <string.h> + +static PANEL * +s_new_window(GntWidget *win) +{ + int x, y, w, h; + int maxx, maxy; + const char *name; + + getmaxyx(stdscr, maxy, maxx); + + gnt_widget_get_position(win, &x, &y); + gnt_widget_get_size(win, &w, &h); + + name = gnt_widget_get_name(win); + + if (name && strcmp(name, "buddylist") == 0) { + /* The buddylist doesn't have no border nor nothing! */ + x = 0; + y = 0; + h = maxy - 1; + + gnt_box_set_toplevel(GNT_BOX(win), FALSE); + GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_CAN_TAKE_FOCUS); + gnt_box_readjust(GNT_BOX(win)); + + gnt_widget_set_position(win, x, y); + mvwin(win->window, y, x); + + gnt_widget_set_size(win, w, h); + } else if (name && strcmp(name, "conversation-window") == 0) { + /* Put the conversation windows to the far-right */ + x = maxx - w; + y = 0; + gnt_widget_set_position(win, x, y); + mvwin(win->window, y, x); + } else if (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { + /* In the middle of the screen */ + x = (maxx - w) / 2; + y = (maxy - h) / 2; + + gnt_widget_set_position(win, x, y); + mvwin(win->window, y, x); + } + + return new_panel(win->window); +} + +void gntwm_init(GntWM *wm) +{ + wm->new_window = s_new_window; +} +