gen_util_applet mailcheck patch
- From: Jacob Berkman <jberkman andrew cmu edu>
- To: gnome-devel-list gnome org
- Subject: gen_util_applet mailcheck patch
- Date: Wed, 10 Mar 1999 21:14:22 -0500 (EST)
Hi,
I've included a patch that adds the ability to the mailcheck applet to
launch a user-defined email program (well, any program) when clicked.
Also, I added a check to see if the pre-check command string is zero
length, and skip the system() etc. if it is.
If someone could, after checking it over for anything dumb on my part,
submit it to CVS I would appreciate it.
Thanks,
Jacob Berkman
--
"Me fail English? That's unpossible!" - R. Wiggam
--- mailcheck.c Wed Jan 27 15:54:18 1999
+++ mailcheck.c Wed Mar 10 21:02:55 1999
@@ -41,6 +41,9 @@
guint update_freq;
+ /* command launched when clicked */
+ char *mail_prog_cmd;
+
char *cmd;
/* This holds either the drawing area or the label */
@@ -81,7 +84,7 @@
/* The property window */
GtkWidget *property_window;
- GtkWidget *spin, *cmd_entry;
+ GtkWidget *spin, *cmd_entry, *mail_prog_entry;
gboolean anim_changed;
char *mailcheck_text_only;
@@ -190,13 +193,12 @@
{
MailCheck *mc = data;
- if (mc->cmd){
+ if (mc->cmd && (strlen(mc->cmd) > 0)) {
/*
* if we have to execute a command before checking for mail, we
* remove the mail-check timeout and re-add it after the command
* returns, just in case the execution takes too long.
*/
-
gtk_timeout_remove (mc->mail_timeout);
if (system(mc->cmd) == 127)
g_warning("Couldn't execute command");
@@ -271,6 +273,15 @@
return TRUE;
}
+static gint
+exec_mail_prog (GtkWidget *widget, GdkEvent *evt, gpointer data)
+{
+ MailCheck *mc = data;
+ if (mc->mail_prog_cmd && (strlen(mc->mail_prog_cmd)) > 0)
+ gnome_execute_shell(NULL, mc->mail_prog_cmd);
+ return TRUE;
+}
+
static void
mailcheck_destroy (GtkWidget *widget, gpointer data)
{
@@ -283,6 +294,9 @@
if(mc->cmd)
g_free (mc->cmd);
+ if (mc->mail_prog_cmd)
+ g_free(mc->mail_prog_cmd);
+
gtk_timeout_remove (mc->mail_timeout);
}
@@ -290,7 +304,6 @@
create_mail_widgets (MailCheck *mc)
{
char *fname = mail_animation_filename (mc);
-
mc->bin = gtk_hbox_new (0, 0);
/*
@@ -488,6 +501,16 @@
if (strlen (text) > 0)
mc->cmd = g_strdup (text);
+ if (mc->mail_prog_cmd) {
+ g_free(mc->mail_prog_cmd);
+ mc->mail_prog_cmd = NULL;
+ }
+
+ text = gtk_entry_get_text (GTK_ENTRY(mc->mail_prog_entry));
+
+ if (strlen(text) > 0)
+ mc->mail_prog_cmd = g_strdup(text);
+
if (mc->anim_changed)
load_new_pixmap (mc);
@@ -523,7 +546,28 @@
l = gtk_label_new(_("before each update"));
gtk_widget_show(l);
gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ l = gtk_label_new (_("Execute"));
+ gtk_widget_show(l);
+ gtk_box_pack_start(GTK_BOX(hbox), l, FALSE, FALSE, 0);
+
+ mc->mail_prog_entry = gtk_entry_new();
+ if(mc->mail_prog_cmd) {
+ gtk_entry_set_text(GTK_ENTRY(mc->mail_prog_entry),
+ mc->mail_prog_cmd);
+ }
+ gtk_signal_connect(GTK_OBJECT(mc->mail_prog_entry), "changed",
+ GTK_SIGNAL_FUNC(property_box_changed), mc);
+ gtk_widget_show(mc->mail_prog_entry);
+ gtk_box_pack_start (GTK_BOX (hbox), mc->mail_prog_entry, FALSE, FALSE, 0);
+ l = gtk_label_new (_("when clicked."));
+ gtk_widget_show(l);
+ gtk_box_pack_start(GTK_BOX(hbox), l, FALSE, FALSE, 0);
+
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
@@ -609,6 +653,8 @@
gnome_config_set_int("mail/update_frequency", mc->update_freq);
gnome_config_set_string("mail/exec_command",
mc->cmd?mc->cmd:"");
+ gnome_config_set_string("mail/mail_prog_command",
+ mc->mail_prog_cmd?mc->mail_prog_cmd:"");
gnome_config_pop_prefix();
gnome_config_sync();
@@ -640,6 +686,7 @@
make_mailcheck_applet(const gchar *goad_id)
{
GtkWidget *mailcheck;
+
MailCheck *mc;
char *emailfile;
char *query;
@@ -688,13 +735,25 @@
mc->cmd = gnome_config_get_string(query);
g_free(query);
+ query = g_strconcat(APPLET_WIDGET(applet)->privcfgpath,
+ "mail/mail_prog_command", NULL);
+ mc->mail_prog_cmd = gnome_config_get_string(query);
+ g_free(query);
+
if(emailfile) g_free(emailfile);
mc->mailcheck_text_only = _("Text only");
mailcheck = create_mail_widgets (mc);
gtk_widget_show(mailcheck);
applet_widget_add (APPLET_WIDGET (applet), mailcheck);
- gtk_widget_show (applet);
+
+ gtk_widget_set_events(GTK_WIDGET(applet),
+ gtk_widget_get_events(GTK_WIDGET(applet)) |
+ GDK_BUTTON_PRESS_MASK);
+
+ gtk_signal_connect(GTK_OBJECT(applet), "button_press_event",
+ GTK_SIGNAL_FUNC(exec_mail_prog), mc);
+
gtk_signal_connect(GTK_OBJECT(applet),"save_session",
GTK_SIGNAL_FUNC(applet_save_session),
mc);
@@ -712,5 +771,7 @@
_("About..."),
mailcheck_about,
NULL);
+ gtk_widget_show (applet);
+
return applet;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]