Adding upstream version 0.5.12.
[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
514580cf 31enum _PluginConfType {
7486d297
DB
32 CONF_TYPE_STR,
33 CONF_TYPE_INT,
34 CONF_TYPE_BOOL,
35 CONF_TYPE_FILE,
2ba86315
DB
36 CONF_TYPE_FILE_ENTRY,
37 CONF_TYPE_DIRECTORY_ENTRY,
38 CONF_TYPE_TRIM
7486d297
DB
39};
40
6cc5e1a6
DB
41enum { LINE_NONE, LINE_BLOCK_START, LINE_BLOCK_END, LINE_VAR };
42
43typedef struct {
44 int num, len, type;
45 gchar str[256];
46 gchar *t[3];
47} line;
48
49
50typedef struct {
51 int num;
52 gchar *str;
53} pair;
54
55extern pair allign_pair[];
56extern pair edge_pair[];
57extern pair width_pair[];
58extern pair height_pair[];
59extern pair bool_pair[];
60extern pair pos_pair[];
61
62int str2num(pair *p, gchar *str, int defval);
63gchar *num2str(pair *p, int num, gchar *defval);
64
65extern int lxpanel_get_line(char **fp, line *s);
66extern int lxpanel_put_line(FILE* fp, const char* format, ...);
7486d297
DB
67#define lxpanel_put_str(fp, name, val) (G_UNLIKELY( !(val) || !*(val) )) ? 0 : lxpanel_put_line(fp, "%s=%s", name, val)
68#define lxpanel_put_bool(fp, name, val) lxpanel_put_line(fp, "%s=%c", name, (val) ? '1' : '0')
69#define lxpanel_put_int(fp, name, val) lxpanel_put_line(fp, "%s=%d", name, val)
70//extern int lxpanel_put_str( FILE* fp, const char* name, const char* val );
71//extern int lxpanel_put_bool( FILE* fp, const char* name, gboolean val );
72//extern int lxpanel_put_int( FILE* fp, const char* name, int val );
6cc5e1a6
DB
73int get_line_as_is(char **fp, line *s);
74
2ba86315 75void Xclimsg(Window win, Atom type, long l0, long l1, long l2, long l3, long l4);
6cc5e1a6
DB
76void Xclimsgwm(Window win, Atom type, Atom arg);
77void *get_xaproperty (Window win, Atom prop, Atom type, int *nitems);
78char *get_textproperty(Window win, Atom prop);
79void *get_utf8_property(Window win, Atom atom);
80char **get_utf8_property_list(Window win, Atom atom, int *count);
81
82void resolve_atoms();
83//Window Select_Window(Display *dpy);
84int get_net_number_of_desktops();
85int get_net_current_desktop ();
86int get_net_wm_desktop(Window win);
87int get_wm_state (Window win);
88void get_net_wm_state(Window win, NetWMState *nws);
89void get_net_wm_window_type(Window win, NetWMWindowType *nwwt);
90GPid get_net_wm_pid(Window win);
91
92void calculate_position(Panel *np);
93gchar *expand_tilda(gchar *file);
2ba86315 94
96dc8a45
DB
95GtkWidget *_gtk_image_new_from_file_scaled(const gchar *file, gint width,
96 gint height, gboolean keep_ratio);
6cc5e1a6
DB
97void get_button_spacing(GtkRequisition *req, GtkContainer *parent, gchar *name);
98guint32 gcolor2rgb24(GdkColor *color);
2ba86315
DB
99GtkWidget * fb_button_new_from_file(
100 gchar * image_file, int width, int height, gulong highlight_color, gboolean keep_ratio);
101GtkWidget * fb_button_new_from_file_with_label(
102 gchar * image_file, int width, int height, gulong highlight_color, gboolean keep_ratio, Panel * panel, gchar * label);
6cc5e1a6
DB
103
104char* translate_exec_to_cmd( const char* exec, const char* icon,
105 const char* title, const char* fpath );
106
107/*
108 This function is used to re-create a new box with different
109 orientation from the old one, add all children of the old one to
110 the new one, and then destroy the old box.
111 It's mainly used when we need to change the orientation of the panel or
112 any plugin with a layout box. Since GtkHBox cannot be changed to GtkVBox,
113 recreating a new box to replace the old one is required.
114*/
115GtkWidget* recreate_box( GtkBox* oldbox, GtkOrientation orientation );
116
117void show_error( GtkWindow* parent_win, const char* msg );
118
119/* Parameters: const char* name, gpointer ret_value, GType type, ....NULL */
120GtkWidget* create_generic_config_dlg( const char* title, GtkWidget* parent,
2ba86315 121 GSourceFunc apply_func, Plugin * plugin,
6cc5e1a6
DB
122 const char* name, ... );
123
124
125char* get_config_file( const char* profile, const char* file_name, gboolean is_global );
126
7486d297
DB
127extern GtkMenu* lxpanel_get_panel_menu( Panel* panel, Plugin* plugin, gboolean use_sub_menu );
128
2ba86315 129extern GdkPixbuf* lxpanel_load_icon( const char* name, int width, int height, gboolean use_fallback );
7486d297 130
2ba86315 131void fb_button_set_from_file(GtkWidget* btn, const char* img_file, gint width, gint height, gboolean keep_ratio);
7486d297
DB
132
133gboolean lxpanel_launch_app(const char* exec, GList* files, gboolean in_terminal);
6cc5e1a6
DB
134
135#endif