pidgin/purple-plugin-pack
Clone
Summary
Browse
Changes
Graph
fixed the crash on disconnect by closing conversation windows when that buddy is done with it's events, rather than when processing each event.
2009-08-30, Gary Kramlich
8ab9212b3ed3
fixed the crash on disconnect by closing conversation windows when that buddy is done with it's events, rather than when processing each event.
added status text support as a status of the stress
/*--------------------------------------------------------------------------*
* AUTOPROFILE *
* *
* A Purple away message and profile manager that supports dynamic text *
* *
* AutoProfile is the legal property of its developers. Please refer to *
* the COPYRIGHT file distributed with this source distribution. *
* *
* 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
"../common/pp_internal.h"
#include
"component.h"
#include
"utility.h"
#include
"gtkimhtml.h"
/*---------- TIMESTAMP: Display time at creation ---------------------------*/
static
char
*
timestamp_generate
(
struct
widget
*
w
)
{
struct
tm
*
cur_time
;
char
*
ret
;
time_t
*
general_time
=
(
time_t
*
)
malloc
(
sizeof
(
time_t
));
time
(
general_time
);
cur_time
=
ap_localtime
(
general_time
);
free
(
general_time
);
ret
=
(
char
*
)
malloc
(
AP_SIZE_MAXIMUM
);
*
ret
=
'\0'
;
strftime
(
ret
,
AP_SIZE_MAXIMUM
-
1
,
ap_prefs_get_string
(
w
,
"timestamp_format"
),
cur_time
);
free
(
cur_time
);
return
ret
;
}
static
void
timestamp_init
(
struct
widget
*
w
)
{
ap_prefs_add_string
(
w
,
"timestamp_format"
,
"Automatically created at %I:%M %p"
);
}
static
GtkWidget
*
entry
;
static
void
event_cb
(
GtkWidget
*
widget
,
struct
widget
*
w
)
{
ap_prefs_set_string
(
w
,
"timestamp_format"
,
gtk_imhtml_get_markup
(
GTK_IMHTML
(
entry
)));
}
static
void
formatting_toggle_cb
(
GtkIMHtml
*
imhtml
,
GtkIMHtmlButtons
buttons
,
struct
widget
*
w
)
{
ap_prefs_set_string
(
w
,
"timestamp_format"
,
gtk_imhtml_get_markup
(
GTK_IMHTML
(
entry
)));
}
static
void
formatting_clear_cb
(
GtkIMHtml
*
imhtml
,
struct
widget
*
w
)
{
ap_prefs_set_string
(
w
,
"timestamp_format"
,
gtk_imhtml_get_markup
(
GTK_IMHTML
(
entry
)));
}
static
GtkWidget
*
timestamp_menu
(
struct
widget
*
w
)
{
GtkWidget
*
ret
=
gtk_vbox_new
(
FALSE
,
5
);
GtkWidget
*
label
,
*
sw
;
GtkWidget
*
entry_window
,
*
toolbar
;
GtkTextBuffer
*
text_buffer
;
entry_window
=
pidgin_create_imhtml
(
TRUE
,
&
entry
,
&
toolbar
,
&
sw
);
gtk_box_pack_start
(
GTK_BOX
(
ret
),
entry_window
,
FALSE
,
FALSE
,
0
);
gtk_imhtml_append_text_with_images
(
GTK_IMHTML
(
entry
),
ap_prefs_get_string
(
w
,
"timestamp_format"
),
0
,
NULL
);
text_buffer
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
entry
));
g_signal_connect
(
G_OBJECT
(
text_buffer
),
"changed"
,
G_CALLBACK
(
event_cb
),
w
);
g_signal_connect_after
(
G_OBJECT
(
entry
),
"format_function_toggle"
,
G_CALLBACK
(
formatting_toggle_cb
),
w
);
g_signal_connect_after
(
G_OBJECT
(
entry
),
"format_function_clear"
,
G_CALLBACK
(
formatting_clear_cb
),
w
);
label
=
gtk_label_new
(
_
(
"Insert the following characters where time is to be displayed:
\n\n
"
"%H
\t
hour (24-hour clock)
\n
"
"%I
\t
hour (12-hour clock)
\n
"
"%p
\t
AM or PM
\n
"
"%M
\t
minute
\n
"
"%S
\t
second
\n
"
"%a
\t
abbreviated weekday name
\n
"
"%A
\t
full weekday name
\n
"
"%b
\t
abbreviated month name
\n
"
"%B
\t
full month name
\n
"
"%m
\t
month (numerical)
\n
"
"%d
\t
day of the month
\n
"
"%j
\t
day of the year
\n
"
"%W
\t
week number of the year
\n
"
"%w
\t
weekday (numerical)
\n
"
"%y
\t
year without century
\n
"
"%Y
\t
year with century
\n
"
"%z
\t
time zone name, if any
\n
"
"%%
\t
%"
));
sw
=
gtk_scrolled_window_new
(
NULL
,
NULL
);
gtk_scrolled_window_set_policy
(
GTK_SCROLLED_WINDOW
(
sw
),
GTK_POLICY_NEVER
,
GTK_POLICY_ALWAYS
);
gtk_box_pack_start
(
GTK_BOX
(
ret
),
sw
,
TRUE
,
TRUE
,
0
);
gtk_scrolled_window_add_with_viewport
(
GTK_SCROLLED_WINDOW
(
sw
),
label
);
return
ret
;
}
struct
component
timestamp
=
{
N_
(
"Timestamp"
),
N_
(
"Displays custom text showing when message was created"
),
"Timestamp"
,
&
timestamp_generate
,
&
timestamp_init
,
NULL
,
NULL
,
NULL
,
&
timestamp_menu
};