pidgin  2.13.0
About: Pidgin is a chat program (multi-protocol instant messaging client) which lets you log in to accounts on multiple chat networks simultaneously (old name "gaim").
  Fossies Dox: pidgin-2.13.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

gntmain.c File Reference
#include "config.h"
#include <gmodule.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "gntinternal.h"
#include "gnt.h"
#include "gntbox.h"
#include "gntbutton.h"
#include "gntcolors.h"
#include "gntclipboard.h"
#include "gntkeys.h"
#include "gntlabel.h"
#include "gntmenu.h"
#include "gntstyle.h"
#include "gnttree.h"
#include "gntutils.h"
#include "gntwindow.h"
#include "gntwm.h"
#include <panel.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
Include dependency graph for gntmain.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define GNT_LOG_DOMAIN   "Main"
 
#define HOLDING_ESCAPE   (escape_stuff.timer != 0)
 

Functions

static void setup_io (void)
 
static gboolean refresh_screen (void)
 
static gboolean escape_timeout (gpointer data)
 
static gboolean detect_mouse_action (const char *buffer)
 
static gboolean io_invoke_error (GIOChannel *source, GIOCondition cond, gpointer data)
 
static gboolean io_invoke (GIOChannel *source, GIOCondition cond, gpointer null)
 
static void clean_pid (void)
 
static void exit_confirmed (gpointer null)
 
static void exit_win_close (GntWidget *w, GntWidget **win)
 
static void ask_before_exit (void)
 
static void sighandler (int sig, siginfo_t *info, void *data)
 
static void init_wm (void)
 
void gnt_init ()
 
void gnt_main ()
 
void gnt_window_present (GntWidget *window)
 
void gnt_screen_occupy (GntWidget *widget)
 
void gnt_screen_release (GntWidget *widget)
 
void gnt_screen_update (GntWidget *widget)
 
gboolean gnt_widget_has_focus (GntWidget *widget)
 
void gnt_widget_set_urgent (GntWidget *widget)
 
void gnt_quit ()
 
gboolean gnt_ascii_only ()
 
void gnt_screen_resize_widget (GntWidget *widget, int width, int height)
 
void gnt_screen_move_widget (GntWidget *widget, int x, int y)
 
void gnt_screen_rename_widget (GntWidget *widget, const char *text)
 
void gnt_register_action (const char *label, void(*callback)(void))
 
static void reset_menu (GntWidget *widget, gpointer null)
 
gboolean gnt_screen_menu_show (gpointer newmenu)
 
void gnt_set_clipboard_string (const gchar *string)
 
GntClipboardgnt_get_clipboard ()
 
gchar * gnt_get_clipboard_string ()
 
gboolean gnt_giveup_console (const char *wd, char **argv, char **envp, gint *stin, gint *stout, gint *sterr, void(*callback)(int status, gpointer data), gpointer data)
 
gboolean gnt_is_refugee ()
 
const char * C_ (const char *x)
 

Variables

static GIOChannel * channel = NULL
 
static guint channel_read_callback = 0
 
static guint channel_error_callback = 0
 
static gboolean ascii_only
 
static gboolean mouse_enabled
 
static GntWMwm
 
static GntClipboardclipboard
 
int gnt_need_conversation_to_locale
 
struct {
   int   timer
 
escape_stuff
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

GNT - The GLib Ncurses Toolkit

GNT is the legal property of its developers, whose names are too numerous to list here. Please refer to the COPYRIGHT file distributed with this source distribution.

This library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA

Definition at line 23 of file gntmain.c.

◆ GNT_LOG_DOMAIN

#define GNT_LOG_DOMAIN   "Main"

Definition at line 37 of file gntmain.c.

◆ HOLDING_ESCAPE

#define HOLDING_ESCAPE   (escape_stuff.timer != 0)

Definition at line 87 of file gntmain.c.

Function Documentation

◆ ask_before_exit()

◆ C_()

◆ clean_pid()

static void clean_pid ( void  )
static

Definition at line 341 of file gntmain.c.

References status.

Referenced by sighandler().

◆ detect_mouse_action()

static gboolean detect_mouse_action ( const char *  buffer)
static

Mouse support:

  • bring a window on top if you click on its taskbar
  • click on the top-bar of the active window and drag+drop to move a window
  • click on a window to bring it to focus
    • allow scrolling in tree/textview on wheel-scroll event
    • click to activate button or select a row in tree wishlist:
    • have a little [X] on the windows, and clicking it will close that window.

Definition at line 112 of file gntmain.c.

References _GntWM::_list, _GntWM::cws, FALSE, GNT_BINDABLE, gnt_bindable_perform_action_named(), GNT_LEFT_MOUSE_DOWN, GNT_MIDDLE_MOUSE_DOWN, GNT_MOUSE_SCROLL_DOWN, GNT_MOUSE_SCROLL_UP, GNT_MOUSE_UP, GNT_RIGHT_MOUSE_DOWN, gnt_screen_move_widget(), gnt_widget_clicked(), GNT_WIDGET_IS_FLAG_SET, GNT_WIDGET_TRANSIENT, gnt_wm_process_click(), gnt_wm_raise_window(), _GntWidgetPriv::height, _GntWS::list, dbus-buddyicons-example::node, NULL, _GntWS::ordered, _GntWidget::priv, TRUE, widget, _GntWidgetPriv::width, _GntWM::window, wm, _GntWidgetPriv::x, and _GntWidgetPriv::y.

Referenced by io_invoke().

◆ escape_timeout()

static gboolean escape_timeout ( gpointer  data)
static

Definition at line 94 of file gntmain.c.

References escape_stuff, FALSE, gnt_wm_process_input(), and wm.

Referenced by io_invoke().

◆ exit_confirmed()

static void exit_confirmed ( gpointer  null)
static

Definition at line 358 of file gntmain.c.

References GNT_BINDABLE, gnt_bindable_perform_action_named(), NULL, and wm.

Referenced by ask_before_exit().

◆ exit_win_close()

static void exit_win_close ( GntWidget w,
GntWidget **  win 
)
static

Definition at line 364 of file gntmain.c.

References NULL.

Referenced by ask_before_exit().

◆ gnt_ascii_only()

gboolean gnt_ascii_only ( void  )

Check whether the terminal is capable of UTF8 display.

Returns
FALSE if the terminal is capable of drawing UTF-8, TRUE otherwise.

Definition at line 628 of file gntmain.c.

References ascii_only.

Referenced by get_display_name(), gnt_entry_draw(), update_buddy_typing(), and update_row_text().

◆ gnt_get_clipboard()

GntClipboard* gnt_get_clipboard ( void  )

Get the global clipboard.

Returns
The clipboard.

Definition at line 688 of file gntmain.c.

References clipboard.

Referenced by plugin_load(), and plugin_unload().

◆ gnt_get_clipboard_string()

gchar* gnt_get_clipboard_string ( void  )

Get the string in the clipboard.

Returns
A copy of the string in the clipboard. The caller must g_free the string.

Definition at line 693 of file gntmain.c.

References clipboard, and gnt_clipboard_get_string().

Referenced by clipboard_paste(), and toggle_clipboard().

◆ gnt_giveup_console()

gboolean gnt_giveup_console ( const char *  wd,
char **  argv,
char **  envp,
gint *  stin,
gint *  stout,
gint *  sterr,
void(*)(int status, gpointer data callback,
gpointer  data 
)

Spawn a different application that will consume the console.

Parameters
wdThe working directory for the new application.
argvThe argument vector.
envpThe environment, or NULL.
stinLocation to store the child's stdin, or NULL.
stoutLocation to store the child's stdout, or NULL.
sterrLocation to store the child's stderr, or NULL.
callbackThe callback to call after the child exits.
dataThe data to pass to the callback.
Returns
TRUE if the child was successfully spawned, FALSE otherwise.

Definition at line 722 of file gntmain.c.

References channel_read_callback, data, FALSE, GNT_KP_MODE_WAIT_ON_CHILD, _GntWM::mode, NULL, TRUE, and wm.

Referenced by check_for_ext_cb().

◆ gnt_init()

◆ gnt_is_refugee()

gboolean gnt_is_refugee ( void  )

Check whether a child process is in control of the current terminal.

Returns
TRUE if a child process (eg., PAGER) is occupying the current terminal, FALSE otherwise.

Definition at line 749 of file gntmain.c.

References FALSE, GNT_KP_MODE_WAIT_ON_CHILD, _GntWM::mode, and wm.

Referenced by gnt_ws_draw_taskbar(), and update_conv_window_title().

◆ gnt_main()

void gnt_main ( void  )

Start running the mainloop for gnt.

Definition at line 539 of file gntmain.c.

References FALSE, _GntWM::loop, NULL, and wm.

Referenced by main().

◆ gnt_quit()

void gnt_quit ( void  )

Terminate the mainloop of gnt.

Definition at line 609 of file gntmain.c.

References channel_error_callback, channel_read_callback, gnt_uninit_colors(), gnt_uninit_styles(), NULL, and wm.

◆ gnt_register_action()

void gnt_register_action ( const char *  label,
void(*)(void)  callback 
)

Register a global action.

Parameters
labelThe user-visible label for the action.
callbackThe callback function for the action.

Definition at line 650 of file gntmain.c.

References _GntWM::acts, _GntAction::callback, _GntAction::label, label, and wm.

Referenced by gnt_ui_init().

◆ gnt_screen_menu_show()

gboolean gnt_screen_menu_show ( gpointer  menu)

Show a menu.

Parameters
menuThe menu to display.
Returns
TRUE if the menu is displayed, FALSE otherwise (e.g., if another menu is currently displayed).

Definition at line 665 of file gntmain.c.

References FALSE, GNT_WIDGET, gnt_widget_draw(), GNT_WIDGET_INVISIBLE, GNT_WIDGET_UNSET_FLAGS, _GntWM::menu, NULL, reset_menu(), TRUE, and wm.

Referenced by draw_context_menu(), and show_menu().

◆ gnt_screen_move_widget()

void gnt_screen_move_widget ( GntWidget widget,
int  x,
int  y 
)

Move a widget.

Parameters
widgetThe widget to move.
xThe desired x-coordinate.
yThe desired y-coordinate.

Definition at line 638 of file gntmain.c.

References gnt_wm_move_window(), widget, and wm.

Referenced by detect_mouse_action(), gnt_wm_process_input(), refresh_node(), and remove_toaster().

◆ gnt_screen_occupy()

void gnt_screen_occupy ( GntWidget widget)

Definition at line 556 of file gntmain.c.

References gnt_wm_new_window(), widget, and wm.

Referenced by gnt_widget_show().

◆ gnt_screen_release()

void gnt_screen_release ( GntWidget widget)

Definition at line 561 of file gntmain.c.

References gnt_wm_window_close(), widget, and wm.

Referenced by finch_request_authorize(), gnt_box_destroy(), and gnt_widget_hide().

◆ gnt_screen_rename_widget()

void gnt_screen_rename_widget ( GntWidget widget,
const char *  text 
)

Rename a widget.

Parameters
widgetThe widget to rename.
textThe new name for the widget.

Definition at line 643 of file gntmain.c.

References GNT_BOX, gnt_box_set_title(), gnt_widget_draw(), gnt_wm_update_window(), text, widget, and wm.

Referenced by finch_conversation_set_active(), update_buddy_typing(), and update_title_progress().

◆ gnt_screen_resize_widget()

void gnt_screen_resize_widget ( GntWidget widget,
int  width,
int  height 
)

Resize a widget.

Parameters
widgetThe widget to resize.
widthThe desired width.
heightThe desired height.

Definition at line 633 of file gntmain.c.

References gnt_wm_resize_window(), widget, and wm.

Referenced by finch_conversation_set_info_widget(), finch_notify_userinfo(), fl_show_with_account(), gnt_box_readjust(), gnt_wm_process_input(), and refresh_node().

◆ gnt_screen_update()

void gnt_screen_update ( GntWidget widget)

Definition at line 567 of file gntmain.c.

References gnt_wm_update_window(), widget, and wm.

Referenced by update_queue_callback().

◆ gnt_set_clipboard_string()

void gnt_set_clipboard_string ( const gchar *  string)

Set the contents of the global clipboard.

Parameters
stringThe new content of the new clipboard.

Definition at line 683 of file gntmain.c.

References clipboard, and gnt_clipboard_set_string().

Referenced by gnt_text_view_clicked().

◆ gnt_widget_has_focus()

gboolean gnt_widget_has_focus ( GntWidget widget)

◆ gnt_widget_set_urgent()

void gnt_widget_set_urgent ( GntWidget widget)

Set the URGENT hint for a widget.

Parameters
widgetThe widget to set the URGENT hint for.

Definition at line 596 of file gntmain.c.

References _GntWM::cws, GNT_WIDGET_SET_FLAGS, GNT_WIDGET_URGENT, gnt_wm_update_window(), _GntWS::ordered, widget, and wm.

Referenced by finch_write_common(), gnt_window_present(), and gnt_wm_new_window_real().

◆ gnt_window_present()

void gnt_window_present ( GntWidget window)

Present a window. If the event was triggered because of user interaction, the window is moved to the foreground. Otherwise, the Urgent hint is set.

Parameters
windowThe window the present.
Since
2.0.0 (gnt), 2.1.0 (pidgin)

Definition at line 548 of file gntmain.c.

References _GntWM::event_stack, gnt_widget_set_urgent(), gnt_wm_raise_window(), window, and wm.

Referenced by blist_show(), finch_accounts_show_all(), finch_certmgr_show(), finch_conv_present(), finch_create_conversation(), finch_debug_window_show(), finch_log_show(), finch_log_show_contact(), finch_notify_emails(), finch_plugins_show_all(), finch_pounces_manager_show(), finch_prefs_show_all(), finch_savedstatus_show_all(), finch_sounds_show_all(), finch_syslog_show(), fl_show_with_account(), and selection_activate().

◆ init_wm()

static void init_wm ( void  )
static

Definition at line 437 of file gntmain.c.

References gnt_style_get(), GNT_STYLE_WM, GNT_TYPE_WM, handle, name, NULL, and wm.

Referenced by gnt_init().

◆ io_invoke()

static gboolean io_invoke ( GIOChannel *  source,
GIOCondition  cond,
gpointer  null 
)
static

◆ io_invoke_error()

static gboolean io_invoke_error ( GIOChannel *  source,
GIOCondition  cond,
gpointer  data 
)
static

Definition at line 216 of file gntmain.c.

References channel, data, NULL, setup_io(), and TRUE.

Referenced by setup_io().

◆ refresh_screen()

static gboolean refresh_screen ( void  )
static

Definition at line 333 of file gntmain.c.

References FALSE, GNT_BINDABLE, gnt_bindable_perform_action_named(), NULL, and wm.

Referenced by sighandler().

◆ reset_menu()

static void reset_menu ( GntWidget widget,
gpointer  null 
)
static

Definition at line 660 of file gntmain.c.

References _GntWM::menu, NULL, and wm.

Referenced by gnt_screen_menu_show().

◆ setup_io()

static void setup_io ( void  )
static

◆ sighandler()

static void sighandler ( int  sig,
siginfo_t *  info,
void *  data 
)
static

Definition at line 414 of file gntmain.c.

References ask_before_exit(), clean_pid(), data, info, NULL, and refresh_screen().

Referenced by gnt_init(), and main().

Variable Documentation

◆ ascii_only

gboolean ascii_only
static

Definition at line 75 of file gntmain.c.

Referenced by gnt_ascii_only(), and gnt_init().

◆ channel

◆ channel_error_callback

guint channel_error_callback = 0
static

Definition at line 73 of file gntmain.c.

Referenced by gnt_quit(), and setup_io().

◆ channel_read_callback

guint channel_read_callback = 0
static

Definition at line 72 of file gntmain.c.

Referenced by gnt_giveup_console(), gnt_quit(), and setup_io().

◆ clipboard

◆ escape_stuff

struct { ... } escape_stuff

Referenced by escape_timeout(), and io_invoke().

◆ gnt_need_conversation_to_locale

int gnt_need_conversation_to_locale

Definition at line 85 of file gntmain.c.

Referenced by C_(), and gnt_init().

◆ mouse_enabled

gboolean mouse_enabled
static

Definition at line 76 of file gntmain.c.

Referenced by gnt_init(), and io_invoke().

◆ timer

int timer

Definition at line 90 of file gntmain.c.

Referenced by hide_conv(), and pidgin_conv_attach_to_conversation().

◆ wm

GntWM* wm
static

Definition at line 82 of file gntmain.c.

Referenced by action_list_activate(), ask_before_exit(), destroy__list(), detect_mouse_action(), ensure_normal_mode(), escape_timeout(), exit_confirmed(), find_widget(), gnt_giveup_console(), gnt_is_refugee(), gnt_main(), gnt_quit(), gnt_register_action(), gnt_screen_menu_show(), gnt_screen_move_widget(), gnt_screen_occupy(), gnt_screen_release(), gnt_screen_rename_widget(), gnt_screen_resize_widget(), gnt_screen_update(), gnt_style_read_workspaces(), gnt_widget_has_focus(), gnt_widget_set_urgent(), gnt_window_present(), gnt_wm_add_workspace(), gnt_wm_destroy(), gnt_wm_give_focus(), gnt_wm_init(), gnt_wm_move_window(), gnt_wm_new_window(), gnt_wm_new_window_real(), gnt_wm_process_click(), gnt_wm_process_input(), gnt_wm_raise_window(), gnt_wm_resize_window(), gnt_wm_set_event_stack(), gnt_wm_set_workspaces(), gnt_wm_switch_workspace(), gnt_wm_switch_workspace_next(), gnt_wm_switch_workspace_prev(), gnt_wm_update_window(), gnt_wm_widget_find_workspace(), gnt_wm_widget_move_workspace(), gnt_wm_window_close(), gnt_wm_window_decorate(), gntwm_init(), help_for_bindable(), help_for_widget(), help_for_window(), ignore_keys_start(), init_wm(), io_invoke(), irssi_close_window(), irssi_new_window(), irssi_terminal_refresh(), irssi_update_window(), irssi_window_resized(), list_actions(), list_of_windows(), move_direction(), new_widget_find_workspace(), place_tagged(), populate_window_list(), read_window_positions(), refresh_screen(), remove_tag(), reset_menu(), s_new_window(), s_window_update(), setup__list(), shift_left(), shift_right(), shift_window(), start_move(), start_resize(), switch_window(), switch_window_n(), tag_widget(), toggle_buddylist(), update_screen(), update_window_in_list(), widget_move_ws(), window_close(), window_list(), window_list_activate(), window_list_key_pressed(), window_next(), window_next_urgent(), window_prev(), window_prev_urgent(), window_reverse(), window_scroll_down(), window_scroll_up(), wm_quit(), workspace_list(), workspace_new(), workspace_next(), workspace_prev(), write_already(), and write_positions_to_file().