Merge pull request #90 from ZoiteChat/code-cleanup

Code cleanup
This commit is contained in:
deepend-tildeclub
2026-02-25 18:16:54 -07:00
committed by GitHub
48 changed files with 73 additions and 335 deletions

View File

@@ -190,11 +190,11 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
gtk_adjustment_set_value (adj, new_value);
tab_left_is_moving = 0; /* hSP: set to false in case we didnt get stopped (the normal case) */
tab_left_is_moving = 0;
}
else
{
tab_left_is_moving = 0; /* hSP: jump directly to next element if user is clicking faster than we can scroll.. */
tab_left_is_moving = 0;
}
}
@@ -239,11 +239,11 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
gtk_adjustment_set_value (adj, new_value);
tab_right_is_moving = 0; /* hSP: set to false in case we didnt get stopped (the normal case) */
tab_right_is_moving = 0;
}
else
{
tab_right_is_moving = 0; /* hSP: jump directly to next element if user is clicking faster than we can scroll.. */
tab_right_is_moving = 0;
}
}
@@ -332,7 +332,6 @@ cv_tabs_init (chanview *cv)
((tabview *)cv)->outer = outer;
g_signal_connect (G_OBJECT (outer), "size_allocate",
G_CALLBACK (cv_tabs_sizealloc), cv);
/* gtk_container_set_border_width (GTK_CONTAINER (outer), 2);*/
gtk_widget_show (outer);
viewport = gtk_viewport_new (0, 0);
@@ -574,7 +573,7 @@ tab_pressed_cb (GtkToggleButton *tab, chan *ch)
ignore_toggle = FALSE;
cv->focused = ch;
if (/*tab->active*/is_switching)
if (is_switching)
/* call the focus callback */
cv->cb_focus (cv, ch, ch->tag, ch->userdata);
}

View File

@@ -925,8 +925,6 @@ fe_main (void)
void
fe_cleanup (void)
{
/* it's saved when pressing OK in setup.c */
/*palette_save ();*/
}
void
@@ -963,8 +961,7 @@ log_handler (const gchar *log_domain,
{
session *sess;
/* if (getenv ("ZOITECHAT_WARNING_IGNORE")) this gets ignored sometimes, so simply just disable all warnings */
return;
return;
sess = find_dialog (serv_list->data, "(warnings)");
if (!sess)
@@ -977,8 +974,6 @@ log_handler (const gchar *log_domain,
#endif
/* install tray stuff */
static int
fe_idle (gpointer data)
{

View File

@@ -1199,11 +1199,6 @@ corrupt_file:
return 5;
}
/* ***** Key actions start here *********** */
/* See the NOTES above --AGL */
/* "Run command" */
static int
key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, char *d1,
char *d2, struct session *sess)
@@ -1224,7 +1219,6 @@ key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, char *d1,
/*
* Check if the given session is inside the main window. This predicate
* is passed to lastact_getfirst() as a way to filter out detached sessions.
* XXX: Consider moving this in a different file?
*/
static int
session_check_is_tab(session *sess)
@@ -1806,7 +1800,7 @@ key_action_move_tab_left (GtkWidget * wid, GdkEventKey * ent, char *d1,
char *d2, struct session *sess)
{
mg_move_tab (sess, +1);
return 2; /* don't allow default action */
return 2;
}
static int
@@ -1814,7 +1808,7 @@ key_action_move_tab_right (GtkWidget * wid, GdkEventKey * ent, char *d1,
char *d2, struct session *sess)
{
mg_move_tab (sess, -1);
return 2; /* -''- */
return 2;
}
static int
@@ -1822,7 +1816,7 @@ key_action_move_tab_family_left (GtkWidget * wid, GdkEventKey * ent, char *d1,
char *d2, struct session *sess)
{
mg_move_tab_family (sess, +1);
return 2; /* don't allow default action */
return 2;
}
static int
@@ -1830,7 +1824,7 @@ key_action_move_tab_family_right (GtkWidget * wid, GdkEventKey * ent, char *d1,
char *d2, struct session *sess)
{
mg_move_tab_family (sess, -1);
return 2; /* -''- */
return 2;
}
static int
@@ -1839,12 +1833,9 @@ key_action_put_history (GtkWidget * wid, GdkEventKey * ent, char *d1,
{
history_add (&sess->history, SPELL_ENTRY_GET_TEXT (wid));
SPELL_ENTRY_SET_TEXT (wid, "");
return 2; /* -''- */
return 2;
}
/* -------- */
static void
replace_handle (GtkWidget *t)
{

View File

@@ -668,8 +668,6 @@ static void
gtkutil_file_req_done (GtkWidget * wid, struct file_req *freq)
{
gtkutil_file_req_done_chooser (GTK_FILE_CHOOSER (freq->dialog), freq);
/* this should call the "destroy" cb, where we free(freq) */
gtk_widget_destroy (freq->dialog);
}
@@ -682,7 +680,6 @@ gtkutil_file_req_response (GtkWidget *dialog, gint res, struct file_req *freq)
return;
}
/* this should call the "destroy" cb, where we free(freq) */
gtk_widget_destroy (dialog);
}
@@ -1360,16 +1357,6 @@ gtkutil_treemodel_string_to_iter (GtkTreeModel *model, gchar *pathstr, GtkTreeIt
return success;
}
/*gboolean
gtkutil_treeview_get_selected_iter (GtkTreeView *view, GtkTreeIter *iter_ret)
{
GtkTreeModel *store;
GtkTreeSelection *select;
select = gtk_tree_view_get_selection (view);
return gtk_tree_selection_get_selected (select, &store, iter_ret);
}*/
gboolean
gtkutil_treeview_get_selected (GtkTreeView *view, GtkTreeIter *iter_ret, ...)
{

View File

@@ -81,11 +81,9 @@ joind_ok_cb (GtkWidget *ok, server *serv)
return;
}
/* do nothing */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (serv->gui->joind_radio1)))
goto xit;
/* join specific channel */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (serv->gui->joind_radio2)))
{
char *text = (char *)gtk_entry_get_text (GTK_ENTRY (serv->gui->joind_entry));
@@ -98,7 +96,6 @@ joind_ok_cb (GtkWidget *ok, server *serv)
goto xit;
}
/* channel list */
chanlist_opengui (serv, TRUE);
xit:

View File

@@ -1278,7 +1278,6 @@ mg_switch_page (int relative, int num)
static void
mg_topdestroy_cb (GtkWidget *win, session *sess)
{
/* printf("enter mg_topdestroy. sess %p was destroyed\n", sess);*/
session_free (sess); /* tell zoitechat.c about it */
}
@@ -1293,7 +1292,6 @@ mg_ircdestroy (session *sess)
if (mg_gui == NULL)
{
/* puts("-> mg_gui is already NULL");*/
return;
}
@@ -1303,13 +1301,11 @@ mg_ircdestroy (session *sess)
sess = list->data;
if (sess->gui->is_tab)
{
/* puts("-> some tabs still remain");*/
return;
}
list = list->next;
}
/* puts("-> no tabs left, killing main tabwindow");*/
gtk_widget_destroy (mg_gui->window);
active_tab = NULL;
mg_gui = NULL;
@@ -2089,7 +2085,6 @@ mg_tabwindow_kill_cb (GtkWidget *win, gpointer userdata)
GSList *list, *next;
session *sess;
/* puts("enter mg_tabwindow_kill_cb");*/
zoitechat_is_quitting = TRUE;
/* see if there's any non-tab windows left */
@@ -2101,7 +2096,6 @@ mg_tabwindow_kill_cb (GtkWidget *win, gpointer userdata)
if (!sess->gui->is_tab)
{
zoitechat_is_quitting = FALSE;
/* puts("-> will not exit, some toplevel windows left");*/
} else
{
mg_ircdestroy (sess);
@@ -2135,7 +2129,6 @@ mg_changui_destroy (session *sess)
/* avoid calling the "destroy" callback */
g_signal_handlers_disconnect_by_func (G_OBJECT (sess->gui->window),
mg_topdestroy_cb, sess);
/*gtk_widget_destroy (sess->gui->window);*/
/* don't destroy until the new one is created. Not sure why, but */
/* it fixes: Gdk-CRITICAL **: gdk_colormap_get_screen: */
/* assertion `GDK_IS_COLORMAP (cmap)' failed */

View File

@@ -77,12 +77,6 @@ if host_machine.system() == 'windows'
zoitechat_gtk_sources += 'notifications/notification-windows.c'
zoitechat_gtk_deps += cc.find_library('dwmapi', required: true)
# TODO: mingw doesn't have these headers or libs
# add_languages('cpp')
# shared_module('hcnotifications-winrt',
# sources: 'notifications/notification-winrt.cpp'
#)
else
zoitechat_gtk_sources += 'notifications/notification-freedesktop.c'
endif
@@ -102,7 +96,7 @@ endif
resources = gnome.compile_resources('resources',
'../../data/zoitechat.gresource.xml',
source_dir: '../../data', # TODO: Fix upstream
source_dir: '../../data',
c_name: 'zoitechat',
extra_args: ['--manual-register']
)

View File

@@ -66,7 +66,6 @@ extern "C"
node_list->GetAt (1)->AppendChild (
toastTemplate->CreateTextNode (Platform::StringReference (wtext.c_str (), wtext.size ())));
// Mute sound, we already play our own
auto node = toastTemplate->SelectSingleNode (L"/toast");
auto audio_elem = toastTemplate->CreateElement (L"audio");
audio_elem->SetAttribute (L"silent", L"true");

View File

@@ -168,7 +168,6 @@ load_pixmap (const char *filename)
g_free (path);
}
// Hack to avoid unbearably tiny icons on HiDPI screens.
scale = g_getenv ("GDK_SCALE");
if (scale)
{

View File

@@ -80,7 +80,6 @@ show_notification (const char *title, const char *text)
{
char *stripped_title, *stripped_text;
/* Strip all colors */
stripped_title = zoitechat_strip (ph, title, -1, 7);
stripped_text = zoitechat_strip (ph, text, -1, 7);
@@ -125,13 +124,10 @@ incoming_message_cb (char *word[], gpointer userdata)
flags = zoitechat_list_int(ph, NULL, "flags");
/* Let sure that can alert */
if (should_alert()) {
/* Follow the channel rules if set */
if (!(flags & CHANNEL_FLAG_BALLOON_UNSET)) {
alert = (flags & CHANNEL_FLAG_BALLOON);
} else {
/* Else follow global environment */
alert = (zoitechat_get_prefs(ph, "input_balloon_chans", NULL, &message) == 3 && message);
}
}
@@ -151,13 +147,10 @@ incoming_priv_cb (char *word[], gpointer userdata)
flags = zoitechat_list_int(ph, NULL, "flags");
/* Let sure that can alert */
if (should_alert()) {
/* Follow the private rules if set */
if (!(flags & CHANNEL_FLAG_BALLOON_UNSET)) {
alert = (flags & CHANNEL_FLAG_BALLOON);
} else {
/* Else follow global environment */
alert = (zoitechat_get_prefs(ph, "input_balloon_priv", NULL, &priv) == 3 && priv);
}
}
@@ -234,7 +227,6 @@ notification_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, c
zoitechat_hook_print (ph, "Private Action", ZOITECHAT_PRI_LOWEST, incoming_priv_cb, NULL);
zoitechat_hook_print (ph, "Private Action to Dialog", ZOITECHAT_PRI_LOWEST, incoming_priv_cb, NULL);
/* Special events treated as priv */
zoitechat_hook_print (ph, "Notice", ZOITECHAT_PRI_LOWEST, incoming_priv_cb, GINT_TO_POINTER (1));
zoitechat_hook_print (ph, "Invited", ZOITECHAT_PRI_LOWEST, incoming_priv_cb, GINT_TO_POINTER (2));
zoitechat_hook_print (ph, "DCC Offer", ZOITECHAT_PRI_LOWEST, incoming_priv_cb, GINT_TO_POINTER (3));

View File

@@ -314,15 +314,14 @@ static const char *const noticeposmenu[] =
static const char *const swtype[] =
{
N_("Tabs"), /* 0 tabs */
"", /* 1 reserved */
N_("Tree"), /* 2 tree */
N_("Tabs"),
"",
N_("Tree"),
NULL
};
static const setting tabs_settings[] =
{
/*{ST_HEADER, N_("Channel Switcher"),0,0,0},*/
{ST_RADIO, N_("Switcher type:"),P_OFFINTNL(hex_gui_tab_layout), 0, swtype, 0},
{ST_TOGGLE, N_("Open an extra tab for server messages"), P_OFFINTNL(hex_gui_tab_server), 0, 0, 0},
{ST_TOGGLE, N_("Open a new tab when you receive a private message"), P_OFFINTNL(hex_gui_autoopen_dialog), 0, 0, 0},
@@ -954,7 +953,6 @@ setup_apply_trans (int *tag)
gtk_window_set_opacity (GTK_WINDOW (current_sess->gui->window),
(prefs.hex_gui_transparency / 255.));
/* mg_update_xtext (current_sess->gui->xtext); */
*tag = 0;
return 0;
}
@@ -1000,8 +998,8 @@ setup_create_hscale (GtkWidget *table, int row, const setting *set)
}
static GtkWidget *proxy_user; /* username GtkEntry */
static GtkWidget *proxy_pass; /* password GtkEntry */
static GtkWidget *proxy_user;
static GtkWidget *proxy_pass;
static void
setup_menu_cb (GtkWidget *cbox, const setting *set)

View File

@@ -37,7 +37,6 @@
#define ICON_URLGRAB_COPY "zc-menu-copy"
#define ICON_URLGRAB_SAVE_AS "zc-menu-save-as"
/* model for the URL treeview */
enum
{
URL_COLUMN,
@@ -60,7 +59,6 @@ url_treeview_url_clicked_cb (GtkWidget *view, GdkEventButton *event,
if (!event || !gtk_tree_view_get_path_at_pos (tree, event->x, event->y, &path, 0, 0, 0))
return FALSE;
/* select what they right-clicked on */
sel = gtk_tree_view_get_selection (tree);
gtk_tree_selection_unselect_all (sel);
gtk_tree_selection_select_path (sel, path);
@@ -103,7 +101,6 @@ url_treeview_new (GtkWidget *box)
gtk_widget_set_vexpand (scroll, TRUE);
g_signal_connect (G_OBJECT (view), "button_press_event",
G_CALLBACK (url_treeview_url_clicked_cb), NULL);
/* don't want column headers */
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
gtk_widget_show (view);
return view;
@@ -172,7 +169,6 @@ fe_url_add (const char *urltext)
URL_COLUMN, urltext,
-1);
/* remove any overflow */
if (prefs.hex_url_grabber_limit > 0)
{
valid = gtk_tree_model_iter_nth_child (