コード例 #1
2
ファイル: plugin-tray.c プロジェクト: shlomif/hexchat
int
tray_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name,
                  char **plugin_desc, char **plugin_version, char *arg)
{
    /* we need to save this for use with any hexchat_* functions */
    ph = plugin_handle;

    *plugin_name = "";
    *plugin_desc = "";
    *plugin_version = "";

    hexchat_hook_print (ph, "Channel Msg Hilight", -1, tray_hilight_cb, NULL);
    hexchat_hook_print (ph, "Channel Action Hilight", -1, tray_hilight_cb, NULL);

    hexchat_hook_print (ph, "Channel Message", -1, tray_message_cb, NULL);
    hexchat_hook_print (ph, "Channel Action", -1, tray_message_cb, NULL);
    hexchat_hook_print (ph, "Channel Notice", -1, tray_message_cb, NULL);

    hexchat_hook_print (ph, "Private Message", -1, tray_priv_cb, NULL);
    hexchat_hook_print (ph, "Private Message to Dialog", -1, tray_priv_cb, NULL);
    hexchat_hook_print (ph, "Notice", -1, tray_priv_cb, NULL);
    hexchat_hook_print (ph, "Invited", -1, tray_invited_cb, NULL);

    hexchat_hook_print (ph, "DCC Offer", -1, tray_dcc_cb, NULL);

    hexchat_hook_print (ph, "Focus Window", -1, tray_focus_cb, NULL);

    if (prefs.hex_gui_tray && !hextray_mode ())
        tray_init ();

    return 1;       /* return 1 for success */
}
コード例 #2
0
ファイル: main.c プロジェクト: kinnalru/x2wintray
/* main() */
int main(int argc, char** argv)
{
	/* Read settings */
	tray_init();
	read_settings(argc, argv);
	/* Register cleanup and signal handlers */
	atexit(cleanup);
#ifndef WIN32
	signal(SIGUSR1, &request_tray_status_on_signal);
    #ifdef ENABLE_GRACEFUL_EXIT_HACK
	signal(SIGINT, &exit_on_signal);
	signal(SIGTERM, &exit_on_signal);
	signal(SIGPIPE, &exit_on_signal);
    #endif
#endif
	/* Open display */
	if ((tray_data.dpy = XOpenDisplay(settings.display_str)) == NULL) 
		DIE(("could not open display\n"));
	else 
		LOG_TRACE(("Opened dpy %p\n", tray_data.dpy));
#ifdef ENABLE_GRACEFUL_EXIT_HACK
	if ((async_dpy = XOpenDisplay(settings.display_str)) == NULL) 
		DIE(("could not open display\n"));
	else 
		LOG_TRACE(("Opened async dpy %p\n", async_dpy));
#endif
	if (settings.xsync)
		XSynchronize(tray_data.dpy, True);
	x11_trap_errors();
	/* Execute proper main() function */
	if (settings.remote_click_name != NULL) 
		return remote_main(argc, argv);
	else
		return tray_main(argc, argv);
}
コード例 #3
0
ファイル: TrayWindow.c プロジェクト: t3swing/fcitx-clone
Bool CreateTrayWindow() {
    tray_init(dpy, &tray);
    XVisualInfo* vi = tray_get_visual(dpy, &tray);
    Window dock = tray_get_dock(dpy);
    if (vi && vi->visual) {
        Window p = DefaultRootWindow (dpy);
        Colormap colormap = XCreateColormap(dpy, p, vi->visual, AllocNone);
        XSetWindowAttributes wsa;
        wsa.background_pixmap = 0;
        wsa.colormap = colormap;
        wsa.background_pixel = 0;
        wsa.border_pixel = 0;
        tray.window = XCreateWindow(dpy, p, -1, -1, 1, 1,
                0, vi->depth, InputOutput, vi->visual,
                CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa);
    }
    else {
        tray.window = XCreateSimpleWindow (dpy, DefaultRootWindow(dpy), \
            0, 0, 1, 1, 0, \
            BlackPixel (dpy, DefaultScreen (dpy)), \
            WhitePixel (dpy, DefaultScreen (dpy)));
        XSetWindowBackgroundPixmap(dpy, tray.window, ParentRelative);
    }
    if (tray.window == (Window) NULL)
        return False;
    // GNOME, NET WM Specification
    tray_send_opcode(dpy, dock, CurrentTime, SYSTEM_TRAY_REQUEST_DOCK,
            0, 0);

    XSizeHints size_hints;
    size_hints.flags = PWinGravity | PBaseSize;
    size_hints.base_width = 22;
    size_hints.base_height = 22;
    XSetWMNormalHints(dpy, tray.window, &size_hints);

    if (!ProcessTrayIcon(inactive_xpm, &tray.icon[INACTIVE_ICON], &tray.icon_mask[INACTIVE_ICON],
				&tray.picon[INACTIVE_ICON])) {
        fprintf(stderr, "failed to get inactive icon image\n");
        return False;
    }

    if (!ProcessTrayIcon(active_xpm, &tray.icon[ACTIVE_ICON], &tray.icon_mask[ACTIVE_ICON],
				&tray.picon[ACTIVE_ICON])) {
        fprintf(stderr, "failed to get active icon image\n");
        return False;
    }

    /* GCs for copy and drawing on mask */
    XGCValues gv;
    gv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
    gv.background = BlackPixel(dpy, DefaultScreen(dpy));
    tray.gc = XCreateGC(dpy, tray.window, GCBackground|GCForeground, &gv);

	XSetClipMask(dpy, tray.gc, tray.icon_mask[0]);

    XSelectInput (dpy, tray.window, ExposureMask | KeyPressMask | \
            ButtonPressMask | ButtonReleaseMask | StructureNotifyMask \
            | EnterWindowMask | PointerMotionMask | LeaveWindowMask | VisibilityChangeMask);
    return True;
}
コード例 #4
0
ファイル: profanity.c プロジェクト: boothj5/profanity
static void
_init(char *log_level)
{
    setlocale(LC_ALL, "");
    // ignore SIGPIPE
    signal(SIGPIPE, SIG_IGN);
    signal(SIGINT, SIG_IGN);
    signal(SIGTSTP, SIG_IGN);
    signal(SIGWINCH, ui_sigwinch_handler);
    if (pthread_mutex_init(&lock, NULL) != 0) {
        log_error("Mutex init failed");
        exit(1);
    }
    pthread_mutex_lock(&lock);
    files_create_directories();
    log_level_t prof_log_level = log_level_from_string(log_level);
    prefs_load();
    log_init(prof_log_level);
    log_stderr_init(PROF_LEVEL_ERROR);
    if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
            log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
            log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION);
#endif
    } else {
        log_info("Starting Profanity (%s)...", PACKAGE_VERSION);
    }
    chat_log_init();
    groupchat_log_init();
    accounts_load();
    char *theme = prefs_get_string(PREF_THEME);
    theme_init(theme);
    prefs_free_string(theme);
    ui_init();
    session_init();
    cmd_init();
    log_info("Initialising contact list");
    muc_init();
    tlscerts_init();
    scripts_init();
#ifdef HAVE_LIBOTR
    otr_init();
#endif
#ifdef HAVE_LIBGPGME
    p_gpg_init();
#endif
#ifdef HAVE_OMEMO
    omemo_init();
#endif
    atexit(_shutdown);
    plugins_init();
#ifdef HAVE_GTK
    tray_init();
#endif
    inp_nonblocking(TRUE);
    ui_resize();
}
コード例 #5
0
ファイル: gui.c プロジェクト: draekko-rand/fortified
/* [ gui_construct ]
 * Create the GUI
 */
void
gui_construct (void)
{
	GtkWidget *tablabel;
        GtkWidget *statusview_page;
	GtkWidget *hitview_page;
	GtkWidget *policyview_page;

	gchar hostname[40];

	if (!gethostname (hostname, 39))
		Fortified.window = gnome_app_new (PACKAGE, g_strconcat ("Fortified ", hostname, NULL));
	else
		Fortified.window = gnome_app_new (PACKAGE, "Fortified");

	Fortified.ttips = gtk_tooltips_new ();

/* Set up the main window */
	g_signal_connect (G_OBJECT (Fortified.window), "delete_event",
			  G_CALLBACK (close_main_window), NULL);

	gnome_window_icon_set_default_from_file (
		"/usr/share/pixmaps/fortified.png");

	menus_initialize (Fortified.window);

/* The main application is spread out over a set of notebook pages */
	notebook = gtk_notebook_new ();
	gnome_app_set_contents (GNOME_APP (Fortified.window), notebook);

/* Set up the statusview page */
	statusview_page = create_statusview_page ();
	tablabel = gtk_label_new (_("Status"));
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), statusview_page, tablabel);

/* Set up the hitview page */
	hitview_page = create_hitview_page ();
	tablabel = gtk_label_new (_("Events"));
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hitview_page, tablabel);

/* Set up the the policyview pages */
	policyview_page = create_policyview_page ();
	tablabel = gtk_label_new (_("Policy"));
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), policyview_page, tablabel);

	g_signal_connect_after (G_OBJECT (notebook), "switch-page",
			        G_CALLBACK (view_switched_cb), NULL);

	/* FIXME: By making the window non-resizable the expanders collapse properly,
	    but it would be nicer if it worked with a resizable window */
	//gtk_window_set_resizable (GTK_WINDOW (Fortified.window), FALSE);

	/* Show the tray icon */
	if (preferences_get_bool (PREFS_ENABLE_TRAY_ICON))
		tray_init ();
}
コード例 #6
0
ファイル: plugin-tray.c プロジェクト: amalmurali47/hexchat
void
tray_apply_setup (void)
{
	if (sticon)
	{
		if (!prefs.hex_gui_tray)
			tray_cleanup ();
	}
	else
	{
		if (prefs.hex_gui_tray && !unity_mode ())
			tray_init ();
	}
}
コード例 #7
0
ファイル: plugin-tray.c プロジェクト: Babl0lka/XChat
void
tray_apply_setup (void)
{
	if (sticon)
	{
		if (!prefs.gui_tray)
			tray_cleanup ();
	}
	else
	{
		if (prefs.gui_tray)
			tray_init ();
	}
}
コード例 #8
0
ファイル: gft.c プロジェクト: bobrippling/comm
int main(int argc, char **argv)
{
	GError     *error = NULL;
	GtkBuilder *builder;

#if defined(_WIN32) && defined(GFT_USE_MANIFEST)
	{
		INITCOMMONCONTROLSEX tim;
		memset(&tim, 0, sizeof tim);
		tim.dwSize = sizeof tim;
		tim.dwICC = ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES |
								ICC_DATE_CLASSES | ICC_HOTKEY_CLASS | ICC_INTERNET_CLASSES |
								ICC_LISTVIEW_CLASSES | ICC_NATIVEFNTCTL_CLASS |
								ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS |
								ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES |
								ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES | ICC_STANDARD_CLASSES;

		if(InitCommonControlsEx(&tim) == FALSE)
			fputs("warning: InitCommomControlsEx() failed\n", stderr);
	}
#endif

#ifndef _WIN32
	if(signal(SIGCHLD, SIG_IGN) == SIG_ERR)
		perror("signal(SIGCHLD)");
#endif

	ft_zero(&ft);
	ft_async(&ft) = 1;
	gtk_init(&argc, &argv); /* bail here if !$DISPLAY */

#ifdef _WIN32
	{
		int debug = 0;

		if(argc == 2){
			if(!strcmp(argv[1], "-d")){
				debug = 1;
				fprintf(stderr, "%s: debug on\n",
						*argv);
			}else{
usage:
				fprintf(stderr, "Usage: %s [-d]\n",
						*argv);
				return 1;
			}
		}else if(argc != 1)
			goto usage;

		if(!debug){
			fputs("gft: debug off\n", stderr);
			FreeConsole();
		}
	}
#else
	if(argc != 1){
		fprintf(stderr, "Usage: %s\n", *argv);
		return 1;
	}
#endif

	builder = gtk_builder_new();

	if(gladegen_init())
		return 1;

	if(!gtk_builder_add_from_file(builder, GLADE_XML_FILE, &error)){
		g_warning("%s", error->message);
		/*g_free(error);*/
		return 1;
	}
	gladegen_term();

	if(getobjects(builder))
		return 1;

	gtk_builder_connect_signals(builder, NULL);

	glist_init(&listTransfers, treeTransfers);

	/* don't need it anymore */
	g_object_unref(G_OBJECT(builder));

	/* signal setup */
	g_signal_connect(G_OBJECT(winMain), "delete-event" ,       G_CALLBACK(on_winMain_delete_event),    NULL);
	g_signal_connect(G_OBJECT(winMain), "destroy",             G_CALLBACK(on_winMain_destroy),         NULL);

	cfg_read(cboHost);
	tray_init(winMain, *argv);
	transfers_init(&listDone, treeDone);

	gtk_widget_set_sensitive(btnSend, FALSE);
	drag_init();

	cmds();
	gtk_widget_show_all(winMain);
	gtk_main();

	tray_term();

	return 0;
}