Back to index

lxpanel  0.5.5
Classes | Enumerations | Functions | Variables
misc.c File Reference
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "misc.h"
#include "panel.h"
#include "dbg.h"

Go to the source code of this file.

Classes

struct  ImgData
 Copyright (c) 2006 LxDE Developers, see the file AUTHORS for details. More...

Enumerations

enum  {
  I_UTF8_STRING, I_XROOTPMAP_ID, I_WM_STATE, I_WM_CLASS,
  I_WM_DELETE_WINDOW, I_WM_PROTOCOLS, I_NET_WORKAREA, I_NET_CLIENT_LIST,
  I_NET_CLIENT_LIST_STACKING, I_NET_NUMBER_OF_DESKTOPS, I_NET_CURRENT_DESKTOP, I_NET_DESKTOP_VIEWPORT,
  I_NET_DESKTOP_NAMES, I_NET_ACTIVE_WINDOW, I_NET_SHOWING_DESKTOP, I_NET_SUPPORTED,
  I_NET_WM_STATE, I_NET_WM_STATE_SKIP_TASKBAR, I_NET_WM_STATE_SKIP_PAGER, I_NET_WM_STATE_STICKY,
  I_NET_WM_STATE_HIDDEN, I_NET_WM_STATE_SHADED, I_NET_WM_WINDOW_TYPE, I_NET_WM_WINDOW_TYPE_DESKTOP,
  I_NET_WM_WINDOW_TYPE_DOCK, I_NET_WM_WINDOW_TYPE_TOOLBAR, I_NET_WM_WINDOW_TYPE_MENU, I_NET_WM_WINDOW_TYPE_UTILITY,
  I_NET_WM_WINDOW_TYPE_SPLASH, I_NET_WM_WINDOW_TYPE_DIALOG, I_NET_WM_WINDOW_TYPE_NORMAL, I_NET_WM_DESKTOP,
  I_NET_WM_PID, I_NET_WM_NAME, I_NET_WM_VISIBLE_NAME, I_NET_WM_STRUT,
  I_NET_WM_STRUT_PARTIAL, I_NET_WM_ICON, I_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR, I_NET_SYSTEM_TRAY_OPCODE,
  I_NET_SYSTEM_TRAY_MESSAGE_DATA, I_NET_SYSTEM_TRAY_ORIENTATION, I_MANAGER, I_LXPANEL_CMD,
  N_ATOMS
}

Functions

static void on_theme_changed (GtkIconTheme *theme, GtkWidget *img)
static void _gtk_image_set_from_file_scaled (GtkWidget *img, const gchar *file, gint width, gint height, gboolean keep_ratio)
int str2num (pair *p, gchar *str, int defval)
gchar * num2str (pair *p, int num, gchar *defval)
int buf_gets (char *buf, int len, char **fp)
int lxpanel_put_line (FILE *fp, const char *format,...)
int lxpanel_get_line (char **fp, line *s)
int get_line_as_is (char **fp, line *s)
void resolve_atoms ()
void Xclimsg (Window win, Atom type, long l0, long l1, long l2, long l3, long l4)
void Xclimsgwm (Window win, Atom type, Atom arg)
void * get_utf8_property (Window win, Atom atom)
char ** get_utf8_property_list (Window win, Atom atom, int *count)
void * get_xaproperty (Window win, Atom prop, Atom type, int *nitems)
static char * text_property_to_utf8 (const XTextProperty *prop)
char * get_textproperty (Window win, Atom atom)
int get_net_number_of_desktops ()
int get_net_current_desktop ()
int get_net_wm_desktop (Window win)
GPid get_net_wm_pid (Window win)
void get_net_wm_state (Window win, NetWMState *nws)
void get_net_wm_window_type (Window win, NetWMWindowType *nwwt)
int get_wm_state (Window win)
static void calculate_width (int scrw, int wtype, int allign, int margin, int *panw, int *x)
void calculate_position (Panel *np)
gchar * expand_tilda (gchar *file)
static void img_data_free (ImgData *data)
void fb_button_set_from_file (GtkWidget *btn, const char *img_file, gint width, gint height, gboolean keep_ratio)
GtkWidget * _gtk_image_new_from_file_scaled (const gchar *file, gint width, gint height, gboolean keep_ratio)
void get_button_spacing (GtkRequisition *req, GtkContainer *parent, gchar *name)
guint32 gcolor2rgb24 (GdkColor *color)
static gboolean fb_button_enter (GtkImage *widget, GdkEventCrossing *event)
static gboolean fb_button_leave (GtkImage *widget, GdkEventCrossing *event, gpointer user_data)
GtkWidget * fb_button_new_from_file (gchar *image_file, int width, int height, gulong highlight_color, gboolean keep_ratio)
GtkWidget * fb_button_new_from_file_with_label (gchar *image_file, int width, int height, gulong highlight_color, gboolean keep_ratio, Panel *panel, gchar *label)
char * translate_exec_to_cmd (const char *exec, const char *icon, const char *title, const char *fpath)
GtkWidget * recreate_box (GtkBox *oldbox, GtkOrientation orientation)
void show_error (GtkWindow *parent_win, const char *msg)
static GdkPixbuf * load_icon_file (const char *file_name, int height, int width)
static GdkPixbuf * load_icon_from_theme (GtkIconTheme *theme, const char *icon_name, int width, int height)
GdkPixbuf * lxpanel_load_icon (const char *name, int width, int height, gboolean use_fallback)
static char * translate_app_exec_to_command_line (const char *pexec, GList *file_list)
gboolean lxpanel_launch_app (const char *exec, GList *files, gboolean in_terminal)

Variables

static GQuark img_data_id = 0
Atom a_UTF8_STRING
Atom a_XROOTPMAP_ID
Atom a_WM_STATE
Atom a_WM_CLASS
Atom a_WM_DELETE_WINDOW
Atom a_WM_PROTOCOLS
Atom a_NET_WORKAREA
Atom a_NET_CLIENT_LIST
Atom a_NET_CLIENT_LIST_STACKING
Atom a_NET_NUMBER_OF_DESKTOPS
Atom a_NET_CURRENT_DESKTOP
Atom a_NET_DESKTOP_VIEWPORT
Atom a_NET_DESKTOP_NAMES
Atom a_NET_ACTIVE_WINDOW
Atom a_NET_CLOSE_WINDOW
Atom a_NET_SHOWING_DESKTOP
Atom a_NET_SUPPORTED
Atom a_NET_WM_STATE
Atom a_NET_WM_STATE_SKIP_TASKBAR
Atom a_NET_WM_STATE_SKIP_PAGER
Atom a_NET_WM_STATE_STICKY
Atom a_NET_WM_STATE_HIDDEN
Atom a_NET_WM_STATE_SHADED
Atom a_NET_WM_WINDOW_TYPE
Atom a_NET_WM_WINDOW_TYPE_DESKTOP
Atom a_NET_WM_WINDOW_TYPE_DOCK
Atom a_NET_WM_WINDOW_TYPE_TOOLBAR
Atom a_NET_WM_WINDOW_TYPE_MENU
Atom a_NET_WM_WINDOW_TYPE_UTILITY
Atom a_NET_WM_WINDOW_TYPE_SPLASH
Atom a_NET_WM_WINDOW_TYPE_DIALOG
Atom a_NET_WM_WINDOW_TYPE_NORMAL
Atom a_NET_WM_DESKTOP
Atom a_NET_WM_PID
Atom a_NET_WM_NAME
Atom a_NET_WM_VISIBLE_NAME
Atom a_NET_WM_STRUT
Atom a_NET_WM_STRUT_PARTIAL
Atom a_NET_WM_ICON
Atom a_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR
Atom a_NET_SYSTEM_TRAY_OPCODE
Atom a_NET_SYSTEM_TRAY_MESSAGE_DATA
Atom a_NET_SYSTEM_TRAY_ORIENTATION
Atom a_MANAGER
Atom a_LXPANEL_CMD
gboolean is_ewmh_supported
pair allign_pair []
pair edge_pair []
pair width_pair []
pair height_pair []
pair bool_pair []
pair pos_pair []

Class Documentation

struct ImgData

Copyright (c) 2006 LxDE Developers, see the file AUTHORS for details.

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Definition at line 37 of file misc.c.

Class Members
int dh
int dw
char * fname
gulong hicolor
GdkPixbuf * hilight
gboolean keep_ratio
GdkPixbuf * pixbuf
guint theme_changed_handler

Enumeration Type Documentation

anonymous enum
Enumerator:
I_UTF8_STRING 
I_XROOTPMAP_ID 
I_WM_STATE 
I_WM_CLASS 
I_WM_DELETE_WINDOW 
I_WM_PROTOCOLS 
I_NET_WORKAREA 
I_NET_CLIENT_LIST 
I_NET_CLIENT_LIST_STACKING 
I_NET_NUMBER_OF_DESKTOPS 
I_NET_CURRENT_DESKTOP 
I_NET_DESKTOP_VIEWPORT 
I_NET_DESKTOP_NAMES 
I_NET_ACTIVE_WINDOW 
I_NET_SHOWING_DESKTOP 
I_NET_SUPPORTED 
I_NET_WM_STATE 
I_NET_WM_STATE_SKIP_TASKBAR 
I_NET_WM_STATE_SKIP_PAGER 
I_NET_WM_STATE_STICKY 
I_NET_WM_STATE_HIDDEN 
I_NET_WM_STATE_SHADED 
I_NET_WM_WINDOW_TYPE 
I_NET_WM_WINDOW_TYPE_DESKTOP 
I_NET_WM_WINDOW_TYPE_DOCK 
I_NET_WM_WINDOW_TYPE_TOOLBAR 
I_NET_WM_WINDOW_TYPE_MENU 
I_NET_WM_WINDOW_TYPE_UTILITY 
I_NET_WM_WINDOW_TYPE_SPLASH 
I_NET_WM_WINDOW_TYPE_DIALOG 
I_NET_WM_WINDOW_TYPE_NORMAL 
I_NET_WM_DESKTOP 
I_NET_WM_PID 
I_NET_WM_NAME 
I_NET_WM_VISIBLE_NAME 
I_NET_WM_STRUT 
I_NET_WM_STRUT_PARTIAL 
I_NET_WM_ICON 
I_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR 
I_NET_SYSTEM_TRAY_OPCODE 
I_NET_SYSTEM_TRAY_MESSAGE_DATA 
I_NET_SYSTEM_TRAY_ORIENTATION 
I_MANAGER 
I_LXPANEL_CMD 
N_ATOMS 

Definition at line 109 of file misc.c.


Function Documentation

GtkWidget* _gtk_image_new_from_file_scaled ( const gchar *  file,
gint  width,
gint  height,
gboolean  keep_ratio 
)

Definition at line 1032 of file misc.c.

{
    GtkWidget * img = gtk_image_new();
    ImgData * data = g_new0(ImgData, 1);
    if (img_data_id == 0)
        img_data_id = g_quark_from_static_string("ImgData");
    g_object_set_qdata_full(G_OBJECT(img), img_data_id, data, (GDestroyNotify) img_data_free);
    _gtk_image_set_from_file_scaled(img, file, width, height, keep_ratio);
    return img;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void _gtk_image_set_from_file_scaled ( GtkWidget *  img,
const gchar *  file,
gint  width,
gint  height,
gboolean  keep_ratio 
) [static]

Definition at line 961 of file misc.c.

{
    ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(img), img_data_id);
    data->dw = width;
    data->dh = height;
    data->keep_ratio = keep_ratio;

    if (data->pixbuf != NULL)
    {
        g_object_unref(data->pixbuf);
        data->pixbuf = NULL;
    }

    /* if there is a cached hilighted version of this pixbuf, free it */
    if (data->hilight != NULL)
    {
        g_object_unref(data->hilight);
        data->hilight = NULL;
    }

    /* if they are the same string, eliminate unnecessary copy. */
    gboolean themed = FALSE;
    if (file != NULL)
    {
        if (data->fname != file)
        {
            g_free(data->fname);
            data->fname = g_strdup(file);
        }

        if (g_file_test(file, G_FILE_TEST_EXISTS))
        {
            GdkPixbuf * pb_scaled = gdk_pixbuf_new_from_file_at_scale(file, width, height, keep_ratio, NULL);
            if (pb_scaled != NULL)
                data->pixbuf = pb_scaled;
        }
        else
        {
            data->pixbuf = lxpanel_load_icon(file, width, height, keep_ratio);
            themed = TRUE;
        }
    }

    if (data->pixbuf != NULL)
    {
        /* Set the pixbuf into the image widget. */
        gtk_image_set_from_pixbuf((GtkImage *)img, data->pixbuf);
        if (themed)
        {
            /* This image is loaded from icon theme.  Update the image if the icon theme is changed. */
            if (data->theme_changed_handler == 0)
                data->theme_changed_handler = g_signal_connect(gtk_icon_theme_get_default(), "changed", G_CALLBACK(on_theme_changed), img);
        }
        else
        {
            /* This is not loaded from icon theme.  Disconnect the signal handler. */
            if (data->theme_changed_handler != 0)
            {
                g_signal_handler_disconnect(gtk_icon_theme_get_default(), data->theme_changed_handler);
                data->theme_changed_handler = 0;
            }
        }
    }
    else
    {
        /* No pixbuf available.  Set the "missing image" icon. */
        gtk_image_set_from_stock(GTK_IMAGE(img), GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON);
    }
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int buf_gets ( char *  buf,
int  len,
char **  fp 
)

Definition at line 228 of file misc.c.

{
    char* p;
    int i = 0;
    if( !fp || !(p = *fp) || !**fp )
    {
        buf[0] = '\0';
        return 0;
    }

    do
    {
        if( G_LIKELY( i < len ) )
        {
            buf[i] = *p;
            ++i;
        }
        if( G_UNLIKELY(*p == '\n') )
        {
            ++p;
            break;
        }
    }while( *(++p) );
    buf[i] = '\0';
    *fp = p;
    return i;
}

Here is the caller graph for this function:

void calculate_position ( Panel np)

Definition at line 855 of file misc.c.

{
    int sswidth, ssheight, minx, miny;

    ENTER;
    /* FIXME: Why this doesn't work? */
    if (0)  {
//        if (np->curdesk < np->wa_len/4) {
        minx = np->workarea[np->curdesk*4 + 0];
        miny = np->workarea[np->curdesk*4 + 1];
        sswidth  = np->workarea[np->curdesk*4 + 2];
        ssheight = np->workarea[np->curdesk*4 + 3];
    } else {
        minx = miny = 0;
        sswidth  = gdk_screen_get_width( gtk_widget_get_screen(np->topgwin) );
        ssheight = gdk_screen_get_height( gtk_widget_get_screen(np->topgwin) );
    }

    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,
              &np->aw, &np->ax);
        np->ah = ((( ! np->autohide) || (np->visible)) ? np->height : np->height_when_hidden);
        np->ay = miny + ((np->edge == EDGE_TOP) ? 0 : (ssheight - np->ah));

    } else {
        np->ah = np->width;
        np->ay = miny;
        calculate_width(ssheight, np->widthtype, np->allign, np->margin,
              &np->ah, &np->ay);
        np->aw = ((( ! np->autohide) || (np->visible)) ? np->height : np->height_when_hidden);
        np->ax = minx + ((np->edge == EDGE_LEFT) ? 0 : (sswidth - np->aw));
    }
    //g_debug("%s - x=%d y=%d w=%d h=%d\n", __FUNCTION__, np->ax, np->ay, np->aw, np->ah);
    RET();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void calculate_width ( int  scrw,
int  wtype,
int  allign,
int  margin,
int *  panw,
int *  x 
) [static]

Definition at line 818 of file misc.c.

{
    ENTER;
    DBG("scrw=%d\n", scrw);
    DBG("IN panw=%d, margin=%d\n", *panw, margin);
    //scrw -= 2;
    if (wtype == WIDTH_PERCENT) {
        /* sanity check */
        if (*panw > 100)
            *panw = 100;
        else if (*panw < 0)
            *panw = 1;
        *panw = ((gfloat) scrw * (gfloat) *panw) / 100.0;
    }
    if (allign != ALLIGN_CENTER) {
        if (margin > scrw) {
            ERR( "margin is bigger then edge size %d > %d. Ignoring margin\n",
                  margin, scrw);
            margin = 0;
        }
       *panw = MIN(scrw - margin, *panw);
    }
    DBG("OUT panw=%d\n", *panw);
    if (allign == ALLIGN_LEFT)
        *x += margin;
    else if (allign == ALLIGN_RIGHT) {
        *x += scrw - *panw - margin;
        if (*x < 0)
            *x = 0;
    } else if (allign == ALLIGN_CENTER)
        *x += (scrw - *panw) / 2;
    RET();
}

Here is the caller graph for this function:

gchar* expand_tilda ( gchar *  file)

Definition at line 894 of file misc.c.

{
    ENTER;
    RET((file[0] == '~') ?
        g_strdup_printf("%s%s", getenv("HOME"), file+1)
        : g_strdup(file));

}

Here is the caller graph for this function:

static gboolean fb_button_enter ( GtkImage *  widget,
GdkEventCrossing *  event 
) [static]

Definition at line 1091 of file misc.c.

{
    if (gtk_image_get_storage_type(widget) == GTK_IMAGE_PIXBUF)
    {
        ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(widget), img_data_id);
        if (data != NULL)
        {
            if (data->hilight == NULL)
            {
                GdkPixbuf * dark = data->pixbuf;
                int height = gdk_pixbuf_get_height(dark);
                int rowstride = gdk_pixbuf_get_rowstride(dark);
                gulong hicolor = data->hicolor;

                GdkPixbuf * light = gdk_pixbuf_add_alpha(dark, FALSE, 0, 0, 0);
                if (light != NULL)
                {
                    guchar extra[3];
                    int i;
                    for (i = 2; i >= 0; i--, hicolor >>= 8)
                        extra[i] = hicolor & 0xFF;

                    guchar * src = gdk_pixbuf_get_pixels(light);
                    guchar * up;
                    for (up = src + height * rowstride; src < up; src += 4)
                    {
                        if (src[3] != 0)
                        {
                            for (i = 0; i < 3; i++)
                            {
                            int value = src[i] + extra[i];
                            if (value > 255) value = 255;
                            src[i] = value;
                            }
                        }
                    }
                data->hilight = light;
                }
            }

        if (data->hilight != NULL)
            gtk_image_set_from_pixbuf(widget, data->hilight);
        }
    }
    return TRUE;
}

Here is the caller graph for this function:

static gboolean fb_button_leave ( GtkImage *  widget,
GdkEventCrossing *  event,
gpointer  user_data 
) [static]

Definition at line 1139 of file misc.c.

{
    if (gtk_image_get_storage_type(widget) == GTK_IMAGE_PIXBUF)
    {
        ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(widget), img_data_id);
        if ((data != NULL) && (data->pixbuf != NULL))
            gtk_image_set_from_pixbuf(widget, data->pixbuf);
    }
    return TRUE;
}

Here is the caller graph for this function:

GtkWidget* fb_button_new_from_file ( gchar *  image_file,
int  width,
int  height,
gulong  highlight_color,
gboolean  keep_ratio 
)

Definition at line 1151 of file misc.c.

{
    return fb_button_new_from_file_with_label(image_file, width, height, highlight_color, keep_ratio, NULL, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GtkWidget* fb_button_new_from_file_with_label ( gchar *  image_file,
int  width,
int  height,
gulong  highlight_color,
gboolean  keep_ratio,
Panel panel,
gchar *  label 
)

Definition at line 1157 of file misc.c.

{
    GtkWidget * event_box = gtk_event_box_new();
    gtk_container_set_border_width(GTK_CONTAINER(event_box), 0);
    GTK_WIDGET_UNSET_FLAGS(event_box, GTK_CAN_FOCUS);

    GtkWidget * image = _gtk_image_new_from_file_scaled(image_file, width, height, keep_ratio);
    gtk_misc_set_padding(GTK_MISC(image), 0, 0);
    gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
    if (highlight_color != 0)
    {
        ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(image), img_data_id);
        data->hicolor = highlight_color;

        gtk_widget_add_events(event_box, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
        g_signal_connect_swapped(G_OBJECT(event_box), "enter-notify-event", G_CALLBACK(fb_button_enter), image);
        g_signal_connect_swapped(G_OBJECT(event_box), "leave-notify-event", G_CALLBACK(fb_button_leave), image);
    }

    if (label == NULL)
        gtk_container_add(GTK_CONTAINER(event_box), image);
    else
    {
        GtkWidget * inner = gtk_hbox_new(FALSE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(inner), 0);
        GTK_WIDGET_UNSET_FLAGS (inner, GTK_CAN_FOCUS);
        gtk_container_add(GTK_CONTAINER(event_box), inner);

        gtk_box_pack_start(GTK_BOX(inner), image, FALSE, FALSE, 0);

        GtkWidget * lbl = gtk_label_new("");
        panel_draw_label_text(panel, lbl, label, FALSE, TRUE);
        gtk_misc_set_padding(GTK_MISC(lbl), 2, 0);
        gtk_box_pack_end(GTK_BOX(inner), lbl, FALSE, FALSE, 0);
    }

    gtk_widget_show_all(event_box);
    return event_box;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fb_button_set_from_file ( GtkWidget *  btn,
const char *  img_file,
gint  width,
gint  height,
gboolean  keep_ratio 
)

Definition at line 935 of file misc.c.

{
    /* Locate the image within the button. */
    GtkWidget * child = gtk_bin_get_child(GTK_BIN(btn));
    GtkWidget * img = NULL;
    if (GTK_IS_IMAGE(child))
        img = child;
    else if (GTK_IS_BOX(child))
    {
        GList * children = gtk_container_get_children(GTK_CONTAINER(child));
        img = GTK_WIDGET(GTK_IMAGE(children->data));
        g_list_free(children);
    }

    if (img != NULL)
    {
        ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(img), img_data_id);
        g_free(data->fname);
        data->fname = g_strdup(img_file);
        data->dw = width;
        data->dh = height;
        data->keep_ratio = keep_ratio;
        _gtk_image_set_from_file_scaled(img, data->fname, data->dw, data->dh, data->keep_ratio);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

guint32 gcolor2rgb24 ( GdkColor *  color)

Definition at line 1069 of file misc.c.

{
    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);

    i = (color->red * 0xFF / 0xFFFF) & 0xFF;
    i <<= 8;
    i |= (color->green * 0xFF / 0xFFFF) & 0xFF;
    i <<= 8;
    i |= (color->blue * 0xFF / 0xFFFF) & 0xFF;
    DBG("i=%x\n", i);
    RET(i);
}

Here is the caller graph for this function:

void get_button_spacing ( GtkRequisition *  req,
GtkContainer *  parent,
gchar *  name 
)

Definition at line 1045 of file misc.c.

{
    GtkWidget *b;
    //gint focus_width;
    //gint focus_pad;

    ENTER;
    b = gtk_button_new();
    gtk_widget_set_name(GTK_WIDGET(b), name);
    GTK_WIDGET_UNSET_FLAGS (b, GTK_CAN_FOCUS);
    GTK_WIDGET_UNSET_FLAGS (b, GTK_CAN_DEFAULT);
    gtk_container_set_border_width (GTK_CONTAINER (b), 0);

    if (parent)
        gtk_container_add(parent, b);

    gtk_widget_show(b);
    gtk_widget_size_request(b, req);

    gtk_widget_destroy(b);
    RET();
}
int get_line_as_is ( char **  fp,
line s 
)

Definition at line 319 of file misc.c.

{
    gchar *tmp, *tmp2;

    ENTER;
    if (!fp) {
        s->type = LINE_NONE;
        RET(s->type);
    }
    s->type = LINE_NONE;
    while (buf_gets(s->str, s->len, fp)) {
        g_strstrip(s->str);
        if (s->str[0] == '#' || s->str[0] == 0)
        continue;
        DBG( ">> %s\n", s->str);
        if (!g_ascii_strcasecmp(s->str, "}")) {
            s->type = LINE_BLOCK_END;
            DBG( "        : line_block_end\n");
            break;
        }
        for (tmp = s->str; isalnum(*tmp); tmp++);
        for (tmp2 = tmp; isspace(*tmp2); tmp2++);
        if (*tmp2 == '=') {
            s->type = LINE_VAR;
        } else if  (*tmp2 == '{') {
            s->type = LINE_BLOCK_START;
        } else {
            DBG( "        : ? <%c>\n", *tmp2);
        }
        break;
    }
    RET(s->type);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 672 of file misc.c.

{
    int desk;
    guint32 *data;

    ENTER;
    data = get_xaproperty (GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, XA_CARDINAL, 0);
    if (!data)
        RET(0);

    desk = *data;
    XFree (data);
    RET(desk);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 654 of file misc.c.

{
    int desknum;
    guint32 *data;

    ENTER;
    data = get_xaproperty (GDK_ROOT_WINDOW(), a_NET_NUMBER_OF_DESKTOPS,
          XA_CARDINAL, 0);
    if (!data)
        RET(0);

    desknum = *data;
    XFree (data);
    RET(desknum);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int get_net_wm_desktop ( Window  win)

Definition at line 688 of file misc.c.

{
    int desk = 0;
    guint32 *data;

    ENTER;
    data = get_xaproperty (win, a_NET_WM_DESKTOP, XA_CARDINAL, 0);
    if (data) {
        desk = *data;
        XFree (data);
    }
    RET(desk);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GPid get_net_wm_pid ( Window  win)

Definition at line 703 of file misc.c.

{
    GPid pid = 0;
    guint32 *data;

    ENTER;
    data = get_xaproperty (win, a_NET_WM_PID, XA_CARDINAL, 0);
    if (data) {
        pid = *data;
        XFree (data);
    }
    RET(pid);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void get_net_wm_state ( Window  win,
NetWMState nws 
)

Definition at line 718 of file misc.c.

{
    Atom *state;
    int num3;


    ENTER;
    bzero(nws, sizeof(nws));
    if (!(state = get_xaproperty(win, a_NET_WM_STATE, XA_ATOM, &num3)))
        RET();

    DBG( "%x: netwm state = { ", (unsigned int)win);
    while (--num3 >= 0) {
        if (state[num3] == a_NET_WM_STATE_SKIP_PAGER) {
            DBG("NET_WM_STATE_SKIP_PAGER ");
            nws->skip_pager = 1;
        } else if (state[num3] == a_NET_WM_STATE_SKIP_TASKBAR) {
            DBG( "NET_WM_STATE_SKIP_TASKBAR ");
        nws->skip_taskbar = 1;
    } else if (state[num3] == a_NET_WM_STATE_STICKY) {
            DBG( "NET_WM_STATE_STICKY ");
        nws->sticky = 1;
        } else if (state[num3] == a_NET_WM_STATE_HIDDEN) {
            DBG( "NET_WM_STATE_HIDDEN ");
            nws->hidden = 1;
    } else if (state[num3] == a_NET_WM_STATE_SHADED) {
            DBG( "NET_WM_STATE_SHADED ");
            nws->shaded = 1;
    } else {
        DBG( "... ");
    }
    }
    XFree(state);
    DBG( "}\n");
    RET();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void get_net_wm_window_type ( Window  win,
NetWMWindowType nwwt 
)

Definition at line 756 of file misc.c.

{
    Atom *state;
    int num3;


    ENTER;
    bzero(nwwt, sizeof(nwwt));
    if (!(state = get_xaproperty(win, a_NET_WM_WINDOW_TYPE, XA_ATOM, &num3)))
        RET();

    DBG( "%x: netwm state = { ", (unsigned int)win);
    while (--num3 >= 0) {
        if (state[num3] == a_NET_WM_WINDOW_TYPE_DESKTOP) {
            DBG("NET_WM_WINDOW_TYPE_DESKTOP ");
            nwwt->desktop = 1;
        } else if (state[num3] == a_NET_WM_WINDOW_TYPE_DOCK) {
            DBG( "NET_WM_WINDOW_TYPE_DOCK ");
        nwwt->dock = 1;
    } else if (state[num3] == a_NET_WM_WINDOW_TYPE_TOOLBAR) {
            DBG( "NET_WM_WINDOW_TYPE_TOOLBAR ");
        nwwt->toolbar = 1;
        } else if (state[num3] == a_NET_WM_WINDOW_TYPE_MENU) {
            DBG( "NET_WM_WINDOW_TYPE_MENU ");
            nwwt->menu = 1;
    } else if (state[num3] == a_NET_WM_WINDOW_TYPE_UTILITY) {
            DBG( "NET_WM_WINDOW_TYPE_UTILITY ");
            nwwt->utility = 1;
    } else if (state[num3] == a_NET_WM_WINDOW_TYPE_SPLASH) {
            DBG( "NET_WM_WINDOW_TYPE_SPLASH ");
            nwwt->splash = 1;
    } else if (state[num3] == a_NET_WM_WINDOW_TYPE_DIALOG) {
            DBG( "NET_WM_WINDOW_TYPE_DIALOG ");
            nwwt->dialog = 1;
    } else if (state[num3] == a_NET_WM_WINDOW_TYPE_NORMAL) {
            DBG( "NET_WM_WINDOW_TYPE_NORMAL ");
            nwwt->normal = 1;
    } else {
        DBG( "... ");
    }
    }
    XFree(state);
    DBG( "}\n");
    RET();
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* get_textproperty ( Window  win,
Atom  atom 
)

Definition at line 631 of file misc.c.

{
    XTextProperty text_prop;
    char *retval;

    ENTER;
    if (XGetTextProperty(GDK_DISPLAY(), win, &text_prop, atom)) {
        DBG("format=%d enc=%d nitems=%d value=%s   \n",
              text_prop.format,
              text_prop.encoding,
              text_prop.nitems,
              text_prop.value);
        retval = text_property_to_utf8 (&text_prop);
        if (text_prop.nitems > 0)
            XFree (text_prop.value);
        RET(retval);

    }
    RET(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* get_utf8_property ( Window  win,
Atom  atom 
)

Definition at line 505 of file misc.c.

{
    Atom type;
    int format;
    gulong nitems;
    gulong bytes_after;
    gchar *val, *retval;
    int result;
    guchar *tmp = NULL;

    type = None;
    retval = NULL;
    result = XGetWindowProperty (GDK_DISPLAY(), win, atom, 0, G_MAXLONG, False,
          a_UTF8_STRING, &type, &format, &nitems,
          &bytes_after, &tmp);
    if (result != Success || type == None)
        return NULL;
    val = (gchar *) tmp;
    if (val) {
        if (type == a_UTF8_STRING && format == 8 && nitems != 0)
            retval = g_strndup (val, nitems);
        XFree (val);
    }
    return retval;

}

Here is the caller graph for this function:

char** get_utf8_property_list ( Window  win,
Atom  atom,
int *  count 
)

Definition at line 533 of file misc.c.

{
    Atom type;
    int format, i;
    gulong nitems;
    gulong bytes_after;
    gchar *s, **retval = NULL;
    int result;
    guchar *tmp = NULL;

    *count = 0;
    result = XGetWindowProperty(GDK_DISPLAY(), win, atom, 0, G_MAXLONG, False,
          a_UTF8_STRING, &type, &format, &nitems,
          &bytes_after, &tmp);
    if (result != Success || type != a_UTF8_STRING || tmp == NULL)
        return NULL;

    if (nitems) {
        gchar *val = (gchar *) tmp;
        DBG("res=%d(%d) nitems=%d val=%s\n", result, Success, nitems, val);
        for (i = 0; i < nitems; i++) {
            if (!val[i])
                (*count)++;
        }
        retval = g_new0 (char*, *count + 2);
        for (i = 0, s = val; i < *count; i++, s = s +  strlen (s) + 1) {
            retval[i] = g_strdup(s);
        }
        if (val[nitems-1]) {
            result = nitems - (s - val);
            DBG("val does not ends by 0, moving last %d bytes\n", result);
            g_memmove(s - 1, s, result);
            val[nitems-1] = 0;
            DBG("s=%s\n", s -1);
            retval[i] = g_strdup(s - 1);
            (*count)++;
        }
    }
    XFree (tmp);

    return retval;

}

Here is the caller graph for this function:

int get_wm_state ( Window  win)

Definition at line 803 of file misc.c.

{
    unsigned long *data;
    int ret = 0;

    ENTER;
    data = get_xaproperty (win, a_WM_STATE, a_WM_STATE, 0);
    if (data) {
        ret = data[0];
        XFree (data);
    }
    RET(ret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* get_xaproperty ( Window  win,
Atom  prop,
Atom  type,
int *  nitems 
)

Definition at line 578 of file misc.c.

{
    Atom type_ret;
    int format_ret;
    unsigned long items_ret;
    unsigned long after_ret;
    unsigned char *prop_data;

    ENTER;
    prop_data = NULL;
    if (XGetWindowProperty (GDK_DISPLAY(), win, prop, 0, 0x7fffffff, False,
              type, &type_ret, &format_ret, &items_ret,
              &after_ret, &prop_data) != Success)
    {
        if( G_UNLIKELY(prop_data) )
            XFree( prop_data );
        if( nitems )
            *nitems = 0;
        RET(NULL);
    }
    if (nitems)
        *nitems = items_ret;
    RET(prop_data);
}

Here is the caller graph for this function:

static void img_data_free ( ImgData data) [static]

Definition at line 916 of file misc.c.

{
    g_free(data->fname);
    if (data->theme_changed_handler != 0)
        g_signal_handler_disconnect(gtk_icon_theme_get_default(), data->theme_changed_handler);
    if (data->pixbuf != NULL)
        g_object_unref(data->pixbuf);
    if (data->hilight != NULL)
        g_object_unref(data->hilight);
    g_free(data);
}

Here is the caller graph for this function:

static GdkPixbuf* load_icon_file ( const char *  file_name,
int  height,
int  width 
) [static]

Definition at line 1298 of file misc.c.

{
    GdkPixbuf * icon = NULL;
    const gchar ** dirs = (const gchar **) g_get_system_data_dirs();
    const gchar ** dir;
    for (dir = dirs; ((*dir != NULL) && (icon == NULL)); dir++)
    {
        char * file_path = g_build_filename(*dir, "pixmaps", file_name, NULL);
        icon = gdk_pixbuf_new_from_file_at_scale(file_path, height, width, TRUE, NULL);
        g_free(file_path);
    }
    return icon;
}

Here is the caller graph for this function:

static GdkPixbuf* load_icon_from_theme ( GtkIconTheme *  theme,
const char *  icon_name,
int  width,
int  height 
) [static]

Definition at line 1313 of file misc.c.

{
    GdkPixbuf * icon = NULL;

    /* Look up the icon in the current theme. */
    GtkIconInfo * icon_info = gtk_icon_theme_lookup_icon(theme, icon_name, height, GTK_ICON_LOOKUP_USE_BUILTIN);
    if (icon_info != NULL)
    {
        /* If that succeeded, get the filename of the icon.
         * If that succeeds, load the icon from the specified file.
         * Otherwise, try to get the builtin icon. */
        const char * file = gtk_icon_info_get_filename(icon_info);
        if (file != NULL)
            icon = gdk_pixbuf_new_from_file(file, NULL);
        else
        {
            icon = gtk_icon_info_get_builtin_pixbuf(icon_info);
            g_object_ref(icon);
        }
        gtk_icon_info_free(icon_info);

        /* If the icon is not sized properly, take a trip through the scaler.
         * The lookup above takes the desired size, so we get the closest result possible. */
        if (icon != NULL)
        {
            if ((height != gdk_pixbuf_get_height(icon)) || (width != gdk_pixbuf_get_width(icon)))
            {
                /* Handle case of unspecified width; gdk_pixbuf_scale_simple does not. */
                if (width < 0)
                {
                    int pixbuf_width = gdk_pixbuf_get_width(icon);
                    int pixbuf_height = gdk_pixbuf_get_height(icon);
                    width = height * pixbuf_width / pixbuf_height;
                }
                GdkPixbuf * scaled = gdk_pixbuf_scale_simple(icon, width, height, GDK_INTERP_BILINEAR);
                g_object_unref(icon);
                icon = scaled;
            }
        }
    }
    return icon;
}

Here is the caller graph for this function:

int lxpanel_get_line ( char **  fp,
line s 
)

Definition at line 280 of file misc.c.

{
    gchar *tmp, *tmp2;

    s->type = LINE_NONE;
    if (!fp)
        RET(s->type);
    while (buf_gets(s->str, s->len, fp)) {

        g_strstrip(s->str);

        if (s->str[0] == '#' || s->str[0] == 0) {
            continue;
        }
        if (!g_ascii_strcasecmp(s->str, "}")) {
            s->type = LINE_BLOCK_END;
            break;
        }

        s->t[0] = s->str;
        for (tmp = s->str; isalnum(*tmp); tmp++);
        for (tmp2 = tmp; isspace(*tmp2); tmp2++);
        if (*tmp2 == '=') {
            for (++tmp2; isspace(*tmp2); tmp2++);
            s->t[1] = tmp2;
            *tmp = 0;
            s->type = LINE_VAR;
        } else if  (*tmp2 == '{') {
            *tmp = 0;
            s->type = LINE_BLOCK_START;
        } else {
            ERR( "parser: unknown token: '%c'\n", *tmp2);
        }
        break;
    }
    return s->type;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean lxpanel_launch_app ( const char *  exec,
GList *  files,
gboolean  in_terminal 
)

Definition at line 1552 of file misc.c.

{
    GError *error = NULL;
    char* cmd;
    if( ! exec )
        return FALSE;
    cmd = translate_app_exec_to_command_line(exec, files);
    if( in_terminal )
    {
        char* term_cmd;
        const char* term = lxpanel_get_terminal();
        if( strstr(term, "%s") )
            term_cmd = g_strdup_printf(term, cmd);
        else
            term_cmd = g_strconcat( term, " -e ", cmd, NULL );
        if( cmd != exec )
            g_free(cmd);
        cmd = term_cmd;
    }
    if (! g_spawn_command_line_async(cmd, &error) ) {
        ERR("can't spawn %s\nError is %s\n", cmd, error->message);
        g_error_free (error);
    }
    g_free(cmd);

    return (error == NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GdkPixbuf* lxpanel_load_icon ( const char *  name,
int  width,
int  height,
gboolean  use_fallback 
)

Definition at line 1356 of file misc.c.

{
    GdkPixbuf * icon = NULL;

    if (name != NULL)
    {
        if (g_path_is_absolute(name))
        {
            /* Absolute path. */
            icon = gdk_pixbuf_new_from_file_at_scale(name, width, height, TRUE, NULL);
        }
        else
        {
            /* Relative path. */
            GtkIconTheme * theme = gtk_icon_theme_get_default();
            char * suffix = strrchr(name, '.');
            if ((suffix != NULL)
            && ((g_strcasecmp(&suffix[1], "png") == 0)
              || (g_strcasecmp(&suffix[1], "svg") == 0)
              || (g_strcasecmp(&suffix[1], "xpm") == 0)))
            {
                /* The file extension indicates it could be in the system pixmap directories. */
                icon = load_icon_file(name, width, height);
                if (icon == NULL)
                {
                    /* Not found.
                     * Let's remove the suffix, and see if this name can match an icon in the current icon theme. */
                    char * icon_name = g_strndup(name, suffix - name);
                    icon = load_icon_from_theme(theme, icon_name, width, height);
                    g_free(icon_name);
                }
            }
            else
            {
                 /* No file extension.  It could be an icon name in the icon theme. */
                 icon = load_icon_from_theme(theme, name, width, height);
            }
        }
    }

    /* Fall back to generic icons. */
    if ((icon == NULL) && (use_fallback))
    {
        GtkIconTheme * theme = gtk_icon_theme_get_default();
        icon = load_icon_from_theme(theme, "application-x-executable", width, height);
        if (icon == NULL)
            icon = load_icon_from_theme(theme, "gnome-mime-application-x-executable", width, height);
    }
    return icon;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int lxpanel_put_line ( FILE *  fp,
const char *  format,
  ... 
)

Definition at line 257 of file misc.c.

{
    static int indent = 0;
    int i, ret;
    va_list args;

    if( strchr(format, '}') )
        --indent;

    for( i = 0; i < indent; ++i )
        fputs( "    ", fp );

    va_start (args, format);
    ret = vfprintf (fp, format, args);
    va_end (args);

    if( strchr(format, '{') )
        ++indent;
    fputc( '\n', fp );  /* add line break */
    return (ret + 1);
}

Here is the caller graph for this function:

gchar* num2str ( pair p,
int  num,
gchar *  defval 
)

Definition at line 218 of file misc.c.

{
    ENTER;
    for (;p && p->str; p++) {
        if (num == p->num)
            RET(p->str);
    }
    RET(defval);
}

Here is the caller graph for this function:

static void on_theme_changed ( GtkIconTheme *  theme,
GtkWidget *  img 
) [static]

Definition at line 929 of file misc.c.

{
    ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(img), img_data_id);
    _gtk_image_set_from_file_scaled(img, data->fname, data->dw, data->dh, data->keep_ratio);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GtkWidget* recreate_box ( GtkBox *  oldbox,
GtkOrientation  orientation 
)

Definition at line 1247 of file misc.c.

{
    GtkBox* newbox;
    GList *child, *children;
    GtkWidget* (*my_box_new) (gboolean homogeneous, gint spacing);

    if( GTK_IS_HBOX(oldbox) ) {
        if( orientation == GTK_ORIENTATION_HORIZONTAL )
            return GTK_WIDGET(oldbox);
    }
    else {
        if( orientation == GTK_ORIENTATION_VERTICAL )
            return GTK_WIDGET(oldbox);
    }
    my_box_new = (orientation == GTK_ORIENTATION_HORIZONTAL ? gtk_hbox_new : gtk_vbox_new);

    newbox = GTK_BOX(my_box_new( gtk_box_get_homogeneous(oldbox),
                                 gtk_box_get_spacing(oldbox) ));
    gtk_container_set_border_width (GTK_CONTAINER (newbox),
                                    gtk_container_get_border_width(GTK_CONTAINER(oldbox)) );
    children = gtk_container_get_children( GTK_CONTAINER (oldbox) );
    for( child = children; child; child = child->next ) {
        gboolean expand, fill;
        guint padding;
        GtkWidget* w = GTK_WIDGET(child->data);
        gtk_box_query_child_packing( oldbox, w,
                                     &expand, &fill, &padding, NULL );
        /* g_debug( "repack %s, expand=%d, fill=%d", gtk_widget_get_name(w), expand, fill ); */
        g_object_ref( w );
        gtk_container_remove( GTK_CONTAINER (oldbox), w );
        gtk_box_pack_start( newbox, w, expand, fill, padding );
        g_object_unref( w );
    }
    g_list_free( children );
    gtk_widget_show_all( GTK_WIDGET(newbox) );
    gtk_widget_destroy( GTK_WIDGET(oldbox) );
    return GTK_WIDGET(newbox);
}

Here is the caller graph for this function:

void resolve_atoms ( )

Definition at line 354 of file misc.c.

{
    static const char* atom_names[ N_ATOMS ];

    atom_names[ I_UTF8_STRING ] = "UTF8_STRING";
    atom_names[ I_XROOTPMAP_ID ] = "_XROOTPMAP_ID";
    atom_names[ I_WM_STATE ] = "WM_STATE";
    atom_names[ I_WM_CLASS ] = "WM_CLASS";
    atom_names[ I_WM_DELETE_WINDOW ] = "WM_DELETE_WINDOW";
    atom_names[ I_WM_PROTOCOLS ] = "WM_PROTOCOLS";
    atom_names[ I_NET_WORKAREA ] = "_NET_WORKAREA";
    atom_names[ I_NET_CLIENT_LIST ] = "_NET_CLIENT_LIST";
    atom_names[ I_NET_CLIENT_LIST_STACKING ] = "_NET_CLIENT_LIST_STACKING";
    atom_names[ I_NET_NUMBER_OF_DESKTOPS ] = "_NET_NUMBER_OF_DESKTOPS";
    atom_names[ I_NET_CURRENT_DESKTOP ] = "_NET_CURRENT_DESKTOP";
    atom_names[ I_NET_DESKTOP_VIEWPORT ] = "_NET_DESKTOP_VIEWPORT";
    atom_names[ I_NET_DESKTOP_NAMES ] = "_NET_DESKTOP_NAMES";
    atom_names[ I_NET_ACTIVE_WINDOW ] = "_NET_ACTIVE_WINDOW";
    atom_names[ I_NET_SHOWING_DESKTOP ] = "_NET_SHOWING_DESKTOP";
    atom_names[ I_NET_SUPPORTED ] = "_NET_SUPPORTED";
    atom_names[ I_NET_WM_DESKTOP ] = "_NET_WM_DESKTOP";
    atom_names[ I_NET_WM_STATE ] = "_NET_WM_STATE";
    atom_names[ I_NET_WM_STATE_SKIP_TASKBAR ] = "_NET_WM_STATE_SKIP_TASKBAR";
    atom_names[ I_NET_WM_STATE_SKIP_PAGER ] = "_NET_WM_STATE_SKIP_PAGER";
    atom_names[ I_NET_WM_STATE_STICKY ] = "_NET_WM_STATE_STICKY";
    atom_names[ I_NET_WM_STATE_HIDDEN ] = "_NET_WM_STATE_HIDDEN";
    atom_names[ I_NET_WM_STATE_SHADED ] = "_NET_WM_STATE_SHADED";
    atom_names[ I_NET_WM_WINDOW_TYPE ] = "_NET_WM_WINDOW_TYPE";

    atom_names[ I_NET_WM_WINDOW_TYPE_DESKTOP ] = "_NET_WM_WINDOW_TYPE_DESKTOP";
    atom_names[ I_NET_WM_WINDOW_TYPE_DOCK ] = "_NET_WM_WINDOW_TYPE_DOCK";
    atom_names[ I_NET_WM_WINDOW_TYPE_TOOLBAR ] = "_NET_WM_WINDOW_TYPE_TOOLBAR";
    atom_names[ I_NET_WM_WINDOW_TYPE_MENU ] = "_NET_WM_WINDOW_TYPE_MENU";
    atom_names[ I_NET_WM_WINDOW_TYPE_UTILITY ] = "_NET_WM_WINDOW_TYPE_UTILITY";
    atom_names[ I_NET_WM_WINDOW_TYPE_SPLASH ] = "_NET_WM_WINDOW_TYPE_SPLASH";
    atom_names[ I_NET_WM_WINDOW_TYPE_DIALOG ] = "_NET_WM_WINDOW_TYPE_DIALOG";
    atom_names[ I_NET_WM_WINDOW_TYPE_NORMAL ] = "_NET_WM_WINDOW_TYPE_NORMAL";
    atom_names[ I_NET_WM_DESKTOP ] = "_NET_WM_DESKTOP";
    atom_names[ I_NET_WM_PID ] = "_NET_WM_PID";
    atom_names[ I_NET_WM_NAME ] = "_NET_WM_NAME";
    atom_names[ I_NET_WM_VISIBLE_NAME ] = "_NET_WM_VISIBLE_NAME";
    atom_names[ I_NET_WM_STRUT ] = "_NET_WM_STRUT";
    atom_names[ I_NET_WM_STRUT_PARTIAL ] = "_NET_WM_STRUT_PARTIAL";
    atom_names[ I_NET_WM_ICON ] = "_NET_WM_ICON";
    atom_names[ I_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR ] = "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR";

    atom_names[ I_NET_SYSTEM_TRAY_OPCODE ] = "_NET_SYSTEM_TRAY_OPCODE";
    atom_names[ I_NET_SYSTEM_TRAY_MESSAGE_DATA ] = "_NET_SYSTEM_TRAY_MESSAGE_DATA";
    atom_names[ I_NET_SYSTEM_TRAY_ORIENTATION ] = "_NET_SYSTEM_TRAY_ORIENTATION";
    atom_names[ I_MANAGER ] = "MANAGER";

    atom_names[ I_LXPANEL_CMD ] = "_LXPANEL_CMD";

    Atom atoms[ N_ATOMS ];

    ENTER;
   
    if( !  XInternAtoms( GDK_DISPLAY(), (char**)atom_names,
            N_ATOMS, False, atoms ) )
    {
        g_warning( "Error: unable to return Atoms" );
        return;
    }

    a_UTF8_STRING = atoms[ I_UTF8_STRING ];
    a_XROOTPMAP_ID = atoms[ I_XROOTPMAP_ID ];
    a_WM_STATE = atoms[ I_WM_STATE ];
    a_WM_CLASS = atoms[ I_WM_CLASS ];
    a_WM_DELETE_WINDOW = atoms[ I_WM_DELETE_WINDOW ];
    a_WM_PROTOCOLS = atoms[ I_WM_PROTOCOLS ];

    a_NET_WORKAREA = atoms[ I_NET_WORKAREA ];
    a_NET_CLIENT_LIST = atoms[ I_NET_CLIENT_LIST ];
    a_NET_CLIENT_LIST_STACKING = atoms[ I_NET_CLIENT_LIST_STACKING ];
    a_NET_NUMBER_OF_DESKTOPS = atoms[ I_NET_NUMBER_OF_DESKTOPS ];
    a_NET_CURRENT_DESKTOP = atoms[ I_NET_CURRENT_DESKTOP ];
    a_NET_DESKTOP_VIEWPORT = atoms[ I_NET_DESKTOP_VIEWPORT ];
    a_NET_DESKTOP_NAMES = atoms[ I_NET_DESKTOP_NAMES ];
    a_NET_ACTIVE_WINDOW = atoms[ I_NET_ACTIVE_WINDOW ];
    a_NET_SHOWING_DESKTOP = atoms[ I_NET_SHOWING_DESKTOP ];
    a_NET_SUPPORTED = atoms[ I_NET_SUPPORTED ];
    a_NET_WM_STATE = atoms[ I_NET_WM_STATE ];
    a_NET_WM_STATE_SKIP_TASKBAR = atoms[ I_NET_WM_STATE_SKIP_TASKBAR ];
    a_NET_WM_STATE_SKIP_PAGER = atoms[ I_NET_WM_STATE_SKIP_PAGER ];
    a_NET_WM_STATE_STICKY = atoms[ I_NET_WM_STATE_STICKY ];
    a_NET_WM_STATE_HIDDEN = atoms[ I_NET_WM_STATE_HIDDEN ];
    a_NET_WM_STATE_SHADED = atoms[ I_NET_WM_STATE_SHADED ];
    a_NET_WM_WINDOW_TYPE = atoms[ I_NET_WM_WINDOW_TYPE ];

    a_NET_WM_WINDOW_TYPE_DESKTOP = atoms[ I_NET_WM_WINDOW_TYPE_DESKTOP ];
    a_NET_WM_WINDOW_TYPE_DOCK = atoms[ I_NET_WM_WINDOW_TYPE_DOCK ];
    a_NET_WM_WINDOW_TYPE_TOOLBAR = atoms[ I_NET_WM_WINDOW_TYPE_TOOLBAR ];
    a_NET_WM_WINDOW_TYPE_MENU = atoms[ I_NET_WM_WINDOW_TYPE_MENU ];
    a_NET_WM_WINDOW_TYPE_UTILITY = atoms[ I_NET_WM_WINDOW_TYPE_UTILITY ];
    a_NET_WM_WINDOW_TYPE_SPLASH = atoms[ I_NET_WM_WINDOW_TYPE_SPLASH ];
    a_NET_WM_WINDOW_TYPE_DIALOG = atoms[ I_NET_WM_WINDOW_TYPE_DIALOG ];
    a_NET_WM_WINDOW_TYPE_NORMAL = atoms[ I_NET_WM_WINDOW_TYPE_NORMAL ];
    a_NET_WM_DESKTOP = atoms[ I_NET_WM_DESKTOP ];
    a_NET_WM_PID = atoms[ I_NET_WM_PID ];
    a_NET_WM_NAME = atoms[ I_NET_WM_NAME ];
    a_NET_WM_VISIBLE_NAME = atoms[ I_NET_WM_VISIBLE_NAME ];
    a_NET_WM_STRUT = atoms[ I_NET_WM_STRUT ];
    a_NET_WM_STRUT_PARTIAL = atoms[ I_NET_WM_STRUT_PARTIAL ];
    a_NET_WM_ICON = atoms[ I_NET_WM_ICON ];
    a_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR = atoms[ I_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR ];

    a_NET_SYSTEM_TRAY_OPCODE = atoms[ I_NET_SYSTEM_TRAY_OPCODE ];
    a_NET_SYSTEM_TRAY_MESSAGE_DATA = atoms [ I_NET_SYSTEM_TRAY_MESSAGE_DATA ];
    a_NET_SYSTEM_TRAY_ORIENTATION = atoms[ I_NET_SYSTEM_TRAY_ORIENTATION ];
    a_MANAGER = atoms[ I_MANAGER ];

    a_LXPANEL_CMD = atoms[ I_LXPANEL_CMD ];

    RET();
}

Here is the caller graph for this function:

void show_error ( GtkWindow *  parent_win,
const char *  msg 
)

Definition at line 1286 of file misc.c.

{
    GtkWidget* dlg = gtk_message_dialog_new( parent_win,
                                             GTK_DIALOG_MODAL,
                                             GTK_MESSAGE_ERROR,
                                             GTK_BUTTONS_OK, "%s", msg );
    gtk_dialog_run( (GtkDialog*)dlg );
    gtk_widget_destroy( dlg );
}

Here is the caller graph for this function:

int str2num ( pair p,
gchar *  str,
int  defval 
)

Definition at line 207 of file misc.c.

{
    ENTER;
    for (;p && p->str; p++) {
        if (!g_ascii_strcasecmp(str, p->str))
            RET(p->num);
    }
    RET(defval);
}

Here is the caller graph for this function:

static char* text_property_to_utf8 ( const XTextProperty *  prop) [static]

Definition at line 604 of file misc.c.

{
  char **list;
  int count;
  char *retval;

  ENTER;
  list = NULL;
  count = gdk_text_property_to_utf8_list (gdk_x11_xatom_to_atom (prop->encoding),
                                          prop->format,
                                          prop->value,
                                          prop->nitems,
                                          &list);

  DBG("count=%d\n", count);
  if (count == 0)
    return NULL;

  retval = list[0];
  list[0] = g_strdup (""); /* something to free */

  g_strfreev (list);

  RET(retval);
}

Here is the caller graph for this function:

static char* translate_app_exec_to_command_line ( const char *  pexec,
GList *  file_list 
) [static]

Definition at line 1415 of file misc.c.

{
    char* file;
    GList* l;
    gchar *tmp;
    GString* cmd = g_string_new("");
    gboolean add_files = FALSE;

    for( ; *pexec; ++pexec )
    {
        if( *pexec == '%' )
        {
            ++pexec;
            switch( *pexec )
            {
            case 'U':
                for( l = file_list; l; l = l->next )
                {
                    tmp = g_filename_to_uri( (char*)l->data, NULL, NULL );
                    file = g_shell_quote( tmp );
                    g_free( tmp );
                    g_string_append( cmd, file );
                    g_string_append_c( cmd, ' ' );
                    g_free( file );
                }
                add_files = TRUE;
                break;
            case 'u':
                if( file_list && file_list->data )
                {
                    file = (char*)file_list->data;
                    tmp = g_filename_to_uri( file, NULL, NULL );
                    file = g_shell_quote( tmp );
                    g_free( tmp );
                    g_string_append( cmd, file );
                    g_free( file );
                    add_files = TRUE;
                }
                break;
            case 'F':
            case 'N':
                for( l = file_list; l; l = l->next )
                {
                    file = (char*)l->data;
                    tmp = g_shell_quote( file );
                    g_string_append( cmd, tmp );
                    g_string_append_c( cmd, ' ' );
                    g_free( tmp );
                }
                add_files = TRUE;
                break;
            case 'f':
            case 'n':
                if( file_list && file_list->data )
                {
                    file = (char*)file_list->data;
                    tmp = g_shell_quote( file );
                    g_string_append( cmd, tmp );
                    g_free( tmp );
                    add_files = TRUE;
                }
                break;
            case 'D':
                for( l = file_list; l; l = l->next )
                {
                    tmp = g_path_get_dirname( (char*)l->data );
                    file = g_shell_quote( tmp );
                    g_free( tmp );
                    g_string_append( cmd, file );
                    g_string_append_c( cmd, ' ' );
                    g_free( file );
                }
                add_files = TRUE;
                break;
            case 'd':
                if( file_list && file_list->data )
                {
                    tmp = g_path_get_dirname( (char*)file_list->data );
                    file = g_shell_quote( tmp );
                    g_free( tmp );
                    g_string_append( cmd, file );
                    g_free( tmp );
                    add_files = TRUE;
                }
                break;
            case 'c':
                #if 0
                g_string_append( cmd, vfs_app_desktop_get_disp_name( app ) );
                #endif
                break;
            case 'i':
                /* Add icon name */
                #if 0
                if( vfs_app_desktop_get_icon_name( app ) )
                {
                    g_string_append( cmd, "--icon " );
                    g_string_append( cmd, vfs_app_desktop_get_icon_name( app ) );
                }
                #endif
                break;
            case 'k':
                /* Location of the desktop file */
                break;
            case 'v':
                /* Device name */
                break;
            case '%':
                g_string_append_c ( cmd, '%' );
                break;
            case '\0':
                goto _finish;
                break;
            }
        }
        else  /* not % escaped part */
        {
            g_string_append_c ( cmd, *pexec );
        }
    }
_finish:
    if( ! add_files )
    {
        g_string_append_c ( cmd, ' ' );
        for( l = file_list; l; l = l->next )
        {
            file = (char*)l->data;
            tmp = g_shell_quote( file );
            g_string_append( cmd, tmp );
            g_string_append_c( cmd, ' ' );
            g_free( tmp );
        }
    }

    return g_string_free( cmd, FALSE );
}

Here is the caller graph for this function:

char* translate_exec_to_cmd ( const char *  exec,
const char *  icon,
const char *  title,
const char *  fpath 
)

Definition at line 1198 of file misc.c.

{
    GString* cmd = g_string_sized_new( 256 );
    for( ; *exec; ++exec )
    {
        if( G_UNLIKELY(*exec == '%') )
        {
            ++exec;
            if( !*exec )
                break;
            switch( *exec )
            {
                case 'c':
                    g_string_append( cmd, title );
                    break;
                case 'i':
                    if( icon )
                    {
                        g_string_append( cmd, "--icon " );
                        g_string_append( cmd, icon );
                    }
                    break;
                case 'k':
                {
                    char* uri = g_filename_to_uri( fpath, NULL, NULL );
                    g_string_append( cmd, uri );
                    g_free( uri );
                    break;
                }
                case '%':
                    g_string_append_c( cmd, '%' );
                    break;
            }
        }
        else
            g_string_append_c( cmd, *exec );
    }
    return g_string_free( cmd, FALSE );
}

Here is the caller graph for this function:

void Xclimsg ( Window  win,
Atom  type,
long  l0,
long  l1,
long  l2,
long  l3,
long  l4 
)

Definition at line 472 of file misc.c.

{
    XClientMessageEvent xev;
    xev.type = ClientMessage;
    xev.window = win;
    xev.message_type = type;
    xev.format = 32;
    xev.data.l[0] = l0;
    xev.data.l[1] = l1;
    xev.data.l[2] = l2;
    xev.data.l[3] = l3;
    xev.data.l[4] = l4;
    XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False,
          (SubstructureNotifyMask | SubstructureRedirectMask),
          (XEvent *) &xev);
}

Here is the caller graph for this function:

void Xclimsgwm ( Window  win,
Atom  type,
Atom  arg 
)

Definition at line 490 of file misc.c.

{
    XClientMessageEvent xev;

    xev.type = ClientMessage;
    xev.window = win;
    xev.message_type = type;
    xev.format = 32;
    xev.data.l[0] = arg;
    xev.data.l[1] = GDK_CURRENT_TIME;
    XSendEvent(GDK_DISPLAY(), win, False, 0L, (XEvent *) &xev);
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 96 of file misc.c.

Definition at line 104 of file misc.c.

Atom a_MANAGER

Definition at line 102 of file misc.c.

Definition at line 70 of file misc.c.

Definition at line 64 of file misc.c.

Definition at line 65 of file misc.c.

Definition at line 71 of file misc.c.

Definition at line 67 of file misc.c.

Definition at line 69 of file misc.c.

Definition at line 68 of file misc.c.

Definition at line 66 of file misc.c.

Definition at line 72 of file misc.c.

Definition at line 73 of file misc.c.

Definition at line 100 of file misc.c.

Definition at line 99 of file misc.c.

Definition at line 101 of file misc.c.

Definition at line 89 of file misc.c.

Definition at line 95 of file misc.c.

Definition at line 91 of file misc.c.

Definition at line 90 of file misc.c.

Definition at line 74 of file misc.c.

Definition at line 78 of file misc.c.

Definition at line 79 of file misc.c.

Definition at line 76 of file misc.c.

Definition at line 75 of file misc.c.

Definition at line 77 of file misc.c.

Definition at line 93 of file misc.c.

Definition at line 94 of file misc.c.

Definition at line 92 of file misc.c.

Definition at line 80 of file misc.c.

Definition at line 81 of file misc.c.

Definition at line 87 of file misc.c.

Definition at line 82 of file misc.c.

Definition at line 84 of file misc.c.

Definition at line 88 of file misc.c.

Definition at line 86 of file misc.c.

Definition at line 83 of file misc.c.

Definition at line 85 of file misc.c.

Definition at line 63 of file misc.c.

Definition at line 53 of file misc.c.

Atom a_WM_CLASS

Definition at line 58 of file misc.c.

Definition at line 59 of file misc.c.

Definition at line 60 of file misc.c.

Atom a_WM_STATE

Definition at line 57 of file misc.c.

Definition at line 54 of file misc.c.

Initial value:
 {
    { ALLIGN_NONE, "none" },
    { ALLIGN_LEFT, "left" },
    { ALLIGN_RIGHT, "right" },
    { ALLIGN_CENTER, "center"},
    { 0, NULL },
}

Definition at line 162 of file misc.c.

Initial value:
 {
    { 0, "0" },
    { 1, "1" },
    { 0, NULL },
}

Definition at line 193 of file misc.c.

Initial value:
 {
    { EDGE_NONE, "none" },
    { EDGE_LEFT, "left" },
    { EDGE_RIGHT, "right" },
    { EDGE_TOP, "top" },
    { EDGE_BOTTOM, "bottom" },
    { 0, NULL },
}

Definition at line 170 of file misc.c.

Initial value:
 {
    { HEIGHT_NONE, "none" },
    { HEIGHT_PIXEL, "pixel" },
    { 0, NULL },
}

Definition at line 187 of file misc.c.

GQuark img_data_id = 0 [static]

Definition at line 47 of file misc.c.

Definition at line 107 of file misc.c.

Initial value:
 {
    { POS_NONE, "none" },
    { POS_START, "start" },
    { POS_END,  "end" },
    { 0, NULL},
}

Definition at line 198 of file misc.c.

Initial value:
 {
    { WIDTH_NONE, "none" },
    { WIDTH_REQUEST, "request" },
    { WIDTH_PIXEL, "pixel" },
    { WIDTH_PERCENT, "percent" },
    { 0, NULL },
}

Definition at line 179 of file misc.c.