grim/guifications1
Clone
Summary
Browse
Changes
Graph
a useless feature.. dunno if this will work on windows.. datallah any ideas?
2004-01-14, grim
104f6faa875a
a useless feature.. dunno if this will work on windows.. datallah any ideas?
/*
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
"gf_gtkutils.h"
#include
"gf_types.h"
#include
"gf_pngs.h"
/***********************************************************************
* static
**********************************************************************/
static
GtkWidget
*
gf_make_window_position_menu_item
(
gf_window_position
item
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
image
,
*
label
=
NULL
;
GdkPixbuf
*
pixbuf
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
pixbuf
=
get_window_position_image
(
item
);
image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
image
,
FALSE
,
FALSE
,
0
);
if
(
pixbuf
!=
NULL
)
g_object_unref
(
pixbuf
);
switch
(
item
)
{
case
window_position_nw
:
label
=
gtk_label_new
(
"Top Left"
);
break
;
case
window_position_ne
:
label
=
gtk_label_new
(
"Top Right"
);
break
;
case
window_position_sw
:
label
=
gtk_label_new
(
"Bottom Left"
);
break
;
case
window_position_se
:
label
=
gtk_label_new
(
"Bottom Right"
);
break
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
static
GtkWidget
*
gf_make_window_zoom_menu_item
(
gf_window_zoom
item
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
image
,
*
label
=
NULL
;
GdkPixbuf
*
pixbuf
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
pixbuf
=
get_window_zoom_image
(
item
);
image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
image
,
FALSE
,
FALSE
,
0
);
if
(
pixbuf
!=
NULL
)
g_object_unref
(
pixbuf
);
switch
(
item
)
{
case
window_zoom_200
:
label
=
gtk_label_new
(
"200%"
);
break
;
case
window_zoom_175
:
label
=
gtk_label_new
(
"175%"
);
break
;
case
window_zoom_150
:
label
=
gtk_label_new
(
"150%"
);
break
;
case
window_zoom_125
:
label
=
gtk_label_new
(
"125%"
);
break
;
case
window_zoom_100
:
label
=
gtk_label_new
(
"100%"
);
break
;
case
window_zoom_75
:
label
=
gtk_label_new
(
"75%"
);
break
;
case
window_zoom_50
:
label
=
gtk_label_new
(
"50%"
);
break
;
case
window_zoom_25
:
label
=
gtk_label_new
(
"25%"
);
break
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
static
GtkWidget
*
gf_make_window_mouse_menu_item
(
gf_window_mouse
item
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
label
=
NULL
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
switch
(
item
)
{
case
window_mouse_destroy
:
label
=
gtk_label_new
(
"Close Window"
);
break
;
case
window_mouse_info
:
label
=
gtk_label_new
(
"Buddy Info"
);
break
;
case
window_mouse_conversation
:
label
=
gtk_label_new
(
"Open Conversation"
);
break
;
case
window_mouse_log
:
label
=
gtk_label_new
(
"View Log"
);
break
;
case
window_mouse_context
:
label
=
gtk_label_new
(
"Context Menu"
);
break
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
static
GtkWidget
*
gf_make_item_position_menu_item
(
gf_item_position
item
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
image
,
*
label
=
NULL
;
GdkPixbuf
*
pixbuf
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
pixbuf
=
get_item_position_image
(
item
);
image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
image
,
FALSE
,
FALSE
,
0
);
if
(
pixbuf
!=
NULL
)
g_object_unref
(
pixbuf
);
switch
(
item
)
{
case
item_position_nw
:
label
=
gtk_label_new
(
"Top Left"
);
break
;
case
item_position_n
:
label
=
gtk_label_new
(
"Top"
);
break
;
case
item_position_ne
:
label
=
gtk_label_new
(
"Top Right"
);
break
;
case
item_position_w
:
label
=
gtk_label_new
(
"Left"
);
break
;
case
item_position_c
:
label
=
gtk_label_new
(
"Center"
);
break
;
case
item_position_e
:
label
=
gtk_label_new
(
"Right"
);
break
;
case
item_position_sw
:
label
=
gtk_label_new
(
"Bottom Left"
);
break
;
case
item_position_s
:
label
=
gtk_label_new
(
"Bottom"
);
break
;
case
item_position_se
:
label
=
gtk_label_new
(
"Bottom Right"
);
break
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
static
GtkWidget
*
gf_make_text_clipping_menu_item
(
gf_text_clipping
item
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
image
,
*
label
=
NULL
;
GdkPixbuf
*
pixbuf
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
pixbuf
=
get_text_clipping_image
(
item
);
image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
image
,
FALSE
,
FALSE
,
0
);
if
(
pixbuf
!=
NULL
)
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
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
static
GtkWidget
*
gf_make_icon_size_menu_item
(
gf_icon_size
item
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
image
,
*
label
=
NULL
;
GdkPixbuf
*
pixbuf
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
pixbuf
=
get_icon_size_image
(
item
);
image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
image
,
FALSE
,
FALSE
,
0
);
if
(
pixbuf
!=
NULL
)
g_object_unref
(
pixbuf
);
switch
(
item
)
{
case
icon_size_tiny
:
label
=
gtk_label_new
(
"Tiny (16x16)"
);
break
;
case
icon_size_small
:
label
=
gtk_label_new
(
"Small (24x24)"
);
break
;
case
icon_size_normal
:
label
=
gtk_label_new
(
"Normal (48x48)"
);
break
;
case
icon_size_large
:
label
=
gtk_label_new
(
"Large (96x96)"
);
break
;
case
icon_size_huge
:
label
=
gtk_label_new
(
"Huge (144x144)"
);
break
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
static
GtkWidget
*
gf_make_event_menu_item
(
gf_event
event
)
{
GtkWidget
*
menu_item
,
*
hbox
,
*
label
=
NULL
;
menu_item
=
gtk_menu_item_new
();
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
menu_item
),
hbox
);
switch
(
event
)
{
case
gf_event_signon
:
label
=
gtk_label_new
(
"Sign On"
);
break
;
case
gf_event_signoff
:
label
=
gtk_label_new
(
"Sign Off"
);
break
;
case
gf_event_away
:
label
=
gtk_label_new
(
"Away"
);
break
;
case
gf_event_back
:
label
=
gtk_label_new
(
"Back"
);
break
;
case
gf_event_idle
:
label
=
gtk_label_new
(
"Idle"
);
break
;
case
gf_event_unidle
:
label
=
gtk_label_new
(
"Unidle"
);
break
;
case
gf_event_custom
:
label
=
gtk_label_new
(
"Custom"
);
break
;
}
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
menu_item
);
return
menu_item
;
}
/***********************************************************************
* export
**********************************************************************/
GtkWidget
*
gf_make_hig_frame
(
GtkWidget
*
parent
,
const
gchar
*
title
)
{
GtkWidget
*
label
,
*
hbox
,
*
vbox
;
gchar
*
formatted
;
vbox
=
gtk_vbox_new
(
FALSE
,
6
);
gtk_box_pack_start
(
GTK_BOX
(
parent
),
vbox
,
FALSE
,
FALSE
,
0
);
label
=
gtk_label_new
(
NULL
);
formatted
=
g_strdup_printf
(
"<span weight=
\"
bold
\"
>%s</span>"
,
title
);
gtk_label_set_markup
(
GTK_LABEL
(
label
),
formatted
);
g_free
(
formatted
);
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
label
,
FALSE
,
FALSE
,
0
);
hbox
=
gtk_hbox_new
(
FALSE
,
6
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
hbox
,
FALSE
,
FALSE
,
0
);
label
=
gtk_label_new
(
" "
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
vbox
);
vbox
=
gtk_vbox_new
(
FALSE
,
6
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
vbox
,
FALSE
,
FALSE
,
0
);
gtk_widget_show
(
vbox
);
return
vbox
;
}
GtkWidget
*
gf_make_label
(
gchar
*
text
,
GtkSizeGroup
*
sg
)
{
GtkWidget
*
label
;
label
=
gtk_label_new_with_mnemonic
(
text
);
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
,
0.5
);
if
(
sg
)
gtk_size_group_add_widget
(
sg
,
label
);
gtk_widget_show
(
label
);
return
label
;
}
GtkWidget
*
gf_make_check_button
(
gboolean
on
,
const
gchar
*
text
,
GtkSizeGroup
*
sg
)
{
GtkWidget
*
check
;
check
=
gtk_check_button_new_with_mnemonic
(
text
);
gtk_toggle_button_set_active
(
GTK_TOGGLE_BUTTON
(
check
),
on
);
if
(
sg
)
gtk_size_group_add_widget
(
sg
,
check
);
gtk_widget_show
(
check
);
return
check
;
}
GtkWidget
*
gf_make_spin_button
(
gdouble
value
,
gdouble
min
,
gdouble
max
,
gboolean
numeric
)
{
GtkWidget
*
spin
;
GtkObject
*
adj
;
adj
=
gtk_adjustment_new
(
value
,
min
,
max
,
1
,
10
,
10
);
spin
=
gtk_spin_button_new
(
GTK_ADJUSTMENT
(
adj
),
1
,
0
);
gtk_spin_button_set_numeric
(
GTK_SPIN_BUTTON
(
spin
),
numeric
);
gtk_widget_show
(
spin
);
return
spin
;
}
GtkWidget
*
gf_make_window_position_option_menu
(
gf_window_position
position
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
4
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_window_position_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
position
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_make_window_zoom_option_menu
(
gf_window_zoom
zoom
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
8
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_window_zoom_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
zoom
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_make_window_mouse_option_menu
(
gf_window_mouse
mouse
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
5
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_window_mouse_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
mouse
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_make_item_position_option_menu
(
gf_item_position
position
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
9
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_item_position_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
position
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_make_text_clipping_option_menu
(
gf_text_clipping
clipping
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
4
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_text_clipping_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
clipping
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_make_icon_size_option_menu
(
gf_icon_size
size
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
5
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_icon_size_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
size
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_make_event_option_menu
(
gf_event
event
)
{
GtkWidget
*
option_menu
,
*
menu
;
gint
i
;
option_menu
=
gtk_option_menu_new
();
menu
=
gtk_menu_new
();
for
(
i
=
0
;
i
<
7
;
i
++
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
gf_make_event_menu_item
(
i
));
gtk_widget_show_all
(
menu
);
gtk_option_menu_set_menu
(
GTK_OPTION_MENU
(
option_menu
),
menu
);
gtk_option_menu_set_history
(
GTK_OPTION_MENU
(
option_menu
),
event
);
gtk_widget_show
(
option_menu
);
return
option_menu
;
}
GtkWidget
*
gf_add_label
(
GtkWidget
*
widget
,
gchar
*
text
,
GtkSizeGroup
*
sg
)
{
GtkWidget
*
hbox
,
*
label
;
hbox
=
gtk_hbox_new
(
FALSE
,
4
);
label
=
gf_make_label
(
text
,
sg
);
gtk_label_set_mnemonic_widget
(
GTK_LABEL
(
label
),
widget
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
label
,
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
widget
,
FALSE
,
FALSE
,
0
);
gtk_widget_show_all
(
hbox
);
return
hbox
;
}
GtkWidget
*
gf_add_page
(
GtkNotebook
*
parent
,
gchar
*
text
,
gint
position
)
{
GtkWidget
*
vbox
,
*
label
;
label
=
gtk_label_new
(
text
);
vbox
=
gtk_vbox_new
(
FALSE
,
0
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
vbox
),
12
);
gtk_notebook_insert_page
(
parent
,
vbox
,
label
,
position
);
return
vbox
;
}