diff --git a/.config/rules.mk b/.config/rules.mk index 79e4983..bacca3d 100644 --- a/.config/rules.mk +++ b/.config/rules.mk @@ -38,7 +38,7 @@ SPACE := $(EMPTY) $(EMPTY) # recurion rules # ############################################### -RGOALS = all clean install svnignore +RGOALS = all clean install svnignore gitignore .PHONY : $(RGOALS) $(SUBDIRS) $(RGOALS) : $(SUBDIRS) @@ -155,10 +155,14 @@ endif endif ifeq ($(origin CFLAGS),undefined) -CFLAGS = -O2 +ifeq ($(origin DEBUG),undefined) +CFLAGS = -O2 -Wall -Werror +else +CFLAGS = -O0 -Wall -Werror +endif endif ifneq ($(origin DEBUG),undefined) -override CFLAGS += -g +override CFLAGS += -g3 endif override CFLAGS += -I$(TOPDIR) $(CFLAGS_EXTRA) @@ -263,7 +267,7 @@ install: endef % : %.in - @echo "TEXT $@" + @echo " TEXT $@" $Q$(TOPDIR)/repl.py < $^ > $@ @@ -285,7 +289,7 @@ endif clean: ifneq (,$(CLEANLIST)) - $(call summary,CLEAN ,) + $(call summary,CLEAN ,) $Qrm -rf $(CLEANLIST) endif @@ -324,3 +328,11 @@ svnignore: svn propset svn:ignore --file $$prop .; \ rm -f $$prop +help_target :: + @echo "gitignore - tell git to ignore files in a cleanlist" + +gitignore: + $Qfor i in $(DISTCLEANLIST) $(CLEANLIST); do echo "$$i"; \ + done > .gitignore + $Qgit add .gitignore + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b4da2c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +config.mk +config.h +repl.py +.config/*.pyc diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1f8790f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ + +## Version: 7.0 +Date: 2015-12-05 08:25:36 + + * [#12] fix menu position for top panel + * [#11] new plugin: user menu with gravatar icon + * [#8] Fix for issue #5 (make battery plugin work with /sys) + * [#6] Rounded corners don't work with widthtype=request + * [#5] make battery plugin work with /sys + * [#4] update README + * [#2] Include option for vertical (y) and horizontal (x) margin + +[#12]: https://github.com/aanatoly/fbpanel/issues/12 +[#11]: https://github.com/aanatoly/fbpanel/issues/11 +[#8]: https://github.com/aanatoly/fbpanel/pull/8 +[#6]: https://github.com/aanatoly/fbpanel/issues/6 +[#5]: https://github.com/aanatoly/fbpanel/issues/5 +[#4]: https://github.com/aanatoly/fbpanel/issues/4 +[#2]: https://github.com/aanatoly/fbpanel/issues/2 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 8e73413..0000000 --- a/INSTALL +++ /dev/null @@ -1,17 +0,0 @@ -Installation: - -1. Default way -Most users (99.99%) should use this way :-) - - ./configure - make - su - - make install - -2. Litle customization -Run ./configure --help to see supported options, then goto step 1 - - - - - diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..329a09d --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,27 @@ +# Installation: + +## User install +Build and install it +``` +./configure --prefix=$HOME/.local +make +make install +``` + +Then add `~/.local/bin/` to your `PATH`. Add this line to `~/.bashrc` +``` +export PATH=$HOME/.local/bin:$PATH +``` + +## System Install +Build and install it +``` +./configure +make +su -c "make install" +``` + +# Dependencies +Deps: + * core - gtk2 2.17 or higher + * plugin `foo` - bar 1.0 diff --git a/README b/README deleted file mode 100644 index 2d884bb..0000000 --- a/README +++ /dev/null @@ -1,64 +0,0 @@ - fbpanel - -NAME - fbpanel is a lightweight GTK2-based panel for UNIX desktop - -SYNOPSYS - fbpanel [OPTION]... - -DESCRIPTION - fbpanel is desktop panel which provides graphical information and feedback about - desktop activity and allows interaction with the window manager. - It features: - o taskbar - show list of the managed windows (tasks) - o pager - thumbnailed view of the desktop - o launchbar - buttons to quickly launch applications - o show desktop - button to iconify or shade all windows - o image - display an image - o clock - show the current time and/or date - o system tray - tray for XEMBED icons (aka docklets) - o space - just seize space - o menu - menu with text and images - o deskno - display desktop number and name - fbpanel requires NETWM (www.freedesktop.org) compliant window manager. - - You can run many instances of fbpanel each with its own configuration - (see OPTIONS below). - - Most updated info about fbpanel can be found on its home page: - http://fbpanel.sf.net/ - -OPTIONS - --help -- print this help and exit - --version -- print version and exit - --log -- set log level 0-5. 0 - none 5 - chatty - --configure -- launch configuration utility - --profile name -- use specified profile - - -h -- same as --help - -p -- same as --profile - -v -- same as --version - -C -- same as --configure - - -CUSTOMIZATION - To change default settings, copy profile file to your home directory - mkdir -p ~/.fbpanel - cp /usr/share/fbpanel/default ~/.fbpanel - and edit it. Default profile file contains comments and explanation inside, - so it should be easy. For full list of options please visit fbpanel's home page - -FILES - /usr/share/fbpanel - Directory with system wide resources and default settings - - ~/.fbpanel/ - Directory with user's private configurations - - ~/.fbpanel/default - Default profile - -AUTHORS - Anatoly Asviyan - - diff --git a/README.md b/README.md new file mode 100644 index 0000000..605d51c --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# fbpanel +A lightweight gtk2 panel for Linux desktop. + +Please visit [project web site](http://aanatoly.github.io/fbpanel/) +for more information. + +![shot](/data/shot.png) diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/data/config/.gitignore b/data/config/.gitignore new file mode 100644 index 0000000..133e0b7 --- /dev/null +++ b/data/config/.gitignore @@ -0,0 +1,2 @@ +default +pager diff --git a/data/images/.gitignore b/data/images/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/data/man/.gitignore b/data/man/.gitignore new file mode 100644 index 0000000..b0e7d13 --- /dev/null +++ b/data/man/.gitignore @@ -0,0 +1 @@ +fbpanel.1 diff --git a/data/shot.png b/data/shot.png new file mode 100644 index 0000000..59a6c7f Binary files /dev/null and b/data/shot.png differ diff --git a/exec/.gitignore b/exec/.gitignore new file mode 100644 index 0000000..4b7430e --- /dev/null +++ b/exec/.gitignore @@ -0,0 +1 @@ +make_profile diff --git a/panel/.gitignore b/panel/.gitignore new file mode 100644 index 0000000..7742cf7 --- /dev/null +++ b/panel/.gitignore @@ -0,0 +1,25 @@ +bg.o +bg.d +ev.o +ev.d +gconf.o +gconf.d +gconf_panel.o +gconf_panel.d +gconf_plugins.o +gconf_plugins.d +gtkbar.o +gtkbar.d +gtkbgbox.o +gtkbgbox.d +misc.o +misc.d +panel.o +panel.d +plugin.o +plugin.d +run.o +run.d +xconf.o +xconf.d +fbpanel diff --git a/panel/bg.c b/panel/bg.c index 70b7bbf..e22431b 100644 --- a/panel/bg.c +++ b/panel/bg.c @@ -101,7 +101,7 @@ fb_bg_class_init (FbBgClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); ENTER; - signals [CHANGED] = + signals [CHANGED] = g_signal_new ("changed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -154,7 +154,7 @@ fb_bg_finalize (GObject *object) bg = FB_BG (object); XFreeGC(bg->dpy, bg->gc); default_bg = NULL; - + RET(); } @@ -190,7 +190,7 @@ fb_bg_get_xrootpmap_real(FbBg *bg) ret = *((Pixmap *)prop); c = -c ; //to quit loop } - XFree(prop); + XFree(prop); } } while (--c > 0); } @@ -206,7 +206,7 @@ fb_bg_get_xroot_pix_for_area(FbBg *bg, gint x, gint y, { GdkPixmap *gbgpix; Pixmap bgpix; - + ENTER; if (bg->pixmap == None) RET(NULL); @@ -235,7 +235,7 @@ fb_bg_get_xroot_pix_for_win(FbBg *bg, GtkWidget *widget) if (bg->pixmap == None) RET(NULL); - win = GDK_WINDOW_XWINDOW(widget->window); + win = GDK_WINDOW_XWINDOW(widget->window); if (!XGetGeometry(bg->dpy, win, &dummy, &x, &y, &width, &height, &border, &depth)) { DBG2("XGetGeometry failed\n"); @@ -263,7 +263,7 @@ fb_bg_composite(GdkDrawable *base, GdkGC *gc, guint32 tintcolor, gint alpha) GdkPixbuf *ret, *ret2; int w, h; static GdkColormap *cmap = NULL; - + ENTER; gdk_drawable_get_size (base, &w, &h); if (!cmap) { @@ -274,7 +274,7 @@ fb_bg_composite(GdkDrawable *base, GdkGC *gc, guint32 tintcolor, gint alpha) if (!ret) RET(); DBG("here w=%d h=%d\n", w, h); - ret2 = gdk_pixbuf_composite_color_simple(ret, w, h, + ret2 = gdk_pixbuf_composite_color_simple(ret, w, h, GDK_INTERP_HYPER, 255-alpha, MIN(w, h), tintcolor, tintcolor); DBG("here\n"); if (!ret2) { @@ -297,7 +297,7 @@ fb_bg_changed(FbBg *bg) bg->pixmap = fb_bg_get_xrootpmap_real(bg); if (bg->pixmap != None) { XGCValues gcv; - + gcv.tile = bg->pixmap; XChangeGC(bg->dpy, bg->gc, GCTile, &gcv); DBG("changed\n"); diff --git a/panel/ev.c b/panel/ev.c index a2a04cf..b240560 100644 --- a/panel/ev.c +++ b/panel/ev.c @@ -59,7 +59,7 @@ struct _FbEv { Window active_window; Window *client_list; Window *client_list_stacking; - + Window xroot; Atom id; GC gc; @@ -113,7 +113,7 @@ fb_ev_class_init (FbEvClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - signals [EV_CURRENT_DESKTOP] = + signals [EV_CURRENT_DESKTOP] = g_signal_new ("current_desktop", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -121,7 +121,7 @@ fb_ev_class_init (FbEvClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [EV_NUMBER_OF_DESKTOPS] = + signals [EV_NUMBER_OF_DESKTOPS] = g_signal_new ("number_of_desktops", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -129,7 +129,7 @@ fb_ev_class_init (FbEvClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [EV_DESKTOP_NAMES] = + signals [EV_DESKTOP_NAMES] = g_signal_new ("desktop_names", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -137,7 +137,7 @@ fb_ev_class_init (FbEvClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [EV_ACTIVE_WINDOW] = + signals [EV_ACTIVE_WINDOW] = g_signal_new ("active_window", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -145,7 +145,7 @@ fb_ev_class_init (FbEvClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [EV_CLIENT_LIST_STACKING] = + signals [EV_CLIENT_LIST_STACKING] = g_signal_new ("client_list_stacking", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -153,7 +153,7 @@ fb_ev_class_init (FbEvClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [EV_CLIENT_LIST] = + signals [EV_CLIENT_LIST] = g_signal_new ("client_list", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, @@ -191,7 +191,7 @@ fb_ev_new() static void fb_ev_finalize (GObject *object) { - FbEv *ev; + FbEv *ev G_GNUC_UNUSED; ev = FB_EV (object); //XFreeGC(ev->dpy, ev->gc); @@ -274,11 +274,11 @@ fb_ev_current_desktop(FbEv *ev) ev->current_desktop = *data; XFree (data); } else - ev->current_desktop = 0; + ev->current_desktop = 0; } RET(ev->current_desktop); } - + int fb_ev_number_of_desktops(FbEv *ev) { @@ -291,7 +291,7 @@ fb_ev_number_of_desktops(FbEv *ev) ev->number_of_desktops = *data; XFree (data); } else - ev->number_of_desktops = 0; + ev->number_of_desktops = 0; } RET(ev->number_of_desktops); diff --git a/panel/gconf.c b/panel/gconf.c index a41c0e9..6d0c85c 100644 --- a/panel/gconf.c +++ b/panel/gconf.c @@ -25,7 +25,7 @@ gconf_block_new(GCallback cb, gpointer data, int indent) gtk_widget_set_size_request(w, indent, -1); gtk_box_pack_start(GTK_BOX(b->main), w, FALSE, FALSE, 0); } - + /* area */ w = gtk_vbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(b->main), w, FALSE, FALSE, 0); @@ -47,11 +47,11 @@ void gconf_block_add(gconf_block *b, GtkWidget *w, gboolean new_row) { GtkWidget *hbox; - + if (!b->rows || new_row) { GtkWidget *s; - + new_row = TRUE; hbox = gtk_hbox_new(FALSE, 8); b->rows = g_slist_prepend(b->rows, hbox); @@ -80,7 +80,7 @@ static void gconf_edit_int_cb(GtkSpinButton *w, xconf *xc) { int i; - + i = (int) gtk_spin_button_get_value(w); xconf_set_int(xc, i); } @@ -112,7 +112,7 @@ static void gconf_edit_enum_cb(GtkComboBox *w, xconf *xc) { int i; - + i = gtk_combo_box_get_active(w); DBG("%s=%d\n", xc->name, i); xconf_set_enum(xc, i, g_object_get_data(G_OBJECT(w), "enum")); @@ -153,7 +153,7 @@ static void gconf_edit_bool_cb(GtkToggleButton *w, xconf *xc) { int i; - + i = gtk_toggle_button_get_active(w); DBG("%s=%d\n", xc->name, i); xconf_set_enum(xc, i, bool_enum); @@ -169,7 +169,7 @@ gconf_edit_boolean(gconf_block *b, xconf *xc, gchar *text) xconf_set_enum(xc, i, bool_enum); w = gtk_check_button_new_with_label(text); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), i); - + g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(gconf_edit_bool_cb), xc); if (b && b->cb) @@ -190,7 +190,7 @@ gconf_edit_color_cb(GtkColorButton *w, xconf *xc) { GdkColor c; xconf *xc_alpha; - + gtk_color_button_get_color(GTK_COLOR_BUTTON(w), &c); xconf_set_value(xc, gdk_color_to_RRGGBB(&c)); if ((xc_alpha = g_object_get_data(G_OBJECT(w), "alpha"))) @@ -204,18 +204,18 @@ gconf_edit_color_cb(GtkColorButton *w, xconf *xc) GtkWidget * gconf_edit_color(gconf_block *b, xconf *xc_color, xconf *xc_alpha) { - + GtkWidget *w; GdkColor c; gdk_color_parse(xconf_get_value(xc_color), &c); - + w = gtk_color_button_new(); gtk_color_button_set_color(GTK_COLOR_BUTTON(w), &c); if (xc_alpha) { gint a; - + xconf_get_int(xc_alpha, &a); a <<= 8; /* scale to 0..FFFF from 0..FF */ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(w), (guint16) a); @@ -223,7 +223,7 @@ gconf_edit_color(gconf_block *b, xconf *xc_color, xconf *xc_alpha) } gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(w), xc_alpha != NULL); - + g_signal_connect(G_OBJECT(w), "color-set", G_CALLBACK(gconf_edit_color_cb), xc_color); if (b && b->cb) diff --git a/panel/gconf_panel.c b/panel/gconf_panel.c index a88e60a..25d55cc 100644 --- a/panel/gconf_panel.c +++ b/panel/gconf_panel.c @@ -7,7 +7,7 @@ static GtkWidget *dialog; static GtkWidget *width_spin, *width_opt; -static GtkWidget *margin_spin; +static GtkWidget *xmargin_spin, *ymargin_spin; static GtkWidget *allign_opt; static gconf_block *gl_block; @@ -31,7 +31,7 @@ static void effects_changed(gconf_block *b) { int i; - + ENTER; XCG(b->data, "transparent", &i, enum, bool_enum); gtk_widget_set_sensitive(color_block->main, i); @@ -48,7 +48,7 @@ static void mk_effects_block(xconf *xc) { GtkWidget *w; - + ENTER; /* label */ @@ -71,7 +71,7 @@ mk_effects_block(xconf *xc) w = gconf_edit_color(color_block, xconf_get(xc, "tintcolor"), xconf_get(xc, "alpha")); gconf_block_add(color_block, w, FALSE); - + gconf_block_add(effects_block, color_block->main, TRUE); /* round corners */ @@ -101,12 +101,12 @@ mk_effects_block(xconf *xc) w = gtk_label_new(_("pixels")); gconf_block_add(ah_block, w, FALSE); gconf_block_add(effects_block, ah_block->main, TRUE); - + w = gconf_edit_int(effects_block, xconf_get(xc, "maxelemheight"), 0, 128); gconf_block_add(effects_block, gtk_label_new(_("Max Element Height")), TRUE); gconf_block_add(effects_block, w, FALSE); gconf_block_add(gl_block, effects_block->main, TRUE); - + /* empty row */ gconf_block_add(gl_block, gtk_label_new(" "), TRUE); } @@ -118,18 +118,18 @@ static void prop_changed(gconf_block *b) { int i = 0; - + ENTER; XCG(b->data, "setlayer", &i, enum, bool_enum); gtk_widget_set_sensitive(layer_block->main, i); RET(); } - + static void mk_prop_block(xconf *xc) { GtkWidget *w; - + ENTER; /* label */ @@ -141,15 +141,15 @@ mk_prop_block(xconf *xc) /* properties */ prop_block = gconf_block_new((GCallback)prop_changed, xc, 10); - /* strut */ + /* strut */ w = gconf_edit_boolean(prop_block, xconf_get(xc, "setpartialstrut"), _("Do not cover by maximized windows")); gconf_block_add(prop_block, w, TRUE); - + w = gconf_edit_boolean(prop_block, xconf_get(xc, "setdocktype"), _("Set 'Dock' type")); gconf_block_add(prop_block, w, TRUE); - + /* set layer */ w = gconf_edit_boolean(prop_block, xconf_get(xc, "setlayer"), _("Set stacking layer")); @@ -165,9 +165,9 @@ mk_prop_block(xconf *xc) gconf_block_add(layer_block, w, FALSE); gconf_block_add(prop_block, layer_block->main, TRUE); - + gconf_block_add(gl_block, prop_block->main, TRUE); - + /* empty row */ gconf_block_add(gl_block, gtk_label_new(" "), TRUE); } @@ -179,10 +179,10 @@ static void geom_changed(gconf_block *b) { int i, j; - + ENTER; i = gtk_combo_box_get_active(GTK_COMBO_BOX(allign_opt)); - gtk_widget_set_sensitive(margin_spin, (i != ALLIGN_CENTER)); + gtk_widget_set_sensitive(xmargin_spin, (i != ALLIGN_CENTER)); i = gtk_combo_box_get_active(GTK_COMBO_BOX(width_opt)); gtk_widget_set_sensitive(width_spin, (i != WIDTH_REQUEST)); if (i == WIDTH_PERCENT) @@ -195,12 +195,12 @@ geom_changed(gconf_block *b) } RET(); } - + static void mk_geom_block(xconf *xc) { GtkWidget *w; - + ENTER; /* label */ @@ -211,17 +211,17 @@ mk_geom_block(xconf *xc) /* geometry */ geom_block = gconf_block_new((GCallback)geom_changed, xc, 10); - + w = gconf_edit_int(geom_block, xconf_get(xc, "width"), 0, 2300); gconf_block_add(geom_block, gtk_label_new(_("Width")), TRUE); gconf_block_add(geom_block, w, FALSE); width_spin = w; - + w = gconf_edit_enum(geom_block, xconf_get(xc, "widthtype"), widthtype_enum); gconf_block_add(geom_block, w, FALSE); width_opt = w; - + w = gconf_edit_int(geom_block, xconf_get(xc, "height"), 0, 300); gconf_block_add(geom_block, gtk_label_new(_("Height")), TRUE); gconf_block_add(geom_block, w, FALSE); @@ -236,23 +236,28 @@ mk_geom_block(xconf *xc) gconf_block_add(geom_block, gtk_label_new(_("Allignment")), TRUE); gconf_block_add(geom_block, w, FALSE); allign_opt = w; - - w = gconf_edit_int(geom_block, xconf_get(xc, "margin"), 0, 300); - gconf_block_add(geom_block, gtk_label_new(_("Margin")), FALSE); + + w = gconf_edit_int(geom_block, xconf_get(xc, "xmargin"), 0, 300); + gconf_block_add(geom_block, gtk_label_new(_("X Margin")), TRUE); + gconf_block_add(geom_block, w, FALSE); + xmargin_spin = w; + + w = gconf_edit_int(geom_block, xconf_get(xc, "ymargin"), 0, 300); + gconf_block_add(geom_block, gtk_label_new(_("Y Margin")), FALSE); gconf_block_add(geom_block, w, FALSE); - margin_spin = w; + ymargin_spin = w; gconf_block_add(gl_block, geom_block->main, TRUE); /* empty row */ gconf_block_add(gl_block, gtk_label_new(" "), TRUE); } - + static GtkWidget * mk_tab_global(xconf *xc) { GtkWidget *page; - + ENTER; page = gtk_vbox_new(FALSE, 1); gtk_container_set_border_width(GTK_CONTAINER(page), 10); @@ -264,11 +269,11 @@ mk_tab_global(xconf *xc) mk_effects_block(xc); gtk_widget_show_all(page); - + geom_changed(geom_block); effects_changed(effects_block); prop_changed(prop_block); - + RET(page); } @@ -277,19 +282,19 @@ mk_tab_profile(xconf *xc) { GtkWidget *page, *label; gchar *s1; - + ENTER; page = gtk_vbox_new(FALSE, 1); gtk_container_set_border_width(GTK_CONTAINER(page), 10); - + s1 = g_strdup_printf(_("You're using '%s' profile, stored at\n" "%s"), panel_get_profile(), panel_get_profile_file()); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), s1); gtk_box_pack_start(GTK_BOX(page), label, FALSE, TRUE, 0); g_free(s1); - - gtk_widget_show_all(page); + + gtk_widget_show_all(page); RET(page); } @@ -297,7 +302,7 @@ static void dialog_response_event(GtkDialog *_dialog, gint rid, xconf *xc) { xconf *oxc = g_object_get_data(G_OBJECT(dialog), "oxc"); - + ENTER; if (rid == GTK_RESPONSE_APPLY || rid == GTK_RESPONSE_OK) @@ -345,7 +350,7 @@ mk_dialog(xconf *oxc) GtkWidget *sw, *nb, *label; gchar *name; xconf *xc; - + ENTER; DBG("creating dialog\n"); //name = g_strdup_printf("fbpanel settings: <%s> profile", cprofile); @@ -367,7 +372,7 @@ mk_dialog(xconf *oxc) xc = xconf_dup(oxc); g_object_set_data(G_OBJECT(dialog), "oxc", xc); xc = xconf_dup(oxc); - + g_signal_connect (G_OBJECT(dialog), "response", (GCallback) dialog_response_event, xc); // g_signal_connect (G_OBJECT(dialog), "destroy", @@ -379,7 +384,7 @@ mk_dialog(xconf *oxc) gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 500); gtk_window_set_icon_from_file(GTK_WINDOW(dialog), IMGPREFIX "/logo.png", NULL); - + nb = gtk_notebook_new(); gtk_notebook_set_show_border (GTK_NOTEBOOK(nb), FALSE); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), nb); @@ -408,7 +413,7 @@ configure(xconf *xc) { ENTER; DBG("dialog %p\n", dialog); - if (!dialog) + if (!dialog) dialog = mk_dialog(xc); gtk_widget_show(dialog); RET(); diff --git a/panel/gconf_plugins.c b/panel/gconf_plugins.c index a8be874..408359e 100644 --- a/panel/gconf_plugins.c +++ b/panel/gconf_plugins.c @@ -24,12 +24,12 @@ mk_model(xconf *xc) xconf *pxc; int i; gchar *type; - + store = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); for (i = 0; (pxc = xconf_find(xc, "plugin", i)); i++) { XCG(pxc, "type", &type, str); - gtk_tree_store_append(store, &iter, NULL); + gtk_tree_store_append(store, &iter, NULL); gtk_tree_store_set (store, &iter, TYPE_COL, type, NAME_COL, "Martin Heidegger", @@ -61,7 +61,7 @@ mk_view() GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *select; - + tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Type", @@ -81,7 +81,7 @@ mk_buttons() GtkWidget *bm, *b, *w; bm = gtk_hbox_new(FALSE, 3); - + w = gtk_button_new_from_stock(GTK_STOCK_ADD); gtk_box_pack_start(GTK_BOX(bm), w, FALSE, TRUE, 0); @@ -89,7 +89,7 @@ mk_buttons() gtk_box_pack_start(GTK_BOX(bm), b, FALSE, TRUE, 0); bbox = b; gtk_widget_set_sensitive(bbox, FALSE); - + w = gtk_button_new_from_stock(GTK_STOCK_EDIT); gtk_box_pack_start(GTK_BOX(b), w, FALSE, TRUE, 0); w = gtk_button_new_from_stock(GTK_STOCK_DELETE); @@ -106,18 +106,18 @@ GtkWidget * mk_tab_plugins(xconf *xc) { GtkWidget *page, *w; - + ENTER; page = gtk_vbox_new(FALSE, 1); gtk_container_set_border_width(GTK_CONTAINER(page), 10); mk_model(xc); - + w = mk_view(); gtk_box_pack_start(GTK_BOX(page), w, TRUE, TRUE, 0); w = mk_buttons(); gtk_box_pack_start(GTK_BOX(page), w, FALSE, TRUE, 0); - - gtk_widget_show_all(page); + + gtk_widget_show_all(page); RET(page); } diff --git a/panel/gtkbar.c b/panel/gtkbar.c index 8d285cc..74369f1 100644 --- a/panel/gtkbar.c +++ b/panel/gtkbar.c @@ -21,7 +21,7 @@ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ #include "gtkbar.h" @@ -119,7 +119,7 @@ gtk_bar_size_request(GtkWidget *widget, GtkRequisition *requisition) GtkBoxChild *child; GList *children; gint nvis_children, rows, cols, dim; - + nvis_children = 0; children = box->children; while (children) { @@ -128,9 +128,9 @@ gtk_bar_size_request(GtkWidget *widget, GtkRequisition *requisition) if (GTK_WIDGET_VISIBLE(child->widget)) { GtkRequisition child_requisition; - + /* Do not remove child request !!! Label's proper layout depends - * on request running before alloc. */ + * on request running before alloc. */ gtk_widget_size_request(child->widget, &child_requisition); nvis_children++; } @@ -149,7 +149,7 @@ gtk_bar_size_request(GtkWidget *widget, GtkRequisition *requisition) cols = dim; rows = (gint) ceilf((float) nvis_children / cols); } - + requisition->width = bar->child_width * cols + box->spacing * (cols - 1); requisition->height = bar->child_height * rows @@ -178,7 +178,7 @@ gtk_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation) while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) nvis_children += 1; } @@ -206,7 +206,7 @@ gtk_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation) DBG("child alloc: width=%d height=%d\n", child_allocation.width, child_allocation.height); - + child_allocation.x = allocation->x; child_allocation.y = allocation->y; children = box->children; @@ -214,7 +214,7 @@ gtk_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation) while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) { DBG("allocate x=%d y=%d\n", child_allocation.x, child_allocation.y); @@ -241,7 +241,7 @@ gtk_bar_expose (GtkWidget *widget, GdkEventExpose *event) if (GTK_WIDGET_DRAWABLE (widget)) { int w, h; - + DBG("w, h = %d,%d\n", w, h); if (!GTK_WIDGET_APP_PAINTABLE (widget)) gtk_paint_flat_box (widget->style, widget->window, diff --git a/panel/gtkbar.h b/panel/gtkbar.h index 5698026..7e0f3f5 100644 --- a/panel/gtkbar.h +++ b/panel/gtkbar.h @@ -21,7 +21,7 @@ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ #ifndef __GTK_BAR_H__ diff --git a/panel/gtkbgbox.c b/panel/gtkbgbox.c index 166d416..29a24cc 100644 --- a/panel/gtkbgbox.c +++ b/panel/gtkbgbox.c @@ -21,7 +21,7 @@ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ #include @@ -61,7 +61,7 @@ static gboolean gtk_bgbox_configure_event(GtkWidget *widget, GdkEventConfigure * #if 0 static gboolean gtk_bgbox_destroy_event (GtkWidget *widget, GdkEventAny *event); static gboolean gtk_bgbox_delete_event (GtkWidget *widget, GdkEventAny *event); -#endif +#endif static void gtk_bgbox_finalize (GObject *object); @@ -125,7 +125,7 @@ gtk_bgbox_init (GtkBgbox *bgbox) ENTER; GTK_WIDGET_UNSET_FLAGS (bgbox, GTK_NO_WINDOW); - + priv = GTK_BGBOX_GET_PRIVATE (bgbox); priv->bg_type = BG_NONE; priv->sid = 0; @@ -161,19 +161,19 @@ gtk_bgbox_finalize (GObject *object) RET(); } -static GdkFilterReturn +static GdkFilterReturn gtk_bgbox_event_filter(GdkXEvent *xevent, GdkEvent *event, GtkWidget *widget) { XEvent *ev = (XEvent *) xevent; ENTER; if (ev->type == ConfigureNotify) { - gtk_widget_queue_draw(widget); + gtk_widget_queue_draw(widget); //gtk_bgbox_style_set(widget, NULL); - DBG("ConfigureNotify %d %d %d %d\n", - ev->xconfigure.x, - ev->xconfigure.y, - ev->xconfigure.width, + DBG("ConfigureNotify %d %d %d %d\n", + ev->xconfigure.x, + ev->xconfigure.y, + ev->xconfigure.width, ev->xconfigure.height ); } @@ -192,7 +192,7 @@ gtk_bgbox_realize (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); border_width = GTK_CONTAINER (widget)->border_width; - + attributes.x = widget->allocation.x + border_width; attributes.y = widget->allocation.y + border_width; attributes.width = widget->allocation.width - 2*border_width; @@ -208,13 +208,13 @@ gtk_bgbox_realize (GtkWidget *widget) | GDK_STRUCTURE_MASK; priv = GTK_BGBOX_GET_PRIVATE (widget); - + attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.wclass = GDK_INPUT_OUTPUT; - + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); @@ -246,7 +246,7 @@ gtk_bgbox_configure_event (GtkWidget *widget, GdkEventConfigure *e) ENTER; DBG("geom: size (%d, %d). pos (%d, %d)\n", e->width, e->height, e->x, e->y); RET(FALSE); - + } static void @@ -260,7 +260,7 @@ gtk_bgbox_size_request (GtkWidget *widget, GtkRequisition *requisition) if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { GtkRequisition child_requisition; - + gtk_widget_size_request (bin->child, &child_requisition); requisition->width += child_requisition.width; @@ -280,7 +280,7 @@ gtk_bgbox_size_allocate (GtkWidget *widget, GtkAllocation *wa) GtkAllocation ca; GtkBgboxPrivate *priv; int same_alloc, border; - + ENTER; same_alloc = !memcmp(&widget->allocation, wa, sizeof(*wa)); DBG("same alloc = %d\n", same_alloc); @@ -294,16 +294,16 @@ gtk_bgbox_size_allocate (GtkWidget *widget, GtkAllocation *wa) ca.y = border; ca.width = MAX (wa->width - border * 2, 0); ca.height = MAX (wa->height - border * 2, 0); - + if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget) && !same_alloc) { priv = GTK_BGBOX_GET_PRIVATE (widget); DBG("move resize pos=%d,%d geom=%dx%d\n", wa->x, wa->y, wa->width, - wa->height); + wa->height); gdk_window_move_resize (widget->window, wa->x, wa->y, wa->width, wa->height); gtk_bgbox_set_background(widget, priv->bg_type, priv->tintcolor, priv->alpha); } - + if (bin->child) gtk_widget_size_allocate (bin->child, &ca); RET(); @@ -374,7 +374,7 @@ static void gtk_bgbox_set_bg_root(GtkWidget *widget, GtkBgboxPrivate *priv) { priv = GTK_BGBOX_GET_PRIVATE (widget); - + ENTER; priv->pixmap = fb_bg_get_xroot_pix_for_win(priv->bg, widget); if (!priv->pixmap || priv->pixmap == GDK_NO_BG) { @@ -397,7 +397,7 @@ static void gtk_bgbox_set_bg_inherit(GtkWidget *widget, GtkBgboxPrivate *priv) { priv = GTK_BGBOX_GET_PRIVATE (widget); - + ENTER; gdk_window_set_back_pixmap(widget->window, NULL, TRUE); RET(); diff --git a/panel/gtkbgbox.h b/panel/gtkbgbox.h index 16c2ac6..3bd815d 100644 --- a/panel/gtkbgbox.h +++ b/panel/gtkbgbox.h @@ -21,7 +21,7 @@ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ #ifndef __GTK_BGBOX_H__ diff --git a/panel/misc.c b/panel/misc.c index 16173a8..3b5ae94 100644 --- a/panel/misc.c +++ b/panel/misc.c @@ -426,7 +426,7 @@ get_net_wm_desktop(Window win) if (data) { desk = *data; XFree (data); - } else + } else DBG("can't get desktop num for win 0x%lx", win); RET(desk); } @@ -523,7 +523,7 @@ get_net_wm_window_type(Window win, net_wm_window_type *nwwt) static void -calculate_width(int scrw, int wtype, int allign, int margin, +calculate_width(int scrw, int wtype, int allign, int xmargin, int *panw, int *x) { ENTER; @@ -542,22 +542,22 @@ calculate_width(int scrw, int wtype, int allign, int margin, *panw = scrw; if (allign != ALLIGN_CENTER) { - if (margin > scrw) { - ERR( "margin is bigger then edge size %d > %d. Ignoring margin\n", - margin, scrw); - margin = 0; + if (xmargin > scrw) { + ERR( "xmargin is bigger then edge size %d > %d. Ignoring xmargin\n", + xmargin, scrw); + xmargin = 0; } if (wtype == WIDTH_PERCENT) - //*panw = MAX(scrw - margin, *panw); + //*panw = MAX(scrw - xmargin, *panw); ; else - *panw = MIN(scrw - margin, *panw); + *panw = MIN(scrw - xmargin, *panw); } DBG("OUT panw=%d\n", *panw); if (allign == ALLIGN_LEFT) - *x += margin; + *x += xmargin; else if (allign == ALLIGN_RIGHT) { - *x += scrw - *panw - margin; + *x += scrw - *panw - xmargin; if (*x < 0) *x = 0; } else if (allign == ALLIGN_CENTER) @@ -588,22 +588,28 @@ calculate_position(panel *np) if (np->edge == EDGE_TOP || np->edge == EDGE_BOTTOM) { np->aw = np->width; np->ax = minx; - calculate_width(sswidth, np->widthtype, np->allign, np->margin, + calculate_width(sswidth, np->widthtype, np->allign, np->xmargin, &np->aw, &np->ax); np->ah = np->height; np->ah = MIN(PANEL_HEIGHT_MAX, np->ah); np->ah = MAX(PANEL_HEIGHT_MIN, np->ah); - np->ay = miny + ((np->edge == EDGE_TOP) ? 0 : (ssheight - np->ah)); + if (np->edge == EDGE_TOP) + np->ay = np->ymargin; + else + np->ay = ssheight - np->ah - np->ymargin; } else { np->ah = np->width; np->ay = miny; - calculate_width(ssheight, np->widthtype, np->allign, np->margin, + calculate_width(ssheight, np->widthtype, np->allign, np->xmargin, &np->ah, &np->ay); np->aw = np->height; np->aw = MIN(PANEL_HEIGHT_MAX, np->aw); np->aw = MAX(PANEL_HEIGHT_MIN, np->aw); - np->ax = minx + ((np->edge == EDGE_LEFT) ? 0 : (sswidth - np->aw)); + if (np->edge == EDGE_LEFT) + np->ax = np->ymargin; + else + np->ax = sswidth - np->aw - np->ymargin; } if (!np->aw) np->aw = 1; @@ -661,19 +667,23 @@ get_button_spacing(GtkRequisition *req, GtkContainer *parent, gchar *name) } -guint32 +guint32 gcolor2rgb24(GdkColor *color) { guint32 i; - guint16 r, g, b; ENTER; - - r = color->red * 0xFF / 0xFFFF; - g = color->green * 0xFF / 0xFFFF; - b = color->blue * 0xFF / 0xFFFF; - DBG("%x %x %x ==> %x %x %x\n", color->red, color->green, color->blue, r, g, b); - +#ifdef DEBUGPRN + { + guint16 r, g, b; + + r = color->red * 0xFF / 0xFFFF; + g = color->green * 0xFF / 0xFFFF; + b = color->blue * 0xFF / 0xFFFF; + DBG("%x %x %x ==> %x %x %x\n", color->red, color->green, color->blue, + r, g, b); + } +#endif i = (color->red * 0xFF / 0xFFFF) & 0xFF; i <<= 8; i |= (color->green * 0xFF / 0xFFFF) & 0xFF; @@ -695,50 +705,54 @@ gdk_color_to_RRGGBB(GdkColor *color) void menu_pos(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, GtkWidget *widget) { - int ox, oy, w, h; + int w, h; ENTER; - if (widget) { - gdk_window_get_origin(widget->window, &ox, &oy); - ox += widget->allocation.x; - oy += widget->allocation.y; - } else { - gdk_display_get_pointer(gdk_display_get_default(), NULL, &ox, &oy, NULL); - ox -= 20; - if (ox < 0) - ox = 0; - oy -= 10; - if (oy < 0) - oy = 0; + *push_in = TRUE; + if (!widget) { + gdk_display_get_pointer(gdk_display_get_default(), NULL, x, y, NULL); + DBG("mouse pos: x %d, y %d\n", *x, *y); + DBG("menu pos: x %d, y %d\n", *x, *y); + RET(); } - w = GTK_WIDGET(menu)->requisition.width; - h = GTK_WIDGET(menu)->requisition.height; - if (the_panel->orientation == GTK_ORIENTATION_HORIZONTAL) { - // x - *x = ox; - if (*x + w > gdk_screen_width()) - *x = gdk_screen_width() - w; - // y - if (the_panel->edge == EDGE_TOP) - *y = the_panel->ah; - else - *y = gdk_screen_height() - the_panel->ah - h; + DBG("widget: x %d, y %d, w %d, h %d\n", + widget->allocation.x, + widget->allocation.y, + widget->allocation.width, + widget->allocation.height); + gdk_window_get_origin(widget->window, x, y); + DBG("window pos: x %d, y %d\n", *x, *y); + DBG("edge: %s\n", num2str(edge_enum, the_panel->edge, "xz")); + if (the_panel->edge == EDGE_TOP) { + *y += widget->allocation.height; + *y += widget->allocation.y; + *x += widget->allocation.x; + } else if (the_panel->edge == EDGE_LEFT) { + *x += widget->allocation.width; + *y += widget->allocation.y; + *x += widget->allocation.x; } else { - // x - if (the_panel->edge == EDGE_LEFT) - *x = the_panel->aw; - else - *x = gdk_screen_width() - the_panel->aw - w; - // y - *y = oy; - if (*y + h > gdk_screen_height()) - *y = gdk_screen_height() - h; + w = GTK_WIDGET(menu)->requisition.width; + h = GTK_WIDGET(menu)->requisition.height; + if (the_panel->edge == EDGE_BOTTOM) { + *x += widget->allocation.x; + *y += widget->allocation.y; + *y -= h; + if (*y < 0) + *y = 0; + } else if (the_panel->edge == EDGE_RIGHT) { + *y += widget->allocation.y; + *x -= w; + *x -= widget->allocation.x; + if (*x < 0) + *x = 0; + } } - DBG("w-h %d %d\n", w, h); - *push_in = TRUE; + DBG("menu pos: x %d, y %d\n", *x, *y); RET(); } + gchar * indent(int level) { @@ -769,11 +783,11 @@ indent(int level) * file from @fname * icon named "missing-image" as a fallabck, if @use_fallback is TRUE. * Returns pixbuf or NULL on failure - * - * Result pixbuf is always smaller then MAX_SIZE + * + * Result pixbuf is always smaller then MAX_SIZE */ GdkPixbuf * -fb_pixbuf_new(gchar *iname, gchar *fname, int width, int height, +fb_pixbuf_new(gchar *iname, gchar *fname, int width, int height, gboolean use_fallback) { GdkPixbuf *pb = NULL; @@ -793,7 +807,7 @@ fb_pixbuf_new(gchar *iname, gchar *fname, int width, int height, } /* Creates hilighted version of front image to reflect mouse enter - */ + */ static GdkPixbuf * fb_pixbuf_make_back_image(GdkPixbuf *front, gulong hicolor) { @@ -838,7 +852,7 @@ fb_pixbuf_make_press_image(GdkPixbuf *front) tmp = gdk_pixbuf_scale_simple(front, w, h, GDK_INTERP_HYPER); if (press && tmp) { gdk_pixbuf_fill(press, 0); - gdk_pixbuf_copy_area(tmp, + gdk_pixbuf_copy_area(tmp, 0, 0, // src_x, src_y w, h, // width, height press, // dest_pixbuf @@ -885,7 +899,7 @@ fb_image_new(gchar *iname, gchar *fname, int width, int height) image = gtk_image_new(); conf = g_new0(fb_image_conf_t, 1); /* exits if fails */ - g_object_set_data(G_OBJECT(image), "conf", conf); + g_object_set_data(G_OBJECT(image), "conf", conf); conf->itc_id = g_signal_connect_after (G_OBJECT(icon_theme), "changed", (GCallback) fb_image_icon_theme_changed, image); g_signal_connect (G_OBJECT(image), @@ -900,7 +914,7 @@ fb_image_new(gchar *iname, gchar *fname, int width, int height) RET(image); } - + /* Frees image's resources */ static void @@ -915,7 +929,7 @@ fb_image_free(GObject *image) g_free(conf->iname); g_free(conf->fname); for (i = 0; i < PIXBBUF_NUM; i++) - if (conf->pix[i]) + if (conf->pix[i]) g_object_unref(G_OBJECT(conf->pix[i])); g_free(conf); RET(); @@ -937,7 +951,7 @@ fb_image_icon_theme_changed(GtkIconTheme *icon_theme, GtkWidget *image) g_object_unref(G_OBJECT(conf->pix[i])); conf->pix[i] = NULL; } - conf->pix[0] = fb_pixbuf_new(conf->iname, conf->fname, + conf->pix[0] = fb_pixbuf_new(conf->iname, conf->fname, conf->width, conf->height, TRUE); conf->pix[1] = fb_pixbuf_make_back_image(conf->pix[0], conf->hicolor); conf->pix[2] = fb_pixbuf_make_press_image(conf->pix[1]); @@ -958,7 +972,7 @@ static gboolean fb_button_pressed(GtkWidget *widget, GdkEventButton *event); * Additionaly, fb_button highlightes an image on mouse enter and runs simple * animation when clicked. * FIXME: @label parameter is currently ignored - */ + */ GtkWidget * fb_button_new(gchar *iname, gchar *fname, int width, int height, gulong hicolor, gchar *label) @@ -994,7 +1008,7 @@ fb_button_new(gchar *iname, gchar *fname, int width, int height, /* Flips front and back images upon mouse cross event - GDK_ENTER_NOTIFY * or GDK_LEAVE_NOTIFY - */ + */ static gboolean fb_button_cross(GtkImage *widget, GdkEventCrossing *event) { @@ -1012,7 +1026,7 @@ fb_button_cross(GtkImage *widget, GdkEventCrossing *event) conf->i = i; gtk_image_set_from_pixbuf(GTK_IMAGE(widget), conf->pix[i]); } - DBG("%s/%s - %s - pix[%d]=%p\n", conf->iname, conf->fname, + DBG("%s/%s - %s - pix[%d]=%p\n", conf->iname, conf->fname, (event->type == GDK_LEAVE_NOTIFY) ? "out" : "in", conf->i, conf->pix[conf->i]); RET(TRUE); @@ -1030,8 +1044,8 @@ fb_button_pressed(GtkWidget *widget, GdkEventButton *event) i = 2; } else { if ((event->x >=0 && event->x < widget->allocation.width) - && (event->y >=0 && event->y < widget->allocation.height)) - i = 1; + && (event->y >=0 && event->y < widget->allocation.height)) + i = 1; else i = 0; } diff --git a/panel/misc.h b/panel/misc.h index e603fa4..3e31114 100644 --- a/panel/misc.h +++ b/panel/misc.h @@ -36,7 +36,7 @@ void get_button_spacing(GtkRequisition *req, GtkContainer *parent, gchar *name); guint32 gcolor2rgb24(GdkColor *color); gchar *gdk_color_to_RRGGBB(GdkColor *color); -GdkPixbuf *fb_pixbuf_new(gchar *iname, gchar *fname, int width, int height, +GdkPixbuf *fb_pixbuf_new(gchar *iname, gchar *fname, int width, int height, gboolean use_fallback); GtkWidget *fb_image_new(gchar *iname, gchar *fname, int width, int height); GtkWidget *fb_button_new(gchar *iname, gchar *fname, int width, int height, diff --git a/panel/panel.c b/panel/panel.c index 10470e2..811be95 100644 --- a/panel/panel.c +++ b/panel/panel.c @@ -54,28 +54,28 @@ panel_set_wm_strut(panel *p) switch (p->edge) { case EDGE_LEFT: i = 0; - data[i] = p->aw; + data[i] = p->aw + p->ymargin; data[4 + i*2] = p->ay; data[5 + i*2] = p->ay + p->ah; if (p->autohide) data[i] = p->height_when_hidden; break; case EDGE_RIGHT: i = 1; - data[i] = p->aw; + data[i] = p->aw + p->ymargin; data[4 + i*2] = p->ay; data[5 + i*2] = p->ay + p->ah; if (p->autohide) data[i] = p->height_when_hidden; break; case EDGE_TOP: i = 2; - data[i] = p->ah; + data[i] = p->ah + p->ymargin; data[4 + i*2] = p->ax; data[5 + i*2] = p->ax + p->aw; if (p->autohide) data[i] = p->height_when_hidden; break; case EDGE_BOTTOM: i = 3; - data[i] = p->ah; + data[i] = p->ah + p->ymargin; data[4 + i*2] = p->ax; data[5 + i*2] = p->ax + p->aw; if (p->autohide) data[i] = p->height_when_hidden; @@ -158,8 +158,8 @@ panel_event_filter(GdkXEvent *xevent, GdkEvent *event, panel *p) // XA_CARDINAL, &p->wa_len); //print_wmdata(p); } else if (at == a_XROOTPMAP_ID) { - if (p->transparent) - fb_bg_notify_changed_bg(p->bg); + if (p->transparent) + fb_bg_notify_changed_bg(p->bg); } else if (at == a_NET_DESKTOP_GEOMETRY) { DBG("a_NET_DESKTOP_GEOMETRY\n"); gtk_main_quit(); @@ -200,6 +200,14 @@ panel_size_req(GtkWidget *widget, GtkRequisition *req, panel *p) RET(); } + +static void +panel_size_alloc (GtkWidget *widget, GdkRectangle *a, gpointer data) +{ + DBG("alloc %d %d\n", a->width, a->height); +} + + static void make_round_corners(panel *p) { @@ -217,6 +225,10 @@ make_round_corners(panel *p) r = MIN(w, h) / 2; DBG("chaning radius to %d\n", r); } + if (r < 4) { + DBG("radius too small\n"); + RET(); + } b = gdk_pixmap_new(NULL, w, h, 1); gc = gdk_gc_new(GDK_DRAWABLE(b)); gdk_gc_set_foreground(gc, &black); @@ -256,7 +268,7 @@ panel_configure_event(GtkWidget *widget, GdkEventConfigure *e, panel *p) p->cx = e->x; p->cy = e->y; - /* if panel size is not we have requested, just wait, it will */ + /* if panel size is not what we have requested, just wait, it will */ if (e->width != p->aw || e->height != p->ah) { DBG("size_req not yet ready. exiting\n"); RET(FALSE); @@ -270,22 +282,24 @@ panel_configure_event(GtkWidget *widget, GdkEventConfigure *e, panel *p) } /* panel is at right place, lets go on */ + DBG("panel is at right place, lets go on\n"); if (p->transparent) { - fb_bg_notify_changed_bg(p->bg); DBG("remake bg image\n"); + fb_bg_notify_changed_bg(p->bg); } if (p->setstrut) { - panel_set_wm_strut(p); DBG("set_wm_strut\n"); + panel_set_wm_strut(p); } if (p->round_corners) { - make_round_corners(p); DBG("make_round_corners\n"); + make_round_corners(p); + } gtk_widget_show(p->topgwin); if (p->setstrut) { - panel_set_wm_strut(p); DBG("set_wm_strut\n"); + panel_set_wm_strut(p); } RET(FALSE); @@ -296,8 +310,8 @@ panel_configure_event(GtkWidget *widget, GdkEventConfigure *e, panel *p) ****************************************************/ /* Autohide is behaviour when panel hides itself when mouse is "far enough" - * and pops up again when mouse comes "close enough". - * Formally, it's a state machine with 3 states that driven by mouse + * and pops up again when mouse comes "close enough". + * Formally, it's a state machine with 3 states that driven by mouse * coordinates and timer: * 1. VISIBLE - ensures that panel is visible. When/if mouse goes "far enough" * switches to WAITING state @@ -331,14 +345,14 @@ panel_mapped(GtkWidget *widget, GdkEvent *event, panel *p) RET(FALSE); } -static gboolean +static gboolean mouse_watch(panel *p) { gint x, y; ENTER; gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL); - + /* Reduce sensitivity area p->ah_far = ((x < p->cx - GAP) || (x > p->cx + p->cw + GAP) || (y < p->cy - GAP) || (y > p->cy + p->ch + GAP)); @@ -453,9 +467,9 @@ about() gchar *authors[] = { "Anatoly Asviyan ", NULL }; ENTER; - gtk_show_about_dialog(NULL, + gtk_show_about_dialog(NULL, "authors", authors, - "comments", "Lightweight GTK+ desktop panel", + "comments", "Lightweight GTK+ desktop panel", "license", "GPLv2", "program-name", PROJECT_NAME, "version", PROJECT_VERSION, @@ -492,7 +506,7 @@ panel_make_menu(panel *p) g_signal_connect(G_OBJECT(mi), "activate", (GCallback)about, p); gtk_widget_show (mi); - + RET(menu); } @@ -544,6 +558,8 @@ panel_start_gui(panel *p) (GCallback) panel_destroy_event, p); g_signal_connect(G_OBJECT(p->topgwin), "size-request", (GCallback) panel_size_req, p); + g_signal_connect(G_OBJECT(p->topgwin), "size-allocate", + (GCallback) panel_size_alloc, p); g_signal_connect(G_OBJECT(p->topgwin), "map-event", (GCallback) panel_mapped, p); g_signal_connect(G_OBJECT(p->topgwin), "configure-event", @@ -575,7 +591,7 @@ panel_start_gui(panel *p) /* ensure configure event */ XMoveWindow(GDK_DISPLAY(), p->topxwin, 20, 20); XSync(GDK_DISPLAY(), False); - + gtk_widget_set_app_paintable(p->topgwin, TRUE); calculate_position(p); gtk_window_move(GTK_WINDOW(p->topgwin), p->ax, p->ay); @@ -603,8 +619,8 @@ panel_start_gui(panel *p) gtk_box_pack_start(GTK_BOX(p->lbox), p->box, TRUE, TRUE, (p->round_corners) ? p->round_corners_radius : 0); if (p->round_corners) { - make_round_corners(p); DBG("make_round_corners\n"); + make_round_corners(p); } /* start window creation process */ gtk_widget_show_all(p->topgwin); @@ -615,7 +631,7 @@ panel_start_gui(panel *p) if (p->setstrut) panel_set_wm_strut(p); - + XSelectInput(GDK_DISPLAY(), GDK_ROOT_WINDOW(), PropertyChangeMask); gdk_window_add_filter(gdk_get_default_root_window(), (GdkFilterFunc)panel_event_filter, p); @@ -648,7 +664,7 @@ panel_parse_global(xconf *xc) p->spacing = 0; p->setlayer = FALSE; p->layer = LAYER_ABOVE; - + /* Read config */ /* geometry */ XCG(xc, "edge", &p->edge, enum, edge_enum); @@ -657,7 +673,8 @@ panel_parse_global(xconf *xc) XCG(xc, "heighttype", &p->heighttype, enum, heighttype_enum); XCG(xc, "width", &p->width, int); XCG(xc, "height", &p->height, int); - XCG(xc, "margin", &p->margin, int); + XCG(xc, "xmargin", &p->xmargin, int); + XCG(xc, "ymargin", &p->ymargin, int); /* properties */ XCG(xc, "setdocktype", &p->setdocktype, enum, bool_enum); @@ -666,7 +683,7 @@ panel_parse_global(xconf *xc) XCG(xc, "heightwhenhidden", &p->height_when_hidden, int); XCG(xc, "setlayer", &p->setlayer, enum, bool_enum); XCG(xc, "layer", &p->layer, enum, layer_enum); - + /* effects */ XCG(xc, "roundcorners", &p->round_corners, enum, bool_enum); XCG(xc, "roundcornersradius", &p->round_corners_radius, int); @@ -674,7 +691,7 @@ panel_parse_global(xconf *xc) XCG(xc, "alpha", &p->alpha, int); XCG(xc, "tintcolor", &p->tintcolor_name, str); XCG(xc, "maxelemheight", &p->max_elem_height, int); - + /* Sanity checks */ if (!gdk_color_parse(p->tintcolor_name, &p->gtintcolor)) gdk_color_parse("white", &p->gtintcolor); @@ -719,7 +736,7 @@ panel_parse_plugin(xconf *xc) { plugin_instance *plug = NULL; gchar *type = NULL; - + ENTER; xconf_get_str(xconf_find(xc, "type", 0), &type); if (!type || !(plug = plugin_load(type))) { @@ -739,12 +756,21 @@ panel_parse_plugin(xconf *xc) p->plugins = g_list_append(p->plugins, plug); } +static gboolean +panel_show_anyway(gpointer data) +{ + ENTER; + gtk_widget_show_all(p->topgwin); + return FALSE; +} + + static void panel_start(xconf *xc) { int i; xconf *pxc; - + ENTER; fbev = fb_ev_new(); @@ -752,6 +778,7 @@ panel_start(xconf *xc) panel_parse_global(xconf_find(xc, "global", 0)); for (i = 0; (pxc = xconf_find(xc, "plugin", i)); i++) panel_parse_plugin(pxc); + g_timeout_add(200, panel_show_anyway, NULL); RET(); } @@ -769,7 +796,7 @@ panel_stop(panel *p) { ENTER; - if (p->autohide) + if (p->autohide) ah_stop(p); g_list_foreach(p->plugins, delete_plugin, NULL); g_list_free(p->plugins); @@ -840,7 +867,7 @@ static void do_argv(int argc, char *argv[]) { int i; - + for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { usage(); diff --git a/panel/panel.h b/panel/panel.h index 4dac183..c07bc9f 100644 --- a/panel/panel.h +++ b/panel/panel.h @@ -47,10 +47,10 @@ typedef struct _panel guint32 tintcolor; GdkColor gtintcolor; gchar *tintcolor_name; - + int ax, ay, aw, ah; /* prefferd allocation of a panel */ int cx, cy, cw, ch; /* current allocation (as reported by configure event) allocation */ - int allign, edge, margin; + int allign, edge, xmargin, ymargin; GtkOrientation orientation; int widthtype, width; int heighttype, height; @@ -66,7 +66,7 @@ typedef struct _panel gint ah_far; gint layer; gint setlayer; - + int ah_dx, ah_dy; // autohide shift for x and y int height_when_hidden; guint hide_tout; diff --git a/panel/plugin.h b/panel/plugin.h index 23e43be..14ff038 100644 --- a/panel/plugin.h +++ b/panel/plugin.h @@ -25,14 +25,14 @@ typedef struct { char *version; char *description; int priv_size; - + int (*constructor)(struct _plugin_instance *this); void (*destructor)(struct _plugin_instance *this); void (*save_config)(struct _plugin_instance *this, FILE *fp); GtkWidget *(*edit_config)(struct _plugin_instance *this); } plugin_class; -#define PLUGIN_CLASS(class) ((plugin_class *) class) +#define PLUGIN_CLASS(class) ((plugin_class *) class) typedef struct _plugin_instance{ plugin_class *class; @@ -57,11 +57,11 @@ void class_register(plugin_class *p); void class_unregister(plugin_class *p); #ifdef PLUGIN -static plugin_class *class_ptr; -static void ctor(void) __attribute__ ((constructor)); +static plugin_class *class_ptr; +static void ctor(void) __attribute__ ((constructor)); static void ctor(void) { class_register(class_ptr); } -static void dtor(void) __attribute__ ((destructor)); -static void dtor(void) { class_unregister(class_ptr); } +static void dtor(void) __attribute__ ((destructor)); +static void dtor(void) { class_unregister(class_ptr); } #endif #endif diff --git a/panel/run.c b/panel/run.c index 342c2a5..4f3a676 100644 --- a/panel/run.c +++ b/panel/run.c @@ -5,14 +5,14 @@ void run_app(gchar *cmd) { GError *error = NULL; - + ENTER; if (!cmd) RET(); - + if (!g_spawn_command_line_async(cmd, &error)) { - GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, + GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", error->message); @@ -22,3 +22,26 @@ run_app(gchar *cmd) } RET(); } + + +GPid +run_app_argv(gchar **argv) +{ + GError *error = NULL; + GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH; + GPid pid; + + ENTER; + flags |= G_SPAWN_STDOUT_TO_DEV_NULL; + if (!g_spawn_async(NULL, argv, NULL, flags, NULL, NULL, &pid, &error)) { + GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "%s", error->message); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + g_error_free(error); + } + + RET(pid); +} diff --git a/panel/run.h b/panel/run.h index 6093116..31c9979 100644 --- a/panel/run.h +++ b/panel/run.h @@ -4,6 +4,6 @@ #include void run_app(gchar *cmd); -void run_command(gchar *cmd); +GPid run_app_argv(gchar **argv); #endif diff --git a/panel/xconf.c b/panel/xconf.c index a207267..d49ede0 100644 --- a/panel/xconf.c +++ b/panel/xconf.c @@ -36,7 +36,7 @@ void xconf_append_sons(xconf *dst, xconf *src) { GSList *e; xconf *tmp; - + if (!dst || !src) return; for (e = src->sons; e; e = g_slist_next(e)) @@ -74,7 +74,7 @@ void xconf_del(xconf *x, gboolean sons_only) { GSList *s; xconf *x2; - + if (!x) return; DBG("%s %s\n", x->name, x->value); @@ -99,7 +99,7 @@ void xconf_set_value(xconf *x, gchar *value) xconf_del(x, TRUE); g_free(x->value); x->value = g_strdup(value); - + } void xconf_set_value_ref(xconf *x, gchar *value) @@ -107,7 +107,7 @@ void xconf_set_value_ref(xconf *x, gchar *value) xconf_del(x, TRUE); g_free(x->value); x->value = value; - + } void xconf_set_int(xconf *x, int i) @@ -196,6 +196,13 @@ void xconf_get_str(xconf *x, gchar **val) } +void xconf_get_strdup(xconf *x, gchar **val) +{ + if (x && x->value) + *val = g_strdup(x->value); +} + + void xconf_get_int(xconf *x, int *val) { gchar *s; @@ -368,15 +375,15 @@ gboolean xconf_cmp(xconf *a, xconf *b) { GSList *as, *bs; - + if (!(a || b)) return FALSE; if (!(a && b)) return TRUE; - + if (g_ascii_strcasecmp(a->name, b->name)) return TRUE; - + if (g_strcmp0(a->value, b->value)) return TRUE; for (as = a->sons, bs = b->sons; as && bs; diff --git a/panel/xconf.h b/panel/xconf.h index b63ad06..66e0c01 100644 --- a/panel/xconf.h +++ b/panel/xconf.h @@ -38,12 +38,15 @@ xconf *xconf_get(xconf *x, gchar *name); void xconf_get_int(xconf *x, int *val); void xconf_get_enum(xconf *x, int *val, xconf_enum *e); void xconf_get_str(xconf *x, gchar **val); - +void xconf_get_strdup(xconf *x, gchar **val); void xconf_set_int(xconf *x, int val); void xconf_set_enum(xconf *x, int val, xconf_enum *e); #define XCG(xc, name, var, type, extra...) \ xconf_get_ ## type(xconf_find(xc, name, 0), var, ## extra) +#define XCS(xc, name, var, type, extra...) \ + xconf_set_ ## type(xconf_get(xc, name), var, ## extra) + #endif diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/plugins/Makefile b/plugins/Makefile index 346efd3..2990136 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -24,6 +24,7 @@ SUBDIRS := battery \ taskbar \ tclock \ volume \ - wincmd + wincmd \ + user include $(TOPDIR)/.config/rules.mk diff --git a/plugins/battery/.gitignore b/plugins/battery/.gitignore new file mode 100644 index 0000000..45a985d --- /dev/null +++ b/plugins/battery/.gitignore @@ -0,0 +1,5 @@ +battery.o +battery.d +power_supply.o +power_supply.d +libbattery.so diff --git a/plugins/battery/Makefile b/plugins/battery/Makefile index 5ddda22..6967680 100644 --- a/plugins/battery/Makefile +++ b/plugins/battery/Makefile @@ -2,9 +2,9 @@ TOPDIR := ../.. -battery_src = battery.c -battery_cflags = -DPLUGIN $(GTK2_CFLAGS) -battery_libs = $(GTK2_LIBS) -battery_type = lib +battery_src = battery.c power_supply.c +battery_cflags = -DPLUGIN $(GTK2_CFLAGS) +battery_libs = $(GTK2_LIBS) +battery_type = lib include $(TOPDIR)/.config/rules.mk diff --git a/plugins/battery/Makefile-test b/plugins/battery/Makefile-test new file mode 100644 index 0000000..3dc7095 --- /dev/null +++ b/plugins/battery/Makefile-test @@ -0,0 +1,18 @@ +# -*- mode: Makefile -*- +# Time-stamp: < Makefile-test (2015-12-04 19:02) > + +CC = gcc -Wall -g -O0 `pkg-config --cflags --libs glib-2.0` + +all: main + +clean: + rm -rf *.o main + +main: main.c power_supply.o + $(CC) main.c power_supply.o -o $@ + +power_supply.o: power_supply.h power_supply.c + $(CC) -c power_supply.c -o $@ + +valgrind: main + G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --leak-check=yes ./main diff --git a/plugins/battery/battery.c b/plugins/battery/battery.c index 4f5b186..ab736e3 100644 --- a/plugins/battery/battery.c +++ b/plugins/battery/battery.c @@ -120,7 +120,7 @@ static plugin_class class = { .count = 0, .type = "battery", .name = "battery usage", - .version = "1.0", + .version = "1.1", .description = "Display battery usage", .priv_size = sizeof(battery_priv), .constructor = battery_constructor, diff --git a/plugins/battery/main.c b/plugins/battery/main.c new file mode 100644 index 0000000..6be4a20 --- /dev/null +++ b/plugins/battery/main.c @@ -0,0 +1,21 @@ +// Time-stamp: < main.c (2015-12-04 19:02) > +// run with: make -k -f Makefile-test valgrind + +#include +#include + +#include "power_supply.h" + +int main(int argc, char** args) +{ + power_supply* ps = power_supply_new(); + power_supply_parse(ps); + gboolean ac_online = power_supply_is_ac_online(ps); + gdouble bat_capacity = power_supply_get_bat_capacity(ps); + + power_supply_free(ps); + + g_fprintf(stdout, "ac_online: %d\nbat_capacity: %f\n", ac_online, bat_capacity); + + return 0; +} diff --git a/plugins/battery/os_linux.c b/plugins/battery/os_linux.c index 34909b0..6523b4f 100644 --- a/plugins/battery/os_linux.c +++ b/plugins/battery/os_linux.c @@ -1,11 +1,11 @@ - #include #include +#include "power_supply.h" + #define LEN 100 #define PROC_ACPI "/proc/acpi/battery/" - static gboolean get_token_eq(gchar *buf, gchar *token, gchar *value, gboolean *ret) { @@ -114,7 +114,7 @@ battery_update_os_proc(battery_priv *c) } g_dir_close(dir); -out: + out: g_string_free(path, TRUE); RET(ret); } @@ -123,7 +123,18 @@ static gboolean battery_update_os_sys(battery_priv *c) { ENTER; - RET(FALSE); + c->exist = FALSE; + power_supply* ps = power_supply_new(); + power_supply_parse(ps); + if (g_sequence_get_length(ps->bat_list) > 0) { + gboolean ac_online = power_supply_is_ac_online(ps); + gdouble bat_capacity = power_supply_get_bat_capacity(ps); + c->exist = TRUE; + c->charging = ac_online; + c->level = (gfloat) bat_capacity; + } + power_supply_free(ps); + RET(c->exist); } static gboolean diff --git a/plugins/battery/power_supply.c b/plugins/battery/power_supply.c new file mode 100644 index 0000000..ab3f359 --- /dev/null +++ b/plugins/battery/power_supply.c @@ -0,0 +1,346 @@ +// Time-stamp: < power_supply.c (2015-12-04 19:01) > + +#include +#include +#include + +#include "power_supply.h" + +#define DEBUG 0 + +#define STRING_LEN 100 + +#define SYS_ACPI_PATH "/sys/class/power_supply/" +#define SYS_ACPI_TYPE_FILE "type" +#define SYS_ACPI_TYPE_AC "Mains\n" +#define SYS_ACPI_TYPE_BAT "Battery\n" +#define SYS_ACPI_UEVENT_FILE "uevent" +#define SYS_ACPI_UEVENT_NAME_KEY "POWER_SUPPLY_NAME" +#define SYS_ACPI_UEVENT_AC_ONLINE_KEY "POWER_SUPPLY_ONLINE" +#define SYS_ACPI_UEVENT_AC_ONLINE_VALUE "1" +#define SYS_ACPI_UEVENT_BAT_STATUS_KEY "POWER_SUPPLY_STATUS" +/* Recent kernels. */ +#define SYS_ACPI_UEVENT_BAT_CAPACITY_KEY "POWER_SUPPLY_CAPACITY" +/* + * Older kernlels -- capacity is computed as division of: + * POWER_SUPPLY_ENERGY_NOW / POWER_SUPPLY_ENERGY_FULL + * or + * POWER_SUPPLY_CHARGE_NOW / POWER_SUPPLY_CHARGE_FULL + */ +#define SYS_ACPI_UEVENT_BAT_ENERGY_FULL_KEY "POWER_SUPPLY_ENERGY_FULL" +#define SYS_ACPI_UEVENT_BAT_ENERGY_NOW_KEY "POWER_SUPPLY_ENERGY_NOW" +#define SYS_ACPI_UEVENT_BAT_CHARGE_FULL_KEY "POWER_SUPPLY_CHARGE_FULL" +#define SYS_ACPI_UEVENT_BAT_CHARGE_NOW_KEY "POWER_SUPPLY_CHARGE_NOW" + +/* Debug function to print out uevent file key-value pairs. */ +static void +uevent_ghfunc(gpointer key, gpointer value, gpointer user_data) +{ + gchar* k = (gchar*) key; + gchar* v = (gchar*) value; + g_fprintf(stderr, "'%s' => '%s'\n", k, v); +} + +/* Parses uevent file returning the result as GHashTable. */ +static GHashTable* +uevent_parse(gchar* filename) +{ + GHashTable* hash = NULL; + GString* key = g_string_sized_new(STRING_LEN); + GString* value = g_string_sized_new(STRING_LEN); + gchar* buf = NULL; + guint buf_len = 0; + gchar c; + guint i; + gboolean equals_sign_found = FALSE; + + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { + if (g_file_get_contents(filename, &buf, 0, NULL)) { + hash = g_hash_table_new_full(&g_str_hash, &g_str_equal, &g_free, &g_free); + buf_len = strlen(buf); + + for (i = 0; i < buf_len; ++i) { + c = buf[i]; + if (c == '=' && !equals_sign_found) { + equals_sign_found = TRUE; + } else if (c == '\n' && equals_sign_found) { + equals_sign_found = FALSE; + g_hash_table_insert(hash, g_strdup(key->str), g_strdup(value->str)); + g_string_truncate(key, 0); + g_string_truncate(value, 0); + } else { + if (equals_sign_found) { + g_string_append_c(value, c); + } else { + g_string_append_c(key, c); + } + } + } + if (DEBUG) { + g_hash_table_foreach(hash, &uevent_ghfunc, NULL); + } + } + } + + g_free(buf); + g_string_free(key, TRUE); + g_string_free(value, TRUE); + + return hash; +} + +static ac* +ac_new(gchar* path) +{ + ac* tmp = g_new(ac, 1); + tmp->path = path; + tmp->name = NULL; + tmp->online = FALSE; + return tmp; +} + +static void +ac_free(gpointer p) +{ + ac* tmp = (ac*) p; + g_free(tmp->path); + g_free(tmp->name); + g_free(tmp); + if (DEBUG) { + g_fprintf(stderr, "ac_free %p\n", p); + } +} + +static void +ac_print(gpointer p, gpointer user_data) +{ + ac* tmp = (ac*) p; + g_fprintf(stderr, "AC\n path: %s\n name: %s\n online: %d\n", tmp->path, tmp->name, tmp->online); +} + +/* Parses information about AC power supply based on ac->path. */ +static ac* +ac_parse(ac* ac) +{ + GHashTable* hash; + gchar* tmp_value; + + if (ac->path != NULL) { + hash = uevent_parse(ac->path); + if (hash != NULL) { + // ac name + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_NAME_KEY); + if (tmp_value != NULL) { + ac->name = g_strdup(tmp_value); + } + + // ac online + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_AC_ONLINE_KEY); + if (tmp_value != NULL) { + ac->online = strcmp(SYS_ACPI_UEVENT_AC_ONLINE_VALUE, tmp_value) == 0; + } + + g_hash_table_destroy(hash); + } + } + + return ac; +} + +static bat* +bat_new(gchar* path) +{ + bat* tmp = g_new(bat, 1); + tmp->path = path; + tmp->name = NULL; + tmp->status = NULL; + tmp->capacity = -1.0d; + return tmp; +} + +static void +bat_free(gpointer p) +{ + bat* tmp = (bat*) p; + g_free(tmp->path); + g_free(tmp->name); + g_free(tmp->status); + g_free(tmp); + if (DEBUG) { + g_fprintf(stderr, "bat_free %p\n", p); + } +} + +static void +bat_print(gpointer p, gpointer user_data) +{ + bat* tmp = (bat*) p; + g_fprintf(stderr, "BATTERY\n path: %s\n name: %s\n status: %s\n capacity: %f\n", tmp->path, tmp->name, tmp->status, tmp->capacity); +} + +/* Parses information about BATTERY power supply based on bat->path. */ +static bat* +bat_parse(bat* bat) +{ + GHashTable* hash; + gchar* tmp_value; + + if (bat->path != NULL) { + hash = uevent_parse(bat->path); + if (hash != NULL) { + // battery name + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_NAME_KEY); + if (tmp_value != NULL) { + bat->name = g_strdup(tmp_value); + } + + // battery status + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_BAT_STATUS_KEY); + if (tmp_value != NULL) { + bat->status = g_strdup(tmp_value); + } + + // battery remaining capacity + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_BAT_CAPACITY_KEY); + if (tmp_value != NULL) { + bat->capacity = g_ascii_strtod(tmp_value, NULL); + } else { // for older kernels + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_BAT_ENERGY_NOW_KEY); + gdouble tmp = -1.0d; + if (tmp_value != NULL) { // ac off + tmp = g_ascii_strtod(tmp_value, NULL); + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_BAT_ENERGY_FULL_KEY); + if (tmp_value != NULL && tmp > 0.0d) { + tmp = tmp / g_ascii_strtod(tmp_value, NULL) * 100.0d; + bat->capacity = tmp; + } + } else { + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_BAT_CHARGE_NOW_KEY); + if (tmp_value != NULL) { // ac on + tmp = g_ascii_strtod(tmp_value, NULL); + tmp_value = (gchar*) g_hash_table_lookup(hash, SYS_ACPI_UEVENT_BAT_CHARGE_FULL_KEY); + if (tmp_value != NULL && tmp > 0.0d) { + tmp = tmp / g_ascii_strtod(tmp_value, NULL) * 100.0d; + bat->capacity = tmp; + } + } + } + } + + g_hash_table_destroy(hash); + } + } + + return bat; +} + +extern power_supply* +power_supply_new() { + power_supply* tmp = g_new(power_supply, 1); + tmp->ac_list = g_sequence_new(&ac_free); + tmp->bat_list = g_sequence_new(&bat_free); + return tmp; +} + +extern void +power_supply_free(gpointer p) { + power_supply* tmp = (power_supply*) p; + g_sequence_free(tmp->ac_list); + g_sequence_free(tmp->bat_list); + g_free(tmp); + if (DEBUG) { + g_fprintf(stderr, "power_supply_free %p\n", p); + } +} + +/* Parses power supplies on the current system. */ +extern power_supply* +power_supply_parse(power_supply* ps) { + GDir* dir = NULL; + const gchar* tmp; + GString* filename = g_string_sized_new(STRING_LEN); + guint len = 0; + gchar* contents; + + if (g_file_test(SYS_ACPI_PATH, G_FILE_TEST_IS_DIR)) { + dir = g_dir_open(SYS_ACPI_PATH, 0, NULL); + if (dir != NULL) { + while ((tmp = g_dir_read_name(dir)) != NULL) { + g_string_append(filename, SYS_ACPI_PATH); + g_string_append(filename, tmp); + g_string_append_c(filename, G_DIR_SEPARATOR); + len = filename->len; + g_string_append(filename, SYS_ACPI_TYPE_FILE); + if (g_file_test(filename->str, G_FILE_TEST_IS_REGULAR)) { + g_file_get_contents(filename->str, &contents, 0, NULL); + g_string_truncate(filename, len); + g_string_append(filename, SYS_ACPI_UEVENT_FILE); + if (strcmp(SYS_ACPI_TYPE_AC, contents) == 0) { + ac* tmp = ac_new(g_strdup(filename->str)); + ac_parse(tmp); + g_sequence_append(ps->ac_list, tmp); + } else if (strcmp(SYS_ACPI_TYPE_BAT, contents) == 0) { + bat* tmp = bat_new(g_strdup(filename->str)); + bat_parse(tmp); + g_sequence_append(ps->bat_list, tmp); + } else { + g_fprintf(stderr, "unsupported power supply type %s", contents); + } + g_free(contents); + } + g_string_truncate(filename, 0); + } + g_dir_close(dir); + } + } + + g_string_free(filename, TRUE); + + if (DEBUG) { + g_sequence_foreach(ps->ac_list, &ac_print, NULL); + g_sequence_foreach(ps->bat_list, &bat_print, NULL); + } + + return ps; +} + +extern gboolean +power_supply_is_ac_online(power_supply* ps) +{ + gboolean ac_online = FALSE; + GSequenceIter* it; + ac* ac_power; + if (ps->ac_list != NULL) { + it = g_sequence_get_begin_iter(ps->ac_list); + while (!g_sequence_iter_is_end(it)) { + ac_power = (ac*) g_sequence_get(it); + if (ac_power->online) { + ac_online = TRUE; + break; + } + it = g_sequence_iter_next(it); + } + } + return ac_online; +} + +extern gdouble +power_supply_get_bat_capacity(power_supply* ps) +{ + gdouble total_bat_capacity = 0.0d; + guint bat_count = 0; + GSequenceIter* it; + bat* battery; + if (ps->bat_list != NULL) { + it = g_sequence_get_begin_iter(ps->bat_list); + while (!g_sequence_iter_is_end(it)) { + battery = (bat*) g_sequence_get(it); + if (battery->capacity > 0.0d) { + total_bat_capacity = total_bat_capacity + battery->capacity; + } + bat_count++; + it = g_sequence_iter_next(it); + } + } + return total_bat_capacity / bat_count; +} diff --git a/plugins/battery/power_supply.h b/plugins/battery/power_supply.h new file mode 100644 index 0000000..ba5e3ed --- /dev/null +++ b/plugins/battery/power_supply.h @@ -0,0 +1,55 @@ +// Time-stamp: < power_supply.h (2015-12-04 19:01) > + +#ifndef POWER_SUPPLY_H +#define POWER_SUPPLY_H + +#include + +/* Struct representing AC power supply. */ +typedef struct { + /* Path to uevent file. */ + gchar* path; + gchar* name; + gboolean online; +} ac; + +/* Struct representing BATTERY power supply. */ +typedef struct { + /* Path to uevent file. */ + gchar* path; + gchar* name; + gchar* status; + /* In percent 0.0--100.0. */ + gdouble capacity; +} bat; + +/* Struct representing all the power supplies on current system. */ +typedef struct { + /* List of ac structs. */ + GSequence* ac_list; + /* List of bat structs. */ + GSequence* bat_list; +} power_supply; + +/* Allocate memory for struct power_supply. */ +power_supply* power_supply_new(); + +/* Free memory allocated by power_supply_new(). */ +void power_supply_free(gpointer p); + +/* Parses power supplies on the current system. */ +power_supply* power_supply_parse(); + +/* + * Return TRUE if AC power is on (ie. at least one AC adapter is on). + */ +gboolean power_supply_is_ac_online(power_supply* ps); + +/* + * Return total BATTERY capacity (as percentage of capacity) on the + * system as an average of all batteries capacity div by number of + * batteries. + */ +gdouble power_supply_get_bat_capacity(power_supply* ps); + +#endif /* POWER_SUPPLY_H */ diff --git a/plugins/chart/.gitignore b/plugins/chart/.gitignore new file mode 100644 index 0000000..829128a --- /dev/null +++ b/plugins/chart/.gitignore @@ -0,0 +1,3 @@ +chart.o +chart.d +libchart.so diff --git a/plugins/cpu/.gitignore b/plugins/cpu/.gitignore new file mode 100644 index 0000000..b68da54 --- /dev/null +++ b/plugins/cpu/.gitignore @@ -0,0 +1,3 @@ +cpu.o +cpu.d +libcpu.so diff --git a/plugins/cpu/cpu.c b/plugins/cpu/cpu.c index b148ad8..fef3ca8 100644 --- a/plugins/cpu/cpu.c +++ b/plugins/cpu/cpu.c @@ -46,8 +46,8 @@ cpu_get_load_real(struct cpu_stat *cpu) stat = fopen("/proc/stat", "r"); if(!stat) return -1; - fscanf(stat, "cpu %lu %lu %lu %lu %lu", &cpu->u, &cpu->n, &cpu->s, - &cpu->i, &cpu->w); + if (fscanf(stat, "cpu %lu %lu %lu %lu %lu", &cpu->u, &cpu->n, &cpu->s, + &cpu->i, &cpu->w)); fclose(stat); return 0; } diff --git a/plugins/dclock/.gitignore b/plugins/dclock/.gitignore new file mode 100644 index 0000000..b1331e4 --- /dev/null +++ b/plugins/dclock/.gitignore @@ -0,0 +1,3 @@ +dclock.o +dclock.d +libdclock.so diff --git a/plugins/deskno/.gitignore b/plugins/deskno/.gitignore new file mode 100644 index 0000000..c1ad8ce --- /dev/null +++ b/plugins/deskno/.gitignore @@ -0,0 +1,3 @@ +deskno.o +deskno.d +libdeskno.so diff --git a/plugins/deskno2/.gitignore b/plugins/deskno2/.gitignore new file mode 100644 index 0000000..63dbedf --- /dev/null +++ b/plugins/deskno2/.gitignore @@ -0,0 +1,3 @@ +deskno2.o +deskno2.d +libdeskno2.so diff --git a/plugins/deskno2/deskno2.c b/plugins/deskno2/deskno2.c index 213a041..1ea39c8 100644 --- a/plugins/deskno2/deskno2.c +++ b/plugins/deskno2/deskno2.c @@ -25,7 +25,7 @@ typedef struct { static void clicked(GtkWidget *widget, deskno_priv *dc) { - system("xfce-setting-show workspaces"); + if (system("xfce-setting-show workspaces")); } static void diff --git a/plugins/genmon/.gitignore b/plugins/genmon/.gitignore new file mode 100644 index 0000000..0ed635a --- /dev/null +++ b/plugins/genmon/.gitignore @@ -0,0 +1,3 @@ +genmon.o +genmon.d +libgenmon.so diff --git a/plugins/genmon/genmon.c b/plugins/genmon/genmon.c index 7f3ef30..274ed6b 100644 --- a/plugins/genmon/genmon.c +++ b/plugins/genmon/genmon.c @@ -47,7 +47,7 @@ text_update(genmon_priv *gm) ENTER; fp = popen(gm->command, "r"); - fgets(text, sizeof(text), fp); + if (fgets(text, sizeof(text), fp)); pclose(fp); len = strlen(text) - 1; if (len >= 0) { diff --git a/plugins/icons/.gitignore b/plugins/icons/.gitignore new file mode 100644 index 0000000..e61efdd --- /dev/null +++ b/plugins/icons/.gitignore @@ -0,0 +1,3 @@ +icons.o +icons.d +libicons.so diff --git a/plugins/image/.gitignore b/plugins/image/.gitignore new file mode 100644 index 0000000..a9f34b9 --- /dev/null +++ b/plugins/image/.gitignore @@ -0,0 +1,3 @@ +image.o +image.d +libimage.so diff --git a/plugins/image/image.c b/plugins/image/image.c index 5a6cbe0..c034657 100644 --- a/plugins/image/image.c +++ b/plugins/image/image.c @@ -68,8 +68,8 @@ image_constructor(plugin_instance *p) ratio * ((float) gdk_pixbuf_get_height(gp)), GDK_INTERP_HYPER); gdk_pixbuf_render_pixmap_and_mask(gps, &img->pix, &img->mask, 127); - gdk_pixbuf_unref(gp); - gdk_pixbuf_unref(gps); + g_object_unref(gp); + g_object_unref(gps); wid = gtk_image_new_from_pixmap(img->pix, img->mask); } diff --git a/plugins/launchbar/.gitignore b/plugins/launchbar/.gitignore new file mode 100644 index 0000000..c07f3ac --- /dev/null +++ b/plugins/launchbar/.gitignore @@ -0,0 +1,3 @@ +launchbar.o +launchbar.d +liblaunchbar.so diff --git a/plugins/mem/.gitignore b/plugins/mem/.gitignore new file mode 100644 index 0000000..4adf20f --- /dev/null +++ b/plugins/mem/.gitignore @@ -0,0 +1,3 @@ +mem.o +mem.d +libmem.so diff --git a/plugins/mem2/.gitignore b/plugins/mem2/.gitignore new file mode 100644 index 0000000..e08398d --- /dev/null +++ b/plugins/mem2/.gitignore @@ -0,0 +1,3 @@ +mem2.o +mem2.d +libmem2.so diff --git a/plugins/menu/.gitignore b/plugins/menu/.gitignore new file mode 100644 index 0000000..b8b598a --- /dev/null +++ b/plugins/menu/.gitignore @@ -0,0 +1,5 @@ +menu.o +menu.d +system_menu.o +system_menu.d +libmenu.so diff --git a/plugins/menu/menu.c b/plugins/menu/menu.c index ef1c4fe..9e0183d 100644 --- a/plugins/menu/menu.c +++ b/plugins/menu/menu.c @@ -11,23 +11,11 @@ #include "bg.h" #include "gtkbgbox.h" #include "run.h" +#include "menu.h" //#define DEBUGPRN #include "dbg.h" -#define MENU_DEFAULT_ICON_SIZE 22 - -typedef struct { - plugin_instance plugin; - GtkWidget *menu, *bg; - int iconsize, paneliconsize; - xconf *xc; - guint tout, rtout; - gboolean has_system_menu; - time_t btime; - gint icon_size; -} menu_priv; - xconf *xconf_new_from_systemmenu(); gboolean systemmenu_changed(time_t btime); static void menu_create(plugin_instance *p); @@ -371,20 +359,23 @@ menu_destructor(plugin_instance *p) g_signal_handlers_disconnect_by_func(G_OBJECT(icon_theme), schedule_rebuild_menu, p); menu_destroy(m); + gtk_widget_destroy(m->bg); RET(); } -static plugin_class class = { - .count = 0, - .type = "menu", - .name = "Menu", - .version = "1.0", - .description = "Menu", - .priv_size = sizeof(menu_priv), +static menu_class class = { + .plugin = { + .count = 0, + .type = "menu", + .name = "Menu", + .version = "1.0", + .description = "Menu", + .priv_size = sizeof(menu_priv), - .constructor = menu_constructor, - .destructor = menu_destructor, + .constructor = menu_constructor, + .destructor = menu_destructor, + } }; static plugin_class *class_ptr = (plugin_class *) &class; diff --git a/plugins/menu/menu.h b/plugins/menu/menu.h new file mode 100644 index 0000000..f7b5429 --- /dev/null +++ b/plugins/menu/menu.h @@ -0,0 +1,26 @@ +#ifndef MENU_H +#define MENU_H + + +#include "plugin.h" +#include "panel.h" + +#define MENU_DEFAULT_ICON_SIZE 22 + +typedef struct { + plugin_instance plugin; + GtkWidget *menu, *bg; + int iconsize, paneliconsize; + xconf *xc; + guint tout, rtout; + gboolean has_system_menu; + time_t btime; + gint icon_size; +} menu_priv; + +typedef struct { + plugin_class plugin; +} menu_class; + + +#endif diff --git a/plugins/meter/.gitignore b/plugins/meter/.gitignore new file mode 100644 index 0000000..7f853ba --- /dev/null +++ b/plugins/meter/.gitignore @@ -0,0 +1,3 @@ +meter.o +meter.d +libmeter.so diff --git a/plugins/net/.gitignore b/plugins/net/.gitignore new file mode 100644 index 0000000..3161da5 --- /dev/null +++ b/plugins/net/.gitignore @@ -0,0 +1,3 @@ +net.o +net.d +libnet.so diff --git a/plugins/net/net.c b/plugins/net/net.c index 92e2d30..2a60f44 100644 --- a/plugins/net/net.c +++ b/plugins/net/net.c @@ -60,8 +60,8 @@ net_get_load_real(net_priv *c, struct net_stat *net) stat = fopen("/proc/net/dev", "r"); if(!stat) return -1; - fgets(buf, 256, stat); - fgets(buf, 256, stat); + if (fgets(buf, 256, stat)); + if (fgets(buf, 256, stat)); while (!s && !feof(stat) && fgets(buf, 256, stat)) s = g_strrstr(buf, c->iface); diff --git a/plugins/pager/.gitignore b/plugins/pager/.gitignore new file mode 100644 index 0000000..10debd8 --- /dev/null +++ b/plugins/pager/.gitignore @@ -0,0 +1,3 @@ +pager.o +pager.d +libpager.so diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c index b2bc877..ebe2052 100644 --- a/plugins/pager/pager.c +++ b/plugins/pager/pager.c @@ -707,7 +707,8 @@ pager_bg_changed(FbBg *bg, pager_priv *pg) static void pager_rebuild_all(FbEv *ev, pager_priv *pg) { - int desknum, curdesk, dif, i; + int desknum, dif, i; + int curdesk G_GNUC_UNUSED; ENTER; desknum = pg->desknum; diff --git a/plugins/separator/.gitignore b/plugins/separator/.gitignore new file mode 100644 index 0000000..a8ff622 --- /dev/null +++ b/plugins/separator/.gitignore @@ -0,0 +1,3 @@ +separator.o +separator.d +libseparator.so diff --git a/plugins/space/.gitignore b/plugins/space/.gitignore new file mode 100644 index 0000000..9df367b --- /dev/null +++ b/plugins/space/.gitignore @@ -0,0 +1,3 @@ +space.o +space.d +libspace.so diff --git a/plugins/systray/.gitignore b/plugins/systray/.gitignore new file mode 100644 index 0000000..3233d74 --- /dev/null +++ b/plugins/systray/.gitignore @@ -0,0 +1,9 @@ +egg-marshal.o +egg-marshal.d +eggtraymanager.o +eggtraymanager.d +fixedtip.o +fixedtip.d +main.o +main.d +libtray.so diff --git a/plugins/taskbar/.gitignore b/plugins/taskbar/.gitignore new file mode 100644 index 0000000..ad7eefa --- /dev/null +++ b/plugins/taskbar/.gitignore @@ -0,0 +1,3 @@ +taskbar.o +taskbar.d +libtaskbar.so diff --git a/plugins/taskbar/taskbar.c b/plugins/taskbar/taskbar.c index 507615f..be81796 100644 --- a/plugins/taskbar/taskbar.c +++ b/plugins/taskbar/taskbar.c @@ -847,10 +847,7 @@ tk_callback_button_release_event(GtkWidget *widget, GdkEventButton *event, */ tk->tb->menutask = tk; gtk_menu_popup (GTK_MENU (tk->tb->menu), NULL, NULL, - (GtkMenuPositionFunc)menu_pos, - tk->tb->plugin.panel->orientation == GTK_ORIENTATION_HORIZONTAL - ? NULL : widget, - event->button, event->time); + (GtkMenuPositionFunc)menu_pos, widget, event->button, event->time); } gtk_button_released(GTK_BUTTON(widget)); diff --git a/plugins/tclock/.gitignore b/plugins/tclock/.gitignore new file mode 100644 index 0000000..e7c28f6 --- /dev/null +++ b/plugins/tclock/.gitignore @@ -0,0 +1,3 @@ +tclock.o +tclock.d +libtclock.so diff --git a/plugins/user/.gitignore b/plugins/user/.gitignore new file mode 100644 index 0000000..f220c49 --- /dev/null +++ b/plugins/user/.gitignore @@ -0,0 +1,3 @@ +user.o +user.d +libuser.so diff --git a/plugins/user/Makefile b/plugins/user/Makefile new file mode 100644 index 0000000..8025a41 --- /dev/null +++ b/plugins/user/Makefile @@ -0,0 +1,10 @@ +## miniconf makefiles ## 1.1 ## + +TOPDIR := ../.. + +user_src = user.c +user_cflags = -DPLUGIN $(GTK2_CFLAGS) +user_libs = $(GTK2_LIBS) +user_type = lib + +include $(TOPDIR)/.config/rules.mk diff --git a/plugins/user/user.c b/plugins/user/user.c new file mode 100644 index 0000000..62b4ff7 --- /dev/null +++ b/plugins/user/user.c @@ -0,0 +1,141 @@ + +#include "misc.h" +#include "run.h" +#include "../menu/menu.h" +#include +#include +#include +#include + + +//#define DEBUGPRN +#include "dbg.h" + +typedef struct { + menu_priv chart; + gint dummy; + guint sid; + GPid pid; +} user_priv; + +static menu_class *k; + + +static void user_destructor(plugin_instance *p); + +#define GRAVATAR_LEN 300 + +static void +fetch_gravatar_done(GPid pid, gint status, gpointer data) +{ + user_priv *c G_GNUC_UNUSED = data; + plugin_instance *p G_GNUC_UNUSED = data; + gchar *image = NULL, *icon = NULL; + + ENTER; + DBG("status %d\n", status); + g_spawn_close_pid(c->pid); + c->pid = 0; + c->sid = 0; + + if (status) + RET(); + DBG("rebuild menu\n"); + XCG(p->xc, "icon", &icon, strdup); + XCG(p->xc, "image", &image, strdup); + XCS(p->xc, "image", image, value); + xconf_del(xconf_find(p->xc, "icon", 0), FALSE); + PLUGIN_CLASS(k)->destructor(p); + PLUGIN_CLASS(k)->constructor(p); + if (image) { + XCS(p->xc, "image", image, value); + g_free(image); + } + if (icon) { + XCS(p->xc, "icon", icon, value); + g_free(icon); + } + RET(); +} + + +static gboolean +fetch_gravatar(gpointer data) +{ + user_priv *c G_GNUC_UNUSED = data; + plugin_instance *p G_GNUC_UNUSED = data; + GChecksum *cs; + gchar *gravatar = NULL; + gchar buf[GRAVATAR_LEN]; + // FIXME: select more secure path + gchar *image = "/tmp/gravatar"; + gchar *argv[] = { "wget", "-q", "-O", image, buf, NULL }; + + ENTER; + cs = g_checksum_new(G_CHECKSUM_MD5); + XCG(p->xc, "gravataremail", &gravatar, str); + g_checksum_update(cs, (guchar *) gravatar, -1); + snprintf(buf, sizeof(buf), "http://www.gravatar.com/avatar/%s", + g_checksum_get_string(cs)); + g_checksum_free(cs); + DBG("gravatar '%s'\n", buf); + c->pid = run_app_argv(argv); + c->sid = g_child_watch_add(c->pid, fetch_gravatar_done, data); + RET(FALSE); +} + + +static int +user_constructor(plugin_instance *p) +{ + user_priv *c G_GNUC_UNUSED = (user_priv *) p; + gchar *image = NULL; + gchar *icon = NULL; + gchar *gravatar = NULL; + + ENTER; + if (!(k = class_get("menu"))) + RET(0); + XCG(p->xc, "image", &image, str); + XCG(p->xc, "icon", &icon, str); + if (!(image || icon)) + XCS(p->xc, "icon", "avatar-default", value); + if (!PLUGIN_CLASS(k)->constructor(p)) + RET(0); + XCG(p->xc, "gravataremail", &gravatar, str); + DBG("gravatar email '%s'\n", gravatar); + if (gravatar) + g_timeout_add(300, fetch_gravatar, p); + gtk_widget_set_tooltip_markup(p->pwid, "User"); + RET(1); +} + + +static void +user_destructor(plugin_instance *p) +{ + user_priv *c G_GNUC_UNUSED = (user_priv *) p; + + ENTER; + PLUGIN_CLASS(k)->destructor(p); + if (c->pid) + kill(c->pid, SIGKILL); + if (c->sid) + g_source_remove(c->sid); + class_put("menu"); + RET(); +} + + +static plugin_class class = { + .count = 0, + .type = "user", + .name = "User menu", + .version = "1.0", + .description = "User photo and menu of user actions", + .priv_size = sizeof(user_priv), + + .constructor = user_constructor, + .destructor = user_destructor, +}; +static plugin_class *class_ptr = (plugin_class *) &class; diff --git a/plugins/volume/.gitignore b/plugins/volume/.gitignore new file mode 100644 index 0000000..1e9969e --- /dev/null +++ b/plugins/volume/.gitignore @@ -0,0 +1,3 @@ +volume.o +volume.d +libvolume.so diff --git a/plugins/wincmd/.gitignore b/plugins/wincmd/.gitignore new file mode 100644 index 0000000..09b285e --- /dev/null +++ b/plugins/wincmd/.gitignore @@ -0,0 +1,3 @@ +wincmd.o +wincmd.d +libwincmd.so diff --git a/po/.gitignore b/po/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/po/fr_FR.UTF-8.po b/po/fr_FR.UTF-8.po index c3eb657..d738765 100644 --- a/po/fr_FR.UTF-8.po +++ b/po/fr_FR.UTF-8.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: fbpanel 6.2\n" +"Project-Id-Version: fbpanel 7.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-09-30 02:07+0200\n" "PO-Revision-Date: 2010-09-30 02:07+0200\n" diff --git a/po/ru_RU.UTF-8.po b/po/ru_RU.UTF-8.po index d04468e..0af1fe9 100644 --- a/po/ru_RU.UTF-8.po +++ b/po/ru_RU.UTF-8.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: fbpanel 6.2\n" +"Project-Id-Version: fbpanel 7.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-09-30 02:02+0200\n" "PO-Revision-Date: 2010-09-30 02:02+0200\n" diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/version b/version index 0cda48a..4fedf1d 100644 --- a/version +++ b/version @@ -1 +1 @@ -6.2 +7.0