renamed labelcolors.[ch] to colorlabel.[ch]
authorPaul Mangan <paul@claws-mail.org>
Mon, 27 Aug 2001 10:59:22 +0000 (10:59 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 27 Aug 2001 10:59:22 +0000 (10:59 +0000)
src/colorlabel.c [moved from src/labelcolors.c with 78% similarity]
src/colorlabel.h [moved from src/labelcolors.h with 61% similarity]

similarity index 78%
rename from src/labelcolors.c
rename to src/colorlabel.c
index 18823f50003c9be2031b6e1cd97f5498b358748c..37639869fe8d69fded38bf40993ec4e8db991ec4 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include "defs.h"
-#include "intl.h"
 
 #include <glib.h>
 #include <gdk/gdkx.h>
@@ -37,8 +36,8 @@
 #include <gtk/gtkhbox.h>
 #include <gtk/gtkwindow.h>
 
-
-#include "labelcolors.h"
+#include "intl.h"
+#include "colorlabel.h"
 #include "gtkutils.h"
 #include "utils.h"
 
@@ -58,8 +57,8 @@ typedef enum LabelColorChangeFlags_ {
        LCCF_ALL   = LCCF_COLOR | LCCF_LABEL
 } LabelColorChangeFlags;
 
-/* XXX: if you add colors, make sure you also check the procmsg.h. color indices
- * are stored as 3 bits; that explains the max. of 7 colors */
+/* XXX: if you add colors, make sure you also check the procmsg.h.
+ * color indices are stored as 3 bits; that explains the max. of 7 colors */
 static struct 
 {
        LabelColorChangeFlags   changed; 
@@ -69,9 +68,7 @@ static struct
         * allocated and fffreed */
        gchar                   *label;
        GtkPixmap               *pixmap;
-}
-label_colors[] = 
-{
+} label_colors[] = {
        { LCCF_ALL, { 0, 0xffff, (0x99 << 8), 0x0 },            NULL, NULL },
        { LCCF_ALL, { 0, 0xffff, 0, 0 },                        NULL, NULL },
        { LCCF_ALL, { 0, 0xffff, (0x66 << 8), 0xffff },         NULL, NULL },
@@ -86,15 +83,15 @@ label_colors[] =
 #define G_RETURN_VAL_IF_INVALID_COLOR(color, val) \
        g_return_val_if_fail((color) >= 0 && (color) < LABEL_COLORS_ELEMS, (val))
 
-static void labelcolors_recreate        (gint);
-static void labelcolors_recreate_label  (gint);
+static void colorlabel_recreate        (gint);
+static void colorlabel_recreate_label  (gint);
 
-gint labelcolors_get_color_count(void)
+gint colorlabel_get_color_count(void)
 {
        return LABEL_COLORS_ELEMS;
 }
 
-GdkColor labelcolors_get_color(gint color_index)
+GdkColor colorlabel_get_color(gint color_index)
 {
        GdkColor invalid = { 0 };
 
@@ -103,21 +100,21 @@ GdkColor labelcolors_get_color(gint color_index)
        return label_colors[color_index].color;
 }
 
-gchar *labelcolors_get_color_text(gint color_index)
+gchar *colorlabel_get_color_text(gint color_index)
 {
        G_RETURN_VAL_IF_INVALID_COLOR(color_index, NULL);
 
-       labelcolors_recreate_label(color_index);
+       colorlabel_recreate_label(color_index);
        return label_colors[color_index].label;
 }
 
-GtkPixmap *labelcolors_create_color_pixmap(GdkColor color)
+GtkPixmap *colorlabel_create_color_pixmap(GdkColor color)
 {
-       const char *FMT = "+      c #%2.2X%2.2X%2.2X";
-       char buf[40];
-       
+       const gchar *FMT = "+      c #%2.2X%2.2X%2.2X";
+       gchar buf[40];
+
        /* black frame of 1 pixel */
-       char * dummy_xpm[] = {
+       gchar *dummy_xpm[] = {
                "16 16 3 1",
                "       c None",
                ".      c #000000",
@@ -149,97 +146,100 @@ GtkPixmap *labelcolors_create_color_pixmap(GdkColor color)
        dummy_xpm[3] = buf;                             
 
        /* XXX: passing NULL as GdkWindow* seems to be possible */
-       xpm = gdk_pixmap_create_from_xpm_d(GDK_ROOT_PARENT(), &xpmmask, NULL, (gchar **) &dummy_xpm);
+       xpm = gdk_pixmap_create_from_xpm_d
+               (GDK_ROOT_PARENT(), &xpmmask, NULL, (gchar **) &dummy_xpm);
        if (xpm == NULL)
                debug_print("*** NO XPM\n");
        pixmap = GTK_PIXMAP(gtk_pixmap_new(xpm, xpmmask)); 
 
-       
        g_return_val_if_fail(pixmap, NULL);
 
        gdk_pixmap_unref(xpm);
        gdk_bitmap_unref(xpmmask);
+
        return pixmap;
 }
 
 /* XXX: this function to check if menus with colors and labels should
  * be recreated */
-gboolean labelcolors_changed(void)
+gboolean colorlabel_changed(void)
 {
        gint n;
+
        for (n = 0; n < LABEL_COLORS_ELEMS; n++) {
                if (label_colors[n].changed) 
                        return TRUE;
        }
+
        return FALSE;
 }
 
-/* XXX: labelcolors_recreate_XXX are there to make sure everything
+/* XXX: colorlabel_recreate_XXX are there to make sure everything
  * is initialized ok, without having to call a global _xxx_init_
  * function */
-static void labelcolors_recreate_color(gint color)
+static void colorlabel_recreate_color(gint color)
 {
        GtkPixmap *pixmap;
-       
+
        if (!(label_colors[color].changed & LCCF_COLOR))
                return;
-       
-       pixmap = GTK_PIXMAP(labelcolors_create_color_pixmap(label_colors[color].color));
+
+       pixmap = GTK_PIXMAP(colorlabel_create_color_pixmap(label_colors[color].color));
        g_return_if_fail(pixmap);
-       
+
        if (label_colors[color].pixmap)
                gtk_widget_destroy(GTK_WIDGET(label_colors[color].pixmap));
-               
+
        label_colors[color].pixmap = pixmap;            
        label_colors[color].changed &= ~LCCF_COLOR;
 }
 
-static void labelcolors_recreate_label(gint color)
+static void colorlabel_recreate_label(gint color)
 {
        if (!label_colors[color].changed & LCCF_LABEL)
                return;
 
        if (label_colors[color].label == NULL) 
-               label_colors[color].label = g_strdup(labels[color]);
-       
+               label_colors[color].label = g_strdup(gettext(labels[color]));
+
        label_colors[color].changed &= ~LCCF_LABEL;
 }
 
 /* XXX: call this function everytime when you're doing important
  * stuff with the label_colors[] array */
-static void labelcolors_recreate(gint color)
+static void colorlabel_recreate(gint color)
 {
-       labelcolors_recreate_label(color);
-       labelcolors_recreate_color(color);
+       colorlabel_recreate_label(color);
+       colorlabel_recreate_color(color);
 }
 
-static void labelcolors_recreate_all(void)
+static void colorlabel_recreate_all(void)
 {
        gint n;
+
        for ( n = 0; n < LABEL_COLORS_ELEMS; n++) 
-               labelcolors_recreate(n);
+               colorlabel_recreate(n);
 }
 
-/* labelcolors_create_check_color_menu_item() - creates a color
+/* colorlabel_create_check_color_menu_item() - creates a color
  * menu item with a check box */
-GtkWidget *labelcolors_create_check_color_menu_item(gint color_index)
+GtkWidget *colorlabel_create_check_color_menu_item(gint color_index)
 {
        GtkWidget *label; 
        GtkWidget *hbox; 
        GtkWidget *align; 
-       GtkWidget *pixmap; 
        GtkWidget *item;
 
        G_RETURN_VAL_IF_INVALID_COLOR(color_index, NULL);
 
        item  = gtk_check_menu_item_new();
 
-       labelcolors_recreate(color_index);
+       colorlabel_recreate(color_index);
 
        /* XXX: gnome-core::panel::menu.c is a great example of
         * how to create pixmap menus */
        label = gtk_label_new(label_colors[color_index].label);
-       
+
        gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
        gtk_widget_show(label);
        hbox = gtk_hbox_new(FALSE, 0);
@@ -250,7 +250,8 @@ GtkWidget *labelcolors_create_check_color_menu_item(gint color_index)
        gtk_widget_show(align);
        gtk_container_set_border_width(GTK_CONTAINER(align), 1);
 
-       gtk_container_add(GTK_CONTAINER(align), GTK_WIDGET(label_colors[color_index].pixmap));
+       gtk_container_add(GTK_CONTAINER(align),
+                         GTK_WIDGET(label_colors[color_index].pixmap));
        gtk_widget_show(GTK_WIDGET(label_colors[color_index].pixmap));
        gtk_widget_set_usize(align, 16, 16);
 
@@ -260,19 +261,18 @@ GtkWidget *labelcolors_create_check_color_menu_item(gint color_index)
        return item;
 }
 
-/* labelcolors_create_color_menu() - creates a color menu without 
+/* colorlabel_create_color_menu() - creates a color menu without 
  * checkitems, probably for use in combo items */
-GtkWidget *labelcolors_create_color_menu(void)
+GtkWidget *colorlabel_create_color_menu(void)
 {
        GtkWidget *label; 
        GtkWidget *hbox; 
        GtkWidget *align; 
-       GtkWidget *pixmap; 
        GtkWidget *item;
        GtkWidget *menu;
        gint i;
 
-       labelcolors_recreate_all();
+       colorlabel_recreate_all();
 
        /* create the menu items. each item has its color code attached */
        menu = gtk_menu_new();
@@ -285,7 +285,7 @@ GtkWidget *labelcolors_create_color_menu(void)
        
        /* and the color items */
        for (i = 0; i < LABEL_COLORS_ELEMS; i++) {
-               GtkPixmap *pixmap = labelcolors_create_color_pixmap(label_colors[i].color);
+               GtkPixmap *pixmap = colorlabel_create_color_pixmap(label_colors[i].color);
 
                item  = gtk_menu_item_new();
                gtk_object_set_data(GTK_OBJECT(item), "color", GUINT_TO_POINTER(i + 1));
@@ -312,20 +312,22 @@ GtkWidget *labelcolors_create_color_menu(void)
                gtk_menu_append(GTK_MENU(menu), item);
                gtk_widget_show(item);
        }
-       
+
        gtk_widget_show(menu);
 
        return menu;
 }
 
-guint labelcolors_get_color_menu_active_item(GtkWidget *menu)
+guint colorlabel_get_color_menu_active_item(GtkWidget *menu)
 {
        GtkWidget *menuitem;
        guint      color;
-       
-       g_return_val_if_fail( gtk_object_get_data(GTK_OBJECT(menu), "label_color_menu"), 0);
+
+       g_return_val_if_fail
+               (gtk_object_get_data(GTK_OBJECT(menu), "label_color_menu"), 0);
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
-       color = GPOINTER_TO_UINT( gtk_object_get_data(GTK_OBJECT(menuitem), "color") );
+       color = GPOINTER_TO_UINT
+               (gtk_object_get_data(GTK_OBJECT(menuitem), "color"));
        return color;
 }
 
similarity index 61%
rename from src/labelcolors.h
rename to src/colorlabel.h
index 1891bb514c9f1b450506b70102f85274fd7d666e..437f3bab06794f7987585451de693fe391e4bece 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#if !defined(LABELCOLORS_H__)
-#define LABELCOLORS_H__
-
-gint labelcolors_get_color_count(void);
-
-GdkColor labelcolors_get_color(gint color_index);
-
-gchar *labelcolors_get_color_text(gint color_index);
-
-GtkPixmap *labelcolors_create_color_pixmap(GdkColor color);
-
-gboolean labelcolors_changed(void);
-
-GtkWidget *labelcolors_create_check_color_menu_item(gint color_index);
-
-GtkWidget *labelcolors_create_color_menu(void);
-
-guint labelcolors_get_color_menu_active_item(GtkWidget *menu);
-
-#endif /* LABELCOLORS_H__ */
+#if !defined(COLORLABEL_H__)
+#define COLORLABEL_H__
+
+#include <glib.h>
+
+gint colorlabel_get_color_count                        (void);
+GdkColor colorlabel_get_color                  (gint            color_index);
+gchar *colorlabel_get_color_text               (gint            color_index);
+GtkPixmap *colorlabel_create_color_pixmap      (GdkColor        color);
+gboolean colorlabel_changed                    (void);
+GtkWidget *colorlabel_create_check_color_menu_item
+                                               (gint            color_index);
+GtkWidget *colorlabel_create_color_menu                (void);
+guint colorlabel_get_color_menu_active_item    (GtkWidget      *menu);
+
+#endif /* COLORLABEL_H__ */