static void search_search (session * sess, const gchar *text) { gtk_xtext_search_flags flags; textentry *last; GError *err = NULL; flags = ((prefs.text_search_case_match == 1? case_match: 0) | (prefs.text_search_backward == 1? backward: 0) | (prefs.text_search_highlight_all == 1? highlight: 0) | (prefs.text_search_follow == 1? follow: 0) | (prefs.text_search_regexp == 1? regexp: 0)); if (!is_session (sess)) { fe_message (_("The window you opened this Search " "for doesn't exist anymore."), FE_MSG_ERROR); return; } last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, flags, &err); if (text == NULL || text[0] == 0) { return; } if (err) { fe_message (_(err->message), FE_MSG_ERROR); g_error_free (err); } else if (!last) { fe_message (_("Search hit end, not found."), FE_MSG_ERROR); } }
static void pevent_dialog_update (GtkWidget * wid, GtkWidget * twid) { int len, m; const char *text; char *out; int sig; GtkTreeIter iter; GtkListStore *store; if (!gtkutil_treeview_get_selected (GTK_TREE_VIEW (pevent_dialog_list), &iter, COL_ROW, &sig, -1)) return; text = gtk_entry_get_text (GTK_ENTRY (wid)); len = strlen (text); if (pevt_build_string (text, &out, &m) != 0) { fe_message (_("There was an error parsing the string"), FE_MSG_ERROR); return; } if (m > (te[sig].num_args & 0x7f)) { free (out); out = malloc (4096); snprintf (out, 4096, _("This signal is only passed %d args, $%d is invalid"), te[sig].num_args & 0x7f, m); fe_message (out, FE_MSG_WARN); free (out); return; } store = (GtkListStore *)gtk_tree_view_get_model (GTK_TREE_VIEW (pevent_dialog_list)); gtk_list_store_set (store, &iter, COL_EVENT_TEXT, text, -1); if (pntevts_text[sig]) free (pntevts_text[sig]); if (pntevts[sig]) free (pntevts[sig]); pntevts_text[sig] = malloc (len + 1); memcpy (pntevts_text[sig], text, len + 1); pntevts[sig] = out; out = malloc (len + 2); memcpy (out, text, len + 1); out[len] = '\n'; out[len + 1] = 0; check_special_chars (out, TRUE); PrintTextRaw (GTK_XTEXT (twid)->buffer, out, 0, 0); free (out); /* save this when we exit */ prefs.save_pevents = 1; }
static void search_search (session * sess, const gchar *text) { if (!is_session (sess)) { fe_message (_("The window you opened this Search " "for doesn't exist anymore."), FE_MSG_ERROR); return; } last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, last, case_match, search_backward); if (!last) fe_message (_("Search hit end, not found."), FE_MSG_ERROR); }
void fe_serverlist_open (session *sess) { servlist_sess = sess; /* fix: don't allow multiple serverlist editors, causes issues (crash at worst) */ if (serverlist_win) { fe_message (_("Server Editor is already open."), FE_MSG_ERROR); return; } serverlist_win = servlist_open_networks (); gtkutil_set_icon (serverlist_win); servlist_networks_populate (networks_tree, network_list); g_signal_connect (G_OBJECT (serverlist_win), "delete_event", G_CALLBACK (servlist_delete_cb), 0); g_signal_connect (G_OBJECT (serverlist_win), "configure_event", G_CALLBACK (servlist_configure_cb), 0); g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (networks_tree))), "changed", G_CALLBACK (servlist_network_row_cb), NULL); g_signal_connect (G_OBJECT (networks_tree), "key_press_event", G_CALLBACK (servlist_net_keypress_cb), networks_tree); gtk_widget_show_all (serverlist_win); }
/** * * Performs the actual refresh operations. * */ static void banlist_do_refresh (struct session *sess) { char tbuf[256]; if (sess->server->connected) { GtkListStore *store; gtk_widget_set_sensitive (sess->res->banlist_butRefresh, FALSE); snprintf (tbuf, sizeof tbuf, "XChat: Ban List (%s, %s)", sess->channel, sess->server->servername); mg_set_title (sess->res->banlist_window, tbuf); store = get_store (sess); gtk_list_store_clear (store); handle_command (sess, "ban", FALSE); #ifdef WIN32 if (0) #else if (supports_exempt (sess->server)) #endif { snprintf (tbuf, sizeof (tbuf), "quote mode %s +e", sess->channel); handle_command (sess, tbuf, FALSE); } } else { fe_message (_("Not connected."), FE_MSG_ERROR); } }
static void ignore_store_new (int cancel, char *mask, gpointer data) { if (cancel) return; /* check if it already exists */ if (ignore_exists (mask)) { fe_message (_("That mask already exists."), FE_MSG_ERROR); return; } GtkTreeView *view = static_cast<GtkTreeView *>(g_object_get_data(G_OBJECT(ignorewin), "view")); GtkListStore *store = GTK_LIST_STORE(get_store()); GtkTreeIter iter; ignore::ignore_type flags = ignore::IG_DEFAULTS; ignore_add (mask, flags, TRUE); gtk_list_store_append (store, &iter); /* ignore everything by default */ gtk_list_store_set (store, &iter, 0, mask, 1, TRUE, 2, TRUE, 3, TRUE, 4, TRUE, 5, TRUE, 6, TRUE, 7, FALSE, -1); /* make sure the new row is visible and selected */ GtkTreePathPtr path (gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter)); gtk_tree_view_scroll_to_cell (view, path.get(), NULL, TRUE, 1.0, 0.0); gtk_tree_view_set_cursor (view, path.get(), NULL, FALSE); }
void fe_tray_set_balloon (const char *title, const char *text) { #ifndef WIN32 const char *argv[8]; const char *path; char time[16]; WinStatus ws; /* no balloons if the window is focused */ ws = tray_get_window_status (); if (ws == WS_FOCUSED) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2)) return; /* FIXME: this should close the current balloon */ if (!text) return; #ifdef LIBNOTIFY /* try it via libnotify.so */ if (libnotify_notify_new (title, text, sticon)) return; /* success */ #endif /* try it the crude way */ path = g_find_program_in_path ("notify-send"); if (path) { sprintf(time, "%d000",prefs.input_balloon_time); argv[0] = path; argv[1] = "-i"; argv[2] = "gtk-dialog-info"; if (access (XCHATSHAREDIR"/pixmaps/xchat.png", R_OK) == 0) argv[2] = XCHATSHAREDIR"/pixmaps/xchat.png"; argv[3] = "-t"; argv[4] = time; argv[5] = title; text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP); argv[6] = text; argv[7] = NULL; xchat_execv (argv); g_free ((char *)path); g_free ((char *)text); } else { /* show this error only once */ static unsigned char said_it = FALSE; if (!said_it) { said_it = TRUE; fe_message (_("Cannot find 'notify-send' to open balloon alerts.\nPlease install libnotify."), FE_MSG_ERROR); } } #endif }
static void mask_edited (GtkCellRendererText *render, gchar *path, gchar *newStr, gpointer dat) { GtkListStore *store = GTK_LIST_STORE (get_store ()); GtkTreeIter iter; char *old; int flags; gtkutil_treemodel_string_to_iter (GTK_TREE_MODEL (store), path, &iter); gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &old, -1); if (!strcmp (old, newStr)) /* no change */ ; else if (ignore_exists (newStr)) /* duplicate, ignore */ fe_message (_("That mask already exists."), FE_MSG_ERROR); else { /* delete old mask, and add new one with original flags */ ignore_del (old); flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter); ignore_add (newStr, flags, TRUE); /* update tree */ gtk_list_store_set (store, &iter, MASK_COLUMN, newStr, -1); } g_free (old); }
void conversation_window_update_preferences(ConversationWindow *win) { ConversationWindowPriv *priv_win = (ConversationWindowPriv *) win; g_return_if_fail(win != NULL); g_return_if_fail(priv_win->xtext != NULL); gtk_xtext_set_palette(GTK_XTEXT(priv_win->xtext), colors); gtk_xtext_set_max_indent(GTK_XTEXT(priv_win->xtext), prefs.max_auto_indent); gtk_xtext_set_thin_separator(GTK_XTEXT(priv_win->xtext), prefs.thin_separator); gtk_xtext_set_max_lines(GTK_XTEXT(priv_win->xtext), prefs.max_lines); gtk_xtext_set_wordwrap(GTK_XTEXT(priv_win->xtext), prefs.wordwrap); gtk_xtext_set_show_marker(GTK_XTEXT(priv_win->xtext), prefs.show_marker); gtk_xtext_set_show_separator(GTK_XTEXT(priv_win->xtext), prefs.show_separator); gtk_xtext_set_indent(GTK_XTEXT(priv_win->xtext), prefs.indent_nicks); if (!gtk_xtext_set_font(GTK_XTEXT(priv_win->xtext), prefs.font_normal)) { fe_message ("No font is available", FE_MSG_WAIT | FE_MSG_ERROR); exit(1); } gtk_xtext_refresh(GTK_XTEXT(priv_win->xtext)); }
static void plugingui_unload (GtkWidget * wid, gpointer unused) { char *modname, *file, *buf; GtkTreeView *view; GtkTreeIter iter; view = g_object_get_data (G_OBJECT (plugin_window), "view"); if (!gtkutil_treeview_get_selected (view, &iter, NAME_COLUMN, &modname, FILE_COLUMN, &file, -1)) return; if (g_str_has_suffix (file, "."G_MODULE_SUFFIX)) { if (plugin_kill (modname, FALSE) == 2) fe_message (_("That plugin is refusing to unload.\n"), FE_MSG_ERROR); } else { /* let python.so or perl.so handle it */ buf = malloc (strlen (file) + 10); if (strchr (file, ' ')) sprintf (buf, "UNLOAD \"%s\"", file); else sprintf (buf, "UNLOAD %s", file); handle_command (current_sess, buf, FALSE); free (buf); } g_free (modname); g_free (file); }
static void banlist_crop (GtkWidget * wid, banlist_info *banl) { session *sess = banl->sess; GtkTreeSelection *select; GSList *list = NULL, *node; int num_sel; /* remember which bans are selected */ select = gtk_tree_view_get_selection (get_view (sess)); /* gtk_tree_selected_get_selected_rows() isn't present in gtk 2.0.x */ gtk_tree_selection_selected_foreach (select, banlist_add_selected_cb, &list); num_sel = g_slist_length (list); /* select all, then unselect those that we remembered */ if (num_sel) { gtk_tree_selection_select_all (select); for (node = list; node; node = node->next) gtk_tree_selection_unselect_iter (select, node->data); g_slist_foreach (list, (GFunc)g_free, NULL); g_slist_free (list); banlist_unban (NULL, banl); } else fe_message (_("You must select some bans."), FE_MSG_ERROR); }
static void menu_bar_toggle_cb(void) { menu_bar_toggle(); if (prefs.hidemenu) fe_message(_("The Menubar is now hidden. You can show it again" " by pressing F9 or right-clicking in a blank part of" " the main text area."), FE_MSG_INFO); }
static void gtkutil_check_file (char *file, struct file_req *freq) { struct stat st; int axs = FALSE; char temp[256]; path_part (file, temp, sizeof (temp)); /* check if the file is readable or writable */ if (freq->flags & FRF_WRITE) { if (access (temp, W_OK) == 0) axs = TRUE; } else { if (stat (file, &st) != -1) { if (!S_ISDIR (st.st_mode) || (freq->flags & FRF_CHOOSEFOLDER)) axs = TRUE; } } if (axs) { char *utf8_file; /* convert to UTF8. It might be converted back to locale by server.c's g_convert */ utf8_file = hexchat_filename_to_utf8 (file, -1, NULL, NULL, NULL); if (utf8_file) { freq->callback (freq->userdata, utf8_file); g_free (utf8_file); } else { fe_message ("Filename encoding is corrupt.", FE_MSG_ERROR); } } else { if (freq->flags & FRF_WRITE) fe_message (_("Cannot write to that file."), FE_MSG_ERROR); else fe_message (_("Cannot read that file."), FE_MSG_ERROR); } }
void key_init () { if (key_load_kbs () == 1) { fe_message (_("There was an error loading key" " bindings configuration"), FE_MSG_ERROR); } }
static void check_prefs_dir (void) { char *dir = get_xdir_fs (); if (access (dir, F_OK) != 0) { if (mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR) != 0) fe_message (_("Cannot create ~/.gchat"), FE_MSG_ERROR); } }
void key_init () { keys_root = NULL; if (key_load_kbs (NULL) == 1) { key_load_defaults (); if (key_load_kbs (NULL) == 1) fe_message (_("There was an error loading key" " bindings configuration"), FE_MSG_ERROR); } }
static void check_prefs_dir (void) { char *dir = get_xdir_fs (); if (access (dir, F_OK) != 0) { #ifdef WIN32 if (mkdir (dir) != 0) #else if (mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR) != 0) #endif fe_message (_("Cannot create ~/.xchat2"), FE_MSG_ERROR); } }
static void resume_clicked (GtkWidget * wid, gpointer none) { struct DCC *dcc; char buf[512]; GSList *list; list = dcc_get_selected (); if (!list) return; dcc = list->data; g_slist_free (list); if (dcc->type == TYPE_RECV && !dcc_resume (dcc)) { switch (dcc->resume_error) { case 0: /* unknown error */ fe_message (_("That file is not resumable."), FE_MSG_ERROR); break; case 1: snprintf (buf, sizeof (buf), _( "Cannot access file: %s\n" "%s.\n" "Resuming not possible."), dcc->destfile, errorstring (dcc->resume_errno)); fe_message (buf, FE_MSG_ERROR); break; case 2: fe_message (_("File in download directory is larger " "than file offered. Resuming not possible."), FE_MSG_ERROR); break; case 3: fe_message (_("Cannot resume the same file from two people."), FE_MSG_ERROR); } } }
static void banlist_unban (GtkWidget * wid, struct session *sess) { int num = 0; num += banlist_unban_inner (wid, sess, FALSE); num += banlist_unban_inner (wid, sess, TRUE); if (num < 1) { fe_message (_("You must select some bans."), FE_MSG_ERROR); return; } banlist_do_refresh (sess); }
static void check_prefs_dir (void) { char *dir = get_xdir (); char *msg; if (g_access (dir, F_OK) != 0) { if (g_mkdir (dir, 0700) != 0) { msg = g_strdup_printf ("Cannot create %s", get_xdir ()); fe_message (msg, FE_MSG_ERROR); g_free (msg); } } }
void banlist_opengui (struct session *sess) { GtkWidget *vbox1; GtkWidget *bbox; char tbuf[256]; if (sess->res->banlist_window) { mg_bring_tofront (sess->res->banlist_window); return; } if (sess->type != SESS_CHANNEL) { fe_message (_("You can only open the Ban List window while in a channel tab."), FE_MSG_ERROR); return; } snprintf (tbuf, sizeof tbuf, _("XChat: Ban List (%s)"), sess->server->servername); sess->res->banlist_window = mg_create_generic_tab ("BanList", tbuf, FALSE, TRUE, banlist_closegui, sess, 550, 200, &vbox1, sess->server); /* create banlist view */ sess->res->banlist_treeview = banlist_treeview_new (vbox1); bbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD); gtk_container_set_border_width (GTK_CONTAINER (bbox), 5); gtk_box_pack_end (GTK_BOX (vbox1), bbox, 0, 0, 0); gtk_widget_show (bbox); gtkutil_button (bbox, GTK_STOCK_REMOVE, 0, banlist_unban, sess, _("Remove")); gtkutil_button (bbox, GTK_STOCK_REMOVE, 0, banlist_crop, sess, _("Crop")); gtkutil_button (bbox, GTK_STOCK_CLEAR, 0, banlist_clear, sess, _("Clear")); sess->res->banlist_butRefresh = gtkutil_button (bbox, GTK_STOCK_REFRESH, 0, banlist_refresh, sess, _("Refresh")); banlist_do_refresh (sess); gtk_widget_show (sess->res->banlist_window); }
static void banlist_unban (GtkWidget * wid, banlist_info *banl) { int i, num = 0; for (i = 0; i < MODE_CT; i++) num += banlist_unban_inner (wid, banl, i); /* This really should not occur with the redesign */ if (num < 1) { fe_message (_("You must select some bans."), FE_MSG_ERROR); return; } banlist_do_refresh (banl); }
static void log_open(session *sess) { static bool log_error = FALSE; log_close(sess); sess->logfd = log_open_file(sess->server->servername, sess->channel, server_get_network(sess->server, FALSE)); if (!log_error && sess->logfd == -1) { char message[512]; snprintf(message, sizeof(message), _("* Can't open log file(s) for writing. Check the\n" \ " permissions on %s/xchatlogs"), get_xdir_utf8()); fe_message(message, FE_MSG_WAIT | FE_MSG_ERROR); log_error = TRUE; } }
GdkPixmap * pixmap_load_from_file (char *filename) { char buf[256]; GdkPixmap *pix; if (filename[0] == '\0') return NULL; pix = pixmap_load_from_file_real (filename); if (pix == NULL) { strcpy (buf, "Cannot open:\n\n"); strncpy (buf + 14, filename, sizeof (buf) - 14); buf[sizeof (buf) - 1] = 0; fe_message (buf, FE_MSG_ERROR); } return pix; }
static void plugingui_unload (GtkWidget * wid, gpointer unused) { int len; char *modname, *file, *buf; GtkTreeView *view; GtkTreeIter iter; view = g_object_get_data (G_OBJECT (plugin_window), "view"); if (!gtkutil_treeview_get_selected (view, &iter, NAME_COLUMN, &modname, FILE_COLUMN, &file, -1)) return; len = strlen (file); #ifdef WIN32 if (len > 4 && g_ascii_strcasecmp (file + len - 4, ".dll") == 0) #else #if defined(__hpux) if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".sl") == 0) #else if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".so") == 0) #endif #endif { if (plugin_kill (modname, FALSE) == 2) fe_message (_("That plugin is refusing to unload.\n"), FE_MSG_ERROR); } else { /* let python.so or perl.so handle it */ buf = malloc (strlen (file) + 10); if (strchr (file, ' ')) sprintf (buf, "UNLOAD \"%s\"", file); else sprintf (buf, "UNLOAD %s", file); handle_command (current_sess, buf, FALSE); free (buf); } g_free (modname); g_free (file); }
static void servlist_connect_cb (GtkWidget *button, gpointer userdata) { if (!selected_net) return; if (servlist_savegui () != 0) { fe_message (_("User name and Real name cannot be left blank."), FE_MSG_ERROR); return; } if (!is_session (servlist_sess)) servlist_sess = NULL; else if (servlist_sess->server->connected) servlist_sess = NULL; servlist_connect (servlist_sess, selected_net, TRUE); mg_close_gen(NULL, serverlist_win); }
static void check_prefs_dir (void) { char *dir = get_xdir_fs (); static char *msg = NULL; if (access (dir, F_OK) != 0) { #ifdef WIN32 if (mkdir (dir) != 0) #else if (mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR) != 0) #endif { msg = malloc (strlen (get_xdir_fs ()) + 15); sprintf (msg, "Cannot create %s", get_xdir_fs ()); fe_message (msg, FE_MSG_ERROR); free (msg); } } }
static void log_open (session *sess) { static gboolean log_error = FALSE; log_close (sess); sess->logfd = log_open_file (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); if (!log_error && sess->logfd == -1) { char *message; message = g_strdup_printf (_("* Can't open log file(s) for writing. Check the\npermissions on %s"), log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE))); fe_message (message, FE_MSG_WAIT | FE_MSG_ERROR); g_free (message); log_error = TRUE; } }
/** * * Performs the actual refresh operations. * */ static void banlist_do_refresh (banlist_info *banl) { session *sess = banl->sess; char tbuf[256]; int i; char *tbufp; banlist_sensitize (banl); if (sess->server->connected) { GtkListStore *store; g_snprintf (tbuf, sizeof tbuf, DISPLAY_NAME": Ban List (%s, %s)", sess->channel, sess->server->servername); mg_set_title (banl->window, tbuf); store = get_store (sess); gtk_list_store_clear (store); banl->line_ct = 0; banl->pending = banl->checked; if (banl->pending) { tbufp = tbuf + g_snprintf (tbuf, sizeof tbuf, "quote mode %s +", sess->channel); for (i = 0; i < MODE_CT; i++) if (banl->pending & 1<<i) { *tbufp++ = modes[i].letter; } *tbufp = 0; handle_command (sess, tbuf, FALSE); } } else { fe_message (_("Not connected."), FE_MSG_ERROR); } }
static void chanlist_do_refresh (server *serv) { if (serv->gui->chanlist_flash_tag) { g_source_remove (serv->gui->chanlist_flash_tag); serv->gui->chanlist_flash_tag = 0; } if (!serv->connected) { fe_message (_("Not connected."), FE_MSG_ERROR); return; } custom_list_clear ((CustomList *)GET_MODEL (serv)); gtk_widget_set_sensitive (serv->gui->chanlist_refresh, FALSE); chanlist_data_free (serv); chanlist_reset_counters (serv); /* can we request a list with minusers arg? */ if (serv->use_listargs) { /* yes - it will download faster */ serv->p_list_channels (serv, "", serv->gui->chanlist_minusers); /* don't allow the spin button below this value from now on */ serv->gui->chanlist_minusers_downloaded = serv->gui->chanlist_minusers; } else { /* download all, filter minusers locally only */ serv->p_list_channels (serv, "", 1); serv->gui->chanlist_minusers_downloaded = 1; } /* gtk_spin_button_set_range ((GtkSpinButton *)serv->gui->chanlist_min_spin, serv->gui->chanlist_minusers_downloaded, 999999);*/ }