grim/guifications1

fe3c04ffd8b2
Parents 74e5275bdfcc
Children ca0ee4df16ba
Start of the clean up for the next release..
--- a/AUTHORS Thu Jan 15 15:25:19 2004 +0000
+++ b/AUTHORS Wed Mar 10 00:59:18 2004 +0000
@@ -7,4 +7,4 @@
Special Thanks
==============
Stu Tomlinson for the rpm's
-Nathan Walp for helping cleanup the out of tree compile
+Nathan Walp for helping with cleaning up the out of tree compile
--- a/ChangeLog Thu Jan 15 15:25:19 2004 +0000
+++ b/ChangeLog Wed Mar 10 00:59:18 2004 +0000
@@ -1,8 +1,8 @@
-Version 1.6 :
+Version 1.5.1 :
* Added a signal emit so that we can display other plugins contributions to
the buddy context menu
- * Added configure arguments to the advanced tab. Not much use for this yet
- be down the line
+ * Fixed some memory leaks in the ellipsis code
+ * Fixed some spelling mistakes
Version 1.5 01/10/04:
* Guifications will no longer work with Gaim prior to 0.75, if you do
--- a/VERSION Thu Jan 15 15:25:19 2004 +0000
+++ b/VERSION Wed Mar 10 00:59:18 2004 +0000
@@ -1,1 +1,1 @@
-1.6cvs
+1.5.1cvs
--- a/src/Makefile.am Thu Jan 15 15:25:19 2004 +0000
+++ b/src/Makefile.am Wed Mar 10 00:59:18 2004 +0000
@@ -6,9 +6,7 @@
gf_utils.h \
gf_pngs.h \
gf_gtkutils.h \
- gf_types.h \
- gf_pixbuf.h \
- gf_theme.h
+ gf_types.h
plugindir = $(libdir)/gaim
@@ -24,8 +22,7 @@
gf_prefs.c \
gf_utils.c \
gf_pngs.c \
- gf_gtkutils.c \
- gf_pixbuf.c
+ gf_gtkutils.c
endif
--- a/src/gf_conf.c Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_conf.c Wed Mar 10 00:59:18 2004 +0000
@@ -80,7 +80,7 @@
sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
/* create behavior tab */
- vbox = gf_add_page(GTK_NOTEBOOK(note), "Bahavior", -1);
+ vbox = gf_add_page(GTK_NOTEBOOK(note), "Behavior", -1);
/* create notification frame */
frame = gaim_gtk_make_frame(vbox, "Notifications");
--- a/src/gf_gtkutils.c Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_gtkutils.c Wed Mar 10 00:59:18 2004 +0000
@@ -20,7 +20,6 @@
#include "gf_gtkutils.h"
#include "gf_types.h"
-#include "gf_theme.h"
#include "gf_pngs.h"
/***********************************************************************
@@ -170,10 +169,18 @@
g_object_unref(pixbuf);
switch (item) {
- case text_clipping_truncate: label = gtk_label_new("Truncate"); break;
- case text_clipping_elipse_start: label = gtk_label_new("Elipse at the beginning"); break;
- case text_clipping_elipse_middle: label = gtk_label_new("Elipse in the middle"); break;
- case text_clipping_elipse_end: label = gtk_label_new("Elipse at the end"); break;
+ case text_clipping_truncate:
+ label = gtk_label_new("Truncate");
+ break;
+ case text_clipping_elipse_start:
+ label = gtk_label_new("Ellipsis at the beginning");
+ break;
+ case text_clipping_elipse_middle:
+ label = gtk_label_new("Ellipsis in the middle");
+ break;
+ case text_clipping_elipse_end:
+ label = gtk_label_new("Ellipsis at the end");
+ break;
}
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
--- a/src/gf_gtkutils.h Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_gtkutils.h Wed Mar 10 00:59:18 2004 +0000
@@ -22,7 +22,6 @@
#include <gtk/gtk.h>
#include "gf_types.h"
-#include "gf_theme.h"
GtkWidget *gf_make_hig_frame(GtkWidget *parent, const gchar *title);
GtkWidget *gf_make_label(gchar *text, GtkSizeGroup *sg);
--- a/src/gf_pixbuf.c Thu Jan 15 15:25:19 2004 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,315 +0,0 @@
-/*
- Guifications - The notification plugin to end all notification plugins!
- Copyright (C) 2003-2004 Gary Kramlich
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <pango/pango.h>
-#include <string.h>
-
-#include "gtkblist.h"
-#include "blist.h"
-#include "server.h"
-#include "debug.h"
-
-#include "gf_pixbuf.h"
-#include "gf_types.h"
-
-static gchar *
-gf_format_text(GaimBuddy *buddy, gint line, gf_event event, gf_theme *theme) {
- /* Formatting Options
- %N = Screen Name %A = Alias
- %P = Protocol %M = Away Message
- %C = Account %W = Warning level
- */
- char formatted[255], *format;
- gchar *buff = NULL;
- int c = 0, i = 0;
-
- format = theme->notification[event].text[line].format;
-
- while (*format) {
- if (*format == '%') {
- switch(*(format+1)) {
- case 'N': /* screen name */
- for (i = 0; i < strlen(buddy->name); i++)
- formatted[c+i] = buddy->name[i];
- c += i;
- break;
- case 'A': /* alias, follows alias pref rules */
- buff = g_strdup(gaim_get_buddy_alias(buddy));
- for (i = 0; i < strlen(buff); i++)
- formatted[c+i] = buff[i];
- c+=i;
- g_free(buff);
- break;
- case 'P': /* protocol */
- buff = g_strdup(gaim_account_get_protocol_id(buddy->account));
- for (i = 0; i < strlen(buff); i++)
- formatted[c+i] = buff[i];
- c+=i;
- g_free(buff);
- break;
- case 'M': /* away message if event isn't away this value
- gets removed */
- if (event == gf_event_away) {
- /*buff = g_strdup(serv_get_away(buddy->account->gc, buddy->name)); */
- for (i = 0; i < strlen(buff); i++)
- formatted[c+i] = buff[i];
- c+=i;
- g_free(buff);
- }
- break;
- case 'C': /* account name */
- buff = g_strdup(buddy->account->username);
- for (i = 0; i < strlen(buff); i++)
- formatted[c+i] = buff[i];
- c+=i;
- g_free(buff);
- break;
- case 'W': /* warning level, if protocol isn't oscar this
- value gets removed */
- break;
- case '%':
- formatted[i] = '%';
- c++;
- break;
- }
- } else {
- formatted[i] = *format;
- c++;
- }
- format++;
- }
-
- return g_strdup(formatted);
-}
-
-static void
-gf_background_get_size(gint *width, gint *height, gf_event event, gf_theme *theme) {
- GError *error;
- GdkPixbuf *background;
- gchar *filename;
-
- if (g_path_is_absolute(theme->notification[event].image))
- filename = g_strdup(theme->notification[event].image);
- else
- filename = g_build_filename(theme->directory, theme->notification[event].image, NULL);
-
- background = gdk_pixbuf_new_from_file(filename, &error);
- if (background == NULL) {
- *width = *height = -1;
- gaim_debug_info("Guifications", "Error getting background image size: %s\n", error->message);
- return;
- }
-
- *width = gdk_pixbuf_get_width(background);
- *height = gdk_pixbuf_get_height(background);
-
- g_object_unref(background);
-}
-
-static gint
-gf_icon_get_size(gint icon, gf_event event, gf_theme *theme) {
- switch (theme->notification[event].icon[icon].size) {
- case icon_size_tiny: return 16; break;
- case icon_size_small: return 24; break;
- case icon_size_normal: return 48; break;
- case icon_size_large: return 96; break;
- case icon_size_huge: return 144; break;
- default: return 0; break;
- }
-}
-
-static void
-gf_icon_get_position(gint *x, gint *y, gint icon, gf_event event, gf_theme *theme) {
- gint bg_width, bg_height;
- gint bg_half_width, bg_half_height;
- gint icon_size, icon_half_size;
- gint icon_offset_x, icon_offset_y;
- gint icon_half_offset_x, icon_half_offset_y;
- gint north, east, south, west, lat, lon;
-
- gf_background_get_size(&bg_width, &bg_height, event, theme);
-
- if ((bg_width == -1) || (bg_height == -1)) {
- *x = *y = -1;
- gaim_debug_info("Guifications", "Failed to get background image size\n");
- return;
- }
-
- bg_half_width = bg_width / 2;
- bg_half_height = bg_height / 2;
-
- icon_size = gf_icon_get_size(icon, event, theme);
- icon_half_size = icon_size / 2;
-
- icon_offset_x = theme->notification[event].icon[icon].item.offset_horizontal;
- icon_offset_y = theme->notification[event].icon[icon].item.offset_vertical;
-
- icon_half_offset_x = icon_offset_x / 2;
- icon_half_offset_y = icon_offset_y / 2;
-
- north = icon_half_offset_y;
- east = bg_width - (icon_size + icon_offset_x);
- south = bg_height - (icon_size + icon_offset_y);
- west = icon_offset_x;
- lon = bg_half_width - (icon_half_size + icon_half_offset_x); /* x */
- lat = bg_half_height - (icon_half_size + icon_half_offset_y); /* y */
-
- switch (theme->notification[event].icon[icon].position) {
- case item_position_nw: *x = west; *y = north; break;
- case item_position_n: *x = lon; *y = north; break;
- case item_position_ne: *x = east; *y = north; break;
- case item_position_w: *x = west; *y = lat; break;
- case item_position_c: *x = lon; *y = lat; break;
- case item_position_e: *x = east; *y = lat; break;
- case item_position_sw: *x = west; *y = south; break;
- case item_position_s: *x = lon; *y = south; break;
- case item_position_se: *x = east; *y = south; break;
- }
-}
-
-static void
-gf_get_text_position(gint *x, gint *y, gint line, PangoLayout *layout, gf_event event, gf_theme *theme) {
- gint bg_width, bg_height;
- gint bg_half_width, bg_half_height;
- gint text_width, text_height;
- gint text_half_width, text_half_height;
- gint text_offset_x, text_offset_y;
- gint text_half_offset_x, text_half_offset_y;
- gint north, east, south, west, lat, lon;
-
- gf_background_get_size(&bg_width, &bg_height, event, theme);
-
- bg_half_width = bg_width / 2;
- bg_half_height = bg_height / 2;
-
- pango_layout_get_pixel_size(layout, &text_width, &text_height);
-
- if (theme->notification[event].text[line].width != 0)
- text_width = theme->notification[event].text[line].width;
-
- text_half_width = text_width / 2;
- text_half_height = text_height / 2;
-
- text_offset_x = theme->notification[event].text[line].item.offset_horizontal;
- text_offset_y = theme->notification[event].text[line].item.offset_vertical;
-
- text_half_offset_x = text_offset_x / 2;
- text_half_offset_y = text_offset_y / 2;
-
- north = text_offset_y;
- east = bg_width - (text_width + text_offset_x);
- south = bg_height - (text_height + text_offset_y);
- west = text_offset_x;
- lon = bg_half_width - (text_half_width + text_half_offset_x); /* x */
- lat = bg_half_height - (text_half_height + text_half_offset_y); /* y */
-
- switch (theme->notification[event].text[line].position) {
- case item_position_nw: *x = west; *y = north; break;
- case item_position_n: *x = lon; *y = north; break;
- case item_position_ne: *x = east; *y = north; break;
- case item_position_w: *x = west; *y = lat; break;
- case item_position_c: *x = lon; *y = lat; break;
- case item_position_e: *x = east; *y = lat; break;
- case item_position_sw: *x = west; *y = south; break;
- case item_position_s: *x = lon; *y = south; break;
- case item_position_se: *x = east; *y = south; break;
- }
-}
-
-static GdkPixbuf *
-gf_get_event_background(gf_event event, gf_theme *theme) {
- GError *error;
- GdkPixbuf *background = NULL;
- gchar *filename;
-
- if (g_path_is_absolute(theme->notification[event].image))
- filename = g_strdup(theme->notification[event].image);
- else
- filename = g_build_filename(theme->directory, theme->notification[event].image, NULL);
-
- background = gdk_pixbuf_new_from_file(filename, &error);
-
- if (background == NULL)
- gaim_debug_info("Guifications", "Error loading %s: %s\n", filename, error->message);
-
- g_free(filename);
-
- return background;
-}
-
-GdkPixbuf *
-gf_make_pixbuf(GaimBuddy *buddy, gf_event event, gf_theme *theme) {
- GdkPixbuf *gf_pixbuf = NULL;
- GdkPixbuf *background = NULL;
- GdkPixbuf *icon = NULL, *icon_scaled = NULL;
- gint icon_size = 0, icon_x = 0, icon_y = 0;
- gint i = 0;
- const char *buddy_icon_file;
-
- if ((background = gf_get_event_background(event, theme)) == NULL)
- return NULL;
-
- gf_pixbuf = gdk_pixbuf_copy(background);
- g_object_unref(background);
-
- if (theme->notification[event].icons > 0)
- for (i = 0; i < theme->notification[event].icons; i++) {
- if (!theme->notification[event].icon[i].item.visible)
- continue;
-
- switch (theme->notification[event].icon[i].type) {
- case icon_protocol:
- icon = create_prpl_icon(buddy->account);
- break;
- case icon_buddy:
- if ((buddy_icon_file = gaim_blist_node_get_string((GaimBlistNode*)buddy, "buddy_icon")) == NULL)
- continue;
- icon = gdk_pixbuf_new_from_file(buddy_icon_file, NULL);
- break;
- case icon_status:
- icon = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, GAIM_STATUS_ICON_LARGE);
- break;
- default:
- continue;
- break;
- }
- icon_size = gf_icon_get_size(i, event, theme);
- icon_scaled = gdk_pixbuf_scale_simple(icon, icon_size, icon_size, GDK_INTERP_BILINEAR);
- g_object_unref(icon);
-
- gf_icon_get_position(&icon_x, &icon_y, i, event, theme);
-
- gdk_pixbuf_composite(icon_scaled, gf_pixbuf,
- icon_x, icon_y,
- icon_size, icon_size,
- icon_x, icon_y,
- 1, 1,
- GDK_INTERP_BILINEAR,
- 255);
-
- g_object_unref(icon_scaled);
- }
-
- if (theme->notification[event].lines > 0)
- for (i = 0; i < theme->notification[event].lines; i++) {
- }
-
- return gf_pixbuf;
-}
--- a/src/gf_pixbuf.h Thu Jan 15 15:25:19 2004 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- Guifications - The notification plugin to end all notification plugins!
- Copyright (C) 2003-2004 Gary Kramlich
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#ifndef GF_PIXBUF_H
-#define GF_PIXBUF_H
-
-#include <gdk/gdk.h>
-#include <blist.h>
-
-#include "gf_theme.h"
-#include "gf_types.h"
-
-GdkPixbuf *gf_make_pixbuf(GaimBuddy *buddy, gf_event event, gf_theme *theme);
-
-#endif
--- a/src/gf_pngs.c Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_pngs.c Wed Mar 10 00:59:18 2004 +0000
@@ -27,7 +27,6 @@
#include "gf_pngs.h"
#include "gf_types.h"
-#include "gf_theme.h"
/***********************************************************************
* Statics
--- a/src/gf_pngs.h Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_pngs.h Wed Mar 10 00:59:18 2004 +0000
@@ -22,7 +22,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gf_types.h"
-#include "gf_theme.h"
/***********************************************************************
* Exports
**********************************************************************/
--- a/src/gf_prefs.c Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_prefs.c Wed Mar 10 00:59:18 2004 +0000
@@ -20,7 +20,6 @@
#include "debug.h"
#include "gf_types.h"
-#include "gf_theme.h"
#include "gf_prefs.h"
/**********************************************************************/
--- a/src/gf_theme.h Thu Jan 15 15:25:19 2004 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- Guifications - The notification plugin to end all notification plugins!
- Copyright (C) 2003-2004 Gary Kramlich
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#ifndef GF_THEME_H
-#define GF_THEME_H
-
-#include <glib.h>
-
-typedef enum _gf_theme_info {
- gf_theme_info_name = 0,
- gf_theme_info_version,
- gf_theme_info_description,
- gf_theme_info_author,
- gf_theme_info_website
-} gf_theme_info;
-
-typedef enum _gf_item_position {
- item_position_nw = 0,
- item_position_n,
- item_position_ne,
- item_position_w,
- item_position_c,
- item_position_e,
- item_position_sw,
- item_position_s,
- item_position_se
-} gf_item_position;
-
-typedef enum _gf_text_clipping {
- text_clipping_truncate = 0,
- text_clipping_elipse_start,
- text_clipping_elipse_middle,
- text_clipping_elipse_end
-} gf_text_clipping;
-
-typedef enum _gf_icon {
- icon_protocol = 0,
- icon_buddy,
- icon_status
-} gf_icon;
-
-typedef enum _gf_icon_size {
- icon_size_tiny = 0,
- icon_size_small,
- icon_size_normal,
- icon_size_large,
- icon_size_huge
-} gf_icon_size;
-
-typedef struct _gf_theme_item {
- gboolean visible;
- gint offset_horizontal;
- gint offset_vertical;
-} gf_theme_item;
-
-typedef struct _gf_theme_shadow {
- gf_theme_item item;
- gchar *color;
-} gf_theme_shadow;
-
-typedef struct _gf_theme_text {
- gf_theme_item item;
- gchar *font;
- gchar *color;
- gchar *format;
-
- gf_item_position position;
- gint width;
- gf_text_clipping clipping;
-
- gf_theme_shadow shadow;
-} gf_theme_text;
-
-typedef struct _gf_theme_icon {
- gf_theme_item item;
- gf_icon type;
- gf_item_position position;
- gf_icon_size size;
- gf_theme_shadow shadow;
-} gf_theme_icon;
-
-typedef struct _gf_theme_notification {
- gchar *image;
-
- gint lines;
- gf_theme_text *text;
-
- gint icons;
- gf_theme_icon *icon;
-} gf_theme_notification;
-
-typedef struct _gf_theme {
- gchar *info[5];
- gf_theme_notification notification[7];
-
- /* this member should be consider private, the plugin will fill it
- in when it loads the theme, so we can use multiple theme dirs */
- gchar *directory;
-} gf_theme;
-
-#endif
--- a/src/gf_types.h Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_types.h Wed Mar 10 00:59:18 2004 +0000
@@ -55,4 +55,31 @@
window_zoom_25
} gf_window_zoom;
+typedef enum _gf_item_position {
+ item_position_nw = 0,
+ item_position_n,
+ item_position_ne,
+ item_position_w,
+ item_position_c,
+ item_position_e,
+ item_position_sw,
+ item_position_s,
+ item_position_se
+} gf_item_position;
+
+typedef enum _gf_text_clipping {
+ text_clipping_truncate = 0,
+ text_clipping_elipse_start,
+ text_clipping_elipse_middle,
+ text_clipping_elipse_end
+} gf_text_clipping;
+
+typedef enum _gf_icon_size {
+ icon_size_tiny = 0,
+ icon_size_small,
+ icon_size_normal,
+ icon_size_large,
+ icon_size_huge
+} gf_icon_size;
+
#endif
--- a/src/gf_utils.c Thu Jan 15 15:25:19 2004 +0000
+++ b/src/gf_utils.c Wed Mar 10 00:59:18 2004 +0000
@@ -34,7 +34,6 @@
#include "gf_utils.h"
#include "gf_types.h"
-#include "gf_theme.h"
#include "gf_prefs.h"
/**********************************************************************/
@@ -234,6 +233,7 @@
text = pango_layout_get_text(lay);
new_text = g_strndup(text, strlen(text) - 1);
pango_layout_set_text(lay, new_text, -1);
+ g_free(new_text);
}
}
g_free(new_text);
@@ -249,6 +249,7 @@
text = pango_layout_get_text(lay);
new_text = g_strrndup(text, strlen(text) - 1);
pango_layout_set_text(lay, new_text, -1);
+ g_free(new_text);
}
}
text = pango_layout_get_text(lay);
@@ -276,10 +277,23 @@
right_text = g_strrndup(text, mid);
}
new_text = g_strdup_printf("%s%s", left_text, right_text);
-
+ g_free(left_text);
+ g_free(right_text);
+
pango_layout_set_text(lay, new_text, -1);
+ g_free(new_text);
}
}
+
+ mid = strlen(text) / 2;
+ if(is_even(strlen(text))) {
+ left_text = g_strndup(text, mid);
+ right_text = g_strrndup(text, mid - 1);
+ } else {
+ left_text = g_strndup(text, mid);
+ right_text = g_strrndup(text, mid);
+ }
+
new_text = g_strdup_printf("%s...%s", left_text, right_text);
g_free(left_text);
g_free(right_text);
@@ -298,6 +312,7 @@
text = pango_layout_get_text(lay);
new_text = g_strndup(text, strlen(text) - 1);
pango_layout_set_text(lay, new_text, -1);
+ g_free(new_text);
}
}
text = pango_layout_get_text(lay);