Adding upstream version 0.3.5.2+svn20080509.
[debian/lxpanel.git] / src / misc.h
CommitLineData
6cc5e1a6
DB
1/**
2 * Copyright (c) 2006 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef MISC_H
20#define MISC_H
21
22#include <X11/Xatom.h>
23#include <gtk/gtk.h>
24#include <gdk/gdk.h>
25#include <gdk/gdkx.h>
26#include <stdio.h>
27
28#include "panel.h"
29#include "plugin.h"
30
31enum { LINE_NONE, LINE_BLOCK_START, LINE_BLOCK_END, LINE_VAR };
32
33typedef struct {
34 int num, len, type;
35 gchar str[256];
36 gchar *t[3];
37} line;
38
39
40typedef struct {
41 int num;
42 gchar *str;
43} pair;
44
45extern pair allign_pair[];
46extern pair edge_pair[];
47extern pair width_pair[];
48extern pair height_pair[];
49extern pair bool_pair[];
50extern pair pos_pair[];
51
52int str2num(pair *p, gchar *str, int defval);
53gchar *num2str(pair *p, int num, gchar *defval);
54
55extern int lxpanel_get_line(char **fp, line *s);
56extern int lxpanel_put_line(FILE* fp, const char* format, ...);
57extern int lxpanel_put_str( FILE* fp, const char* name, const char* val );
58extern int lxpanel_put_bool( FILE* fp, const char* name, gboolean val );
59extern int lxpanel_put_int( FILE* fp, const char* name, int val );
60int get_line_as_is(char **fp, line *s);
61
62void Xclimsg(Window win, long type, long l0, long l1, long l2, long l3, long l4);
63void Xclimsgwm(Window win, Atom type, Atom arg);
64void *get_xaproperty (Window win, Atom prop, Atom type, int *nitems);
65char *get_textproperty(Window win, Atom prop);
66void *get_utf8_property(Window win, Atom atom);
67char **get_utf8_property_list(Window win, Atom atom, int *count);
68
69void resolve_atoms();
70//Window Select_Window(Display *dpy);
71int get_net_number_of_desktops();
72int get_net_current_desktop ();
73int get_net_wm_desktop(Window win);
74int get_wm_state (Window win);
75void get_net_wm_state(Window win, NetWMState *nws);
76void get_net_wm_window_type(Window win, NetWMWindowType *nwwt);
77GPid get_net_wm_pid(Window win);
78
79void calculate_position(Panel *np);
80gchar *expand_tilda(gchar *file);
81GdkPixbuf *gdk_pixbuf_scale_ratio(GdkPixbuf *p, int width, int height, GdkInterpType itype,
82 gboolean keep_ratio);
83GtkWidget *gtk_image_new_from_file_scaled(const gchar *file, gint width, gint height,
84 gboolean keep_ratio);
85void get_button_spacing(GtkRequisition *req, GtkContainer *parent, gchar *name);
86guint32 gcolor2rgb24(GdkColor *color);
87GtkWidget *fb_button_new_from_file(gchar *fname, int width, int height, gulong hicolor,
88 gboolean keep_ratio);
89GtkWidget *fb_button_new_from_file_with_label(gchar *fname, int width, int height,
90 gulong hicolor, gboolean keep_ratio, gchar *label);
91
92char* translate_exec_to_cmd( const char* exec, const char* icon,
93 const char* title, const char* fpath );
94
95/*
96 This function is used to re-create a new box with different
97 orientation from the old one, add all children of the old one to
98 the new one, and then destroy the old box.
99 It's mainly used when we need to change the orientation of the panel or
100 any plugin with a layout box. Since GtkHBox cannot be changed to GtkVBox,
101 recreating a new box to replace the old one is required.
102*/
103GtkWidget* recreate_box( GtkBox* oldbox, GtkOrientation orientation );
104
105void show_error( GtkWindow* parent_win, const char* msg );
106
107/* Parameters: const char* name, gpointer ret_value, GType type, ....NULL */
108GtkWidget* create_generic_config_dlg( const char* title, GtkWidget* parent,
109 GSourceFunc apply_func, gpointer plugin,
110 const char* name, ... );
111
112
113char* get_config_file( const char* profile, const char* file_name, gboolean is_global );
114
115extern GtkWidget* lxpanel_get_panel_menu( Panel* panel, Plugin* plugin, gboolean use_sub_menu );
116
117#endif