diff options
Diffstat (limited to 'src/fe-gtk/fe-gtk.c')
-rw-r--r-- | src/fe-gtk/fe-gtk.c | 70 |
1 files changed, 31 insertions, 39 deletions
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 4b7d916f..8c163eb7 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -52,6 +52,7 @@ #include "plugin-tray.h" #include "urlgrab.h" #include "setup.h" +#include "plugin-notification.h" #ifdef USE_LIBCANBERRA #include <canberra.h> @@ -224,7 +225,7 @@ fe_args (int argc, char *argv[]) /* cuts can. So we have to set the current dir manually, to the path */ /* of the exe. */ { - char *tmp = strdup (argv[0]); + char *tmp = g_strdup (argv[0]); char *sl; sl = strrchr (tmp, G_DIR_SEPARATOR); @@ -233,7 +234,7 @@ fe_args (int argc, char *argv[]) *sl = 0; chdir (tmp); } - free (tmp); + g_free (tmp); } #endif @@ -265,7 +266,7 @@ create_input_style (GtkStyle *style) /* fall back */ if (pango_font_description_get_size (style->font_desc) == 0) { - snprintf (buf, sizeof (buf), _("Failed to open font:\n\n%s"), prefs.hex_text_font); + g_snprintf (buf, sizeof (buf), _("Failed to open font:\n\n%s"), prefs.hex_text_font); fe_message (buf, FE_MSG_ERROR); pango_font_description_free (style->font_desc); style->font_desc = pango_font_description_from_string ("sans 11"); @@ -381,6 +382,8 @@ fe_idle (gpointer data) { session *sess = sess_list->data; + plugin_add (sess, NULL, NULL, notification_plugin_init, notification_plugin_deinit, NULL, FALSE); + plugin_add (sess, NULL, NULL, tray_plugin_init, tray_plugin_deinit, NULL, FALSE); if (arg_minimize == 1) @@ -424,8 +427,7 @@ fe_new_window (session *sess, int focus) void fe_new_server (struct server *serv) { - serv->gui = malloc (sizeof (struct server_gui)); - memset (serv->gui, 0, sizeof (struct server_gui)); + serv->gui = g_new0 (struct server_gui, 1); } void @@ -510,18 +512,15 @@ fe_set_topic (session *sess, char *topic, char *stripped_topic) } else { - if (sess->res->topic_text) - { - free (sess->res->topic_text); - } + g_free (sess->res->topic_text); if (prefs.hex_text_stripcolor_topic) { - sess->res->topic_text = strdup (stripped_topic); + sess->res->topic_text = g_strdup (stripped_topic); } else { - sess->res->topic_text = strdup (topic); + sess->res->topic_text = g_strdup (topic); } } } @@ -547,9 +546,8 @@ fe_update_mode_entry (session *sess, GtkWidget *entry, char **text, char *new_te { if (sess->gui->is_tab) { - if (*text) - free (*text); - *text = strdup (new_text); + g_free (*text); + *text = g_strdup (new_text); } } } @@ -721,7 +719,7 @@ fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_f lbuf->search_lnee = strlen (lbuf->search_nee); } lbuf->search_flags = flags; - lbuf->search_text = strdup (sstr); + lbuf->search_text = g_strdup (sstr); gtk_xtext_lastlog (lbuf, buf); } @@ -751,9 +749,9 @@ fe_set_lag (server *serv, long lag) if (per > 1.0) per = 1.0; - snprintf (lagtext, sizeof (lagtext) - 1, "%s%ld.%lds", + g_snprintf (lagtext, sizeof (lagtext) - 1, "%s%ld.%lds", serv->lag_sent ? "+" : "", lag / 1000, (lag/100) % 10); - snprintf (lagtip, sizeof (lagtip) - 1, "Lag: %s%ld.%ld seconds", + g_snprintf (lagtip, sizeof (lagtip) - 1, "Lag: %s%ld.%ld seconds", serv->lag_sent ? "+" : "", lag / 1000, (lag/100) % 10); while (list) @@ -761,9 +759,8 @@ fe_set_lag (server *serv, long lag) sess = list->data; if (sess->server == serv) { - if (sess->res->lag_tip) - free (sess->res->lag_tip); - sess->res->lag_tip = strdup (lagtip); + g_free (sess->res->lag_tip); + sess->res->lag_tip = g_strdup (lagtip); if (!sess->gui->is_tab || current_tab == sess) { @@ -777,9 +774,8 @@ fe_set_lag (server *serv, long lag) } else { sess->res->lag_value = per; - if (sess->res->lag_text) - free (sess->res->lag_text); - sess->res->lag_text = strdup (lagtext); + g_free (sess->res->lag_text); + sess->res->lag_text = g_strdup (lagtext); } } list = list->next; @@ -804,12 +800,11 @@ fe_set_throttle (server *serv) sess = list->data; if (sess->server == serv) { - snprintf (tbuf, sizeof (tbuf) - 1, _("%d bytes"), serv->sendq_len); - snprintf (tip, sizeof (tip) - 1, _("Network send queue: %d bytes"), serv->sendq_len); + g_snprintf (tbuf, sizeof (tbuf) - 1, _("%d bytes"), serv->sendq_len); + g_snprintf (tip, sizeof (tip) - 1, _("Network send queue: %d bytes"), serv->sendq_len); - if (sess->res->queue_tip) - free (sess->res->queue_tip); - sess->res->queue_tip = strdup (tip); + g_free (sess->res->queue_tip); + sess->res->queue_tip = g_strdup (tip); if (!sess->gui->is_tab || current_tab == sess) { @@ -823,9 +818,8 @@ fe_set_throttle (server *serv) } else { sess->res->queue_value = per; - if (sess->res->queue_text) - free (sess->res->queue_text); - sess->res->queue_text = strdup (tbuf); + g_free (sess->res->queue_text); + sess->res->queue_text = g_strdup (tbuf); } } list = list->next; @@ -882,11 +876,10 @@ fe_confirm (const char *message, void (*yesproc)(void *), void (*noproc)(void *) { /* warning, assuming fe_confirm is used by DCC only! */ struct DCC *dcc = ud; - char *filepath; if (dcc->file) { - filepath = g_build_filename (prefs.hex_dcc_dir, dcc->file, NULL); + char *filepath = g_build_filename (prefs.hex_dcc_dir, dcc->file, NULL); gtkutil_file_req (message, dcc_saveas_cb, ud, filepath, NULL, FRF_WRITE|FRF_NOASKOVERWRITE|FRF_FILTERISINITIAL); g_free (filepath); @@ -978,9 +971,8 @@ fe_set_inputbox_contents (session *sess, char *text) SPELL_ENTRY_SET_TEXT (sess->gui->input_box, text); } else { - if (sess->res->input_text) - free (sess->res->input_text); - sess->res->input_text = strdup (text); + g_free (sess->res->input_text); + sess->res->input_text = g_strdup (text); } } @@ -1092,9 +1084,9 @@ fe_open_url (const char *url) /* the http:// part's missing, prepend it, otherwise it won't always work */ else if (strchr (url, ':') == NULL) { - url = g_strdup_printf ("http://%s", url); - fe_open_url_inner (url); - g_free ((char *)url); + uri = g_strdup_printf ("http://%s", url); + fe_open_url_inner (uri); + g_free (uri); } /* we have a sane URL, send it to the browser untouched */ else |