Exemple #1
0
void UzblTreeTab::Quit()
{
    running = false;
    SaveSession();
    gtk_main_quit();
}
Exemple #2
0
MainWindow::~MainWindow()
{
    SaveSession();
    ClearMemory();
}
Exemple #3
0
void UzblTreeTab::Command(char* c)
{
    char** cmd = g_strsplit(c, " ", -1);
    do {
    if (!g_strcmp0(cmd[0], "new")) {
        if (cmd[1]) {
            char* u = g_strjoinv(" ",cmd+1);
            NewTab(u);
            g_free(u);
        }
        else 
            NewTab("about:blank");
        SaveSession();
    }
    if (!g_strcmp0(cmd[0], "cnew")) {
        if (cmd[2]) {
            int i = 0;
            for(GList* l = uzblinstances; l != NULL; l = g_list_next(l), i++) {
                UzblInstance* uzin = (UzblInstance*)l->data;
                if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                    char* u = g_strjoinv(" ",cmd+2);
                    NewTab(u, i);
                    g_free(u);
                    break;
                }
            }
        }
        else 
            NewTab("about:blank", currenttab);
        SaveSession();
    }
    if (!g_strcmp0(cmd[0], "close")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* uzin = (UzblInstance*)l->data;
            if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                CloseTab(uzin, false);
                break;
            }
        }
    }
    if (!g_strcmp0(cmd[0], "treeclose")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* uzin = (UzblInstance*)l->data;
            if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                CloseTab(uzin, true);
                break;
            }
        }
    }
    if (!g_strcmp0(cmd[0], "next")) {
        GotoTab(currenttab+1);
    }
    if (!g_strcmp0(cmd[0], "prev")) {
        GotoTab(currenttab-1);
    }
    if (!g_strcmp0(cmd[0], "first")) {
        GotoTab(0);
    }
    if (!g_strcmp0(cmd[0], "last")) {
        GotoTab(totaltabs-1);
    }
    if (!g_strcmp0(cmd[0], "goto")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            GotoTab(a);
        }
    }
    if (!g_strcmp0(cmd[0], "attach")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            if (a > totaltabs)
                break;
            
            UzblInstance* cuz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
            UzblInstance* puz = (UzblInstance*)g_list_nth(uzblinstances, a)->data;
            
            if (cuz == puz)
                break;
            
            if (cuz->GetNum() < puz->GetNum()) {
                uzblinstances = g_list_remove(uzblinstances, cuz);
                uzblinstances = g_list_insert(uzblinstances, cuz, puz->GetNum()+1);
            }
            
            cuz->SetParent(puz);
            RebuildTree();
            UpdateTablist();
            SaveSession();
        }
    }
    if (!g_strcmp0(cmd[0], "move")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            UzblInstance* cuz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
            uzblinstances = g_list_remove(uzblinstances, cuz);
            
            if (a > totaltabs)
                a = totaltabs;
            
            uzblinstances = g_list_insert(uzblinstances, cuz, a);
            currenttab = a;
            RebuildTree();
            UpdateTablist();
            SaveSession();
        }
    }
    if (!g_strcmp0(cmd[0], "tabtitle")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
           if (!strcmp(cmd[1], ((UzblInstance*)l->data)->GetName())) {
               char* title = g_strjoinv(" ", cmd+2);
               ((UzblInstance*)l->data)->SetTitle(title);
               g_free(title);
           }
        }
        UpdateTablist();
    }
    if (!g_strcmp0(cmd[0], "taburi")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
           if (!strcmp(cmd[1], ((UzblInstance*)l->data)->GetName())) {
               char* url = g_strjoinv(" ", cmd+2);
               ((UzblInstance*)l->data)->SetURL(url);
               g_free(url);
               SaveSession();
           }
        }
    }
    if (!g_strcmp0(cmd[0], "showtree")) {
        gtk_paned_set_position(pane, panepos);
    }
    if (!g_strcmp0(cmd[0], "hidetree")) {
        panepos = gtk_paned_get_position(pane);
        gtk_paned_set_position(pane, 0);
    }
    } while(0);
    g_strfreev(cmd);
}
Exemple #4
0
void UzblTreeTab::NewTab(const char* url, int child, bool save)
{
    /*char sockid[128];
    sprintf(sockid, "%d_%d", getpid(), fifocount++);*/

    GtkTreeIter iter;
    if (child != -1 && child < g_list_length(uzblinstances)) {
        GtkTreeRowReference* r = ((UzblInstance*)g_list_nth(uzblinstances, child)->data)->GetRowRef();
        
        GtkTreePath* p = gtk_tree_row_reference_get_path(r);
        
        GtkTreeIter piter;
        gtk_tree_model_get_iter(GTK_TREE_MODEL(tabmodel), &piter, p);
        
        gtk_tree_store_append(GTK_TREE_STORE(tabmodel), &iter, &piter);
        
        gtk_tree_view_expand_row(tabtree, p, false);
    }
    else
        gtk_tree_store_append(GTK_TREE_STORE(tabmodel), &iter, NULL);
    
    GtkTreePath* p = gtk_tree_model_get_path(GTK_TREE_MODEL(tabmodel), &iter);

    GtkTreeRowReference* ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(tabmodel), p);
    
    UzblInstance* uzin = new UzblInstance(url, fifopath, notebook, ref);
    uzin->SetPNum(-1);
    uzin->SetParent(NULL);
    
    
    GtkTreeIter piter;
    GtkTreePath* parent = NULL;
    if(gtk_tree_model_iter_parent(GTK_TREE_MODEL(tabmodel), &piter, &iter))
        parent = gtk_tree_model_get_path(GTK_TREE_MODEL(tabmodel), &piter);
    
    
    int i = 0;
    for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
        UzblInstance* uz = (UzblInstance*)l->data;
        
        GtkTreeRowReference* r = uz->GetRowRef();
        GtkTreePath* p2 = gtk_tree_row_reference_get_path(r);
        
        if (parent == NULL)
            break;

        if (!gtk_tree_path_compare(p2, parent)) {
            uzin->SetPNum(i);
            uzin->SetParent(uz);
            uz->AddChild(uzin);
            break;
        }
        i++;
    }
    
    uzblinstances = g_list_append(uzblinstances, uzin);
    totaltabs++;
    uzin->SetNum(totaltabs);
    
    if (save)
        SaveSession();
    UpdateTablist();
    GotoTab(currenttab);
}
Exemple #5
0
void UzblTreeTab::CloseTab(UzblInstance* uz, bool closeall)
{
    closing = true;
    
    
    UzblInstance* nuz = NULL;
    UzblInstance* puz = uz->GetParent();
    if (puz) {
        if (g_list_length(puz->GetChildren()) > 1) {
            GList* l = g_list_find(puz->GetChildren(), uz);
            int len = g_list_length(puz->GetChildren())-1;
            if (g_list_position(puz->GetChildren(), l) == len) {
                nuz = ((UzblInstance*)g_list_nth(puz->GetChildren(), len-1)->data);
            }
            else {
                nuz = ((UzblInstance*)g_list_next(l)->data);
            }
        }
        else {
            nuz = puz;
        }
    }
    else {
        if (g_list_last(uzblinstances)->data != uz) {
            for(GList* l = g_list_last(uzblinstances); l != g_list_find(uzblinstances, uz); l = g_list_previous(l)) {
                UzblInstance* luz = (UzblInstance*)l->data;
                if (luz->GetParent() == NULL && luz != uz) {
                    nuz = luz;
                    //break;
                }
            }
        }
        else {
            for(GList* l = g_list_last(uzblinstances); l != g_list_first(uzblinstances); l = g_list_previous(l)) {
                UzblInstance* luz = (UzblInstance*)l->data;
                if (luz->GetParent() == NULL && luz != uz) {
                    nuz = luz;
                    break;
                }
            }
        }
    }
    
    if (closeall) {
        GList* todelete = NULL;
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* cuz = (UzblInstance*)l->data;
            UzblInstance* cuz2 = cuz;
            
            while (cuz2->GetParent() != uz && cuz2->GetParent() != NULL) {
                cuz2 = cuz2->GetParent();
            }
            if (cuz2->GetParent() != NULL) {
                todelete = g_list_append(todelete, cuz);
            }
        }
        for(GList* l = todelete; l != NULL; l = g_list_next(l)) {
            uzblinstances = g_list_remove(uzblinstances, l->data);
            delete (UzblInstance*)l->data;
        }
        
        uzblinstances = g_list_remove(uzblinstances, uz);
        delete uz;
        g_list_free(todelete);
    }
    else {
        UzblInstance* puz = uz->GetParent();
        GList* children = uz->GetChildren();
        for(GList* l = children; l != NULL; l = g_list_next(l)) {
            UzblInstance* cuz = (UzblInstance*)l->data;

            cuz->SetParent(puz);
        }
        uzblinstances = g_list_remove(uzblinstances, uz);
        delete uz;
    }
    
    RebuildTree();
    UpdateTablist();
    
    if (nuz)
        GotoTab(nuz->GetNum());
    else
        GotoTab(gtk_notebook_get_current_page(notebook));
    
    SaveSession();
    closing = false;
}
Exemple #6
0
/*
 * Interrupt handler.  Stop curses and exit gracefully.
 */
void cleanup_sig(int sig)
{
#ifdef IGNORE_CTRL_C
    if (sig == SIGINT) {
	/*
	 * Need to rearm the signal.
	 */
#ifdef DJGPP
	if (wathndlcbrk) {
	    sig_handler_watt(sig);	/* Use WATT-32 signal handler */
	}
#endif /* DJGPP */
	signal(SIGINT, cleanup_sig);
	sigint = TRUE;
#ifdef DJGPP
	_eth_release();
	_eth_init();
#endif /* DJGPP */
	return;
    }
#endif /* IGNORE_CTRL_C */

#ifdef VMS
    if (!dump_output_immediately) {
	int c;

	/*
	 * Reassert the AST.
	 */
	(void) signal(SIGINT, cleanup_sig);
	if (!LYCursesON)
	    return;

	/*
	 * Refresh screen to get rid of "cancel" message, then query.
	 */
	lynx_force_repaint();
	LYrefresh();

	/*
	 * Ask if exit is intended.
	 */
	if (LYQuitDefaultYes == TRUE) {
	    c = HTConfirmDefault(REALLY_EXIT, YES);
	} else {
	    c = HTConfirmDefault(REALLY_EXIT, NO);
	}
	HadVMSInterrupt = TRUE;
	if (LYQuitDefaultYes == TRUE) {
	    if (c == NO) {
		return;
	    }
	} else if (c != YES) {
	    return;
	}
    }
#endif /* VMS */

    /*
     * Ignore further interrupts.  - mhc:  11/2/91
     */
#ifndef NOSIGHUP
    (void) signal(SIGHUP, SIG_IGN);
#endif /* NOSIGHUP */

#ifdef VMS
    /*
     * Use ttclose() from cleanup() for VMS if not dumping.
     */
    if (dump_output_immediately)
#else /* Unix: */
    (void) signal(SIGINT, SIG_IGN);
#endif /* VMS */

    (void) signal(SIGTERM, SIG_IGN);

    if (traversal)
	dump_traversal_history();

#ifndef NOSIGHUP
    if (sig != SIGHUP) {
#endif /* NOSIGHUP */

	if (!dump_output_immediately) {
	    /*
	     * cleanup() also calls cleanup_files().
	     */
	    cleanup();
	}
	if (sig != 0) {
	    SetOutputMode(O_TEXT);
	    printf("\n\n%s %d\n\n",
		   gettext("Exiting via interrupt:"),
		   sig);
	    fflush(stdout);
	}
#ifndef NOSIGHUP
    } else {
#ifdef USE_SESSIONS
	/*
	 * Wondering is this right place and time to do it.
	 * We need this, for example it is usefull to save session
	 * if user closed lynx in non standard way, like closing
	 * xterm window or in worst one like crash.
	 */
	SaveSession();
#endif /* USE_SESSIONS */
	cleanup_files();
    }
#endif /* NOSIGHUP */
    if (sig != 0) {
	exit_immediately(EXIT_SUCCESS);
    } else {
	reset_signals();
    }
}
Exemple #7
0
void cleanup(void)
{
#ifdef VMS
    extern BOOLEAN DidCleanup;
#endif /* VMS */

    /*
     * Cleanup signals - just in case.  Ignore further interrupts.  - mhc: 
     * 11/2/91
     */
#ifndef NOSIGHUP
    (void) signal(SIGHUP, SIG_IGN);
#endif /* NOSIGHUP */
    (void) signal(SIGTERM, SIG_IGN);

#ifndef VMS			/* use ttclose() from cleanup() for VMS */
    (void) signal(SIGINT, SIG_IGN);
#endif /* !VMS */

    if (LYCursesON) {
	LYmove(LYlines - 1, 0);
	LYclrtoeol();

	lynx_stop_all_colors();
	LYrefresh();

	stop_curses();
    }
#ifdef EXP_CHARTRANS_AUTOSWITCH
    /*
     * Currently implemented only for LINUX:  Restore original font.
     */
    UCChangeTerminalCodepage(-1, (LYUCcharset *) 0);
#endif /* EXP_CHARTRANS_AUTOSWITCH */

#ifdef USE_PERSISTENT_COOKIES
    /*
     * This can go right here for now.  We need to work up a better place
     * to save cookies for the next release, preferably whenever a new
     * persistent cookie is received or used.  Some sort of protocol to
     * handle two processes writing to the cookie file needs to be worked
     * out as well.
     */
    if (persistent_cookies)
	LYStoreCookies(LYCookieSaveFile);
#endif
#ifdef USE_SESSIONS
    /*
     * Wondering is this right place and time to do it.
     */
    SaveSession();
#endif /* USE_SESSIONS */

    cleanup_files();
#ifdef VMS
    ttclose();
    DidCleanup = TRUE;
#endif /* VMS */

    /*
     * If we're looking at memory leaks, hang onto the trace file, since there
     * is no memory freed in this function, and it is a nuisance to not be able
     * to trace the cleanup activity -TD
     */
#ifndef LY_FIND_LEAKS
    LYCloseTracelog();
#endif
}
Exemple #8
0
 void ClearSession() {
     Session session;
     SaveSession(session);
 }
Exemple #9
0
void asdbus_process_messages (ASDBusFd* fd)
{
	//show_progress ("checking dbus messages for fd = %d", fd->fd);
#ifndef ASDBUS_DISPATCH
	while (ASDBus.session_conn) {
		DBusMessage *msg;
		const char *interface, *member;
		/* non blocking read of the next available message */
		dbus_connection_read_write (ASDBus.session_conn, 0);
		msg = dbus_connection_pop_message (ASDBus.session_conn);

		if (NULL == msg) {
			/* show_progress ("no more Dbus messages..."); */
			//show_progress("time(%ld):dbus message not received during the timeout - sleeping...", time (NULL));
			return;
		}
		interface = dbus_message_get_interface (msg);
		member = dbus_message_get_member (msg);
		show_debug(__FILE__,__FUNCTION__, __LINE__, "dbus msg iface = \"%s\", member = \"%s\"", interface?interface:"(nil)", member?member:"(nil)");
		if (interface == NULL || member == NULL) {
			show_progress ("time(%ld):dbus message cannot be parsed...",
										 time (NULL));
		} else {
			show_progress
					("time(%ld):dbus message received from \"%s\", member \"%s\"",
					 time (NULL), interface, member);
			if (strcmp (interface, IFACE_SESSION_PRIVATE) == 0) {
				if (strcmp (member, "QueryEndSession") == 0) {	/* must replay yes  within 10 seconds */
					asdbus_EndSessionOk ();
					asdbus_Notify ("Session is ending ...",
												 "Checking if it is safe to logout", 0);
					SaveSession (True);
				} else if (strcmp (member, "EndSession") == 0) {
					/*cover_desktop ();
					   display_progress (True, "Session is ending, please wait ..."); */
					asdbus_Notify ("Session is ending ...",
												 "Closing apps, please wait.", 0);
					dbus_connection_read_write (ASDBus.session_conn, 0);
					/* Yield to let other clients process Session Management requests */
					sleep_a_millisec (300);
					CloseSessionClients (False);
					/* we want to end to the very end */
				} else if (strcmp (member, "Stop") == 0) {
					asdbus_Notify ("Session is over.", "Bye-bye!", 0);
					dbus_connection_read_write (ASDBus.session_conn, 0);
					Done (False, NULL);
				}
			}
		}
#if 0
		if (dbus_message_is_method_call (msg, "test.method.Type", "Method"))
			reply_to_method_call (msg, conn);
#endif
		dbus_message_unref (msg);
	}
#else
	if (ASDBus.session_conn)
		do {
			dbus_connection_read_write_dispatch (ASDBus.session_conn, 0);
		} while (dbus_connection_get_dispatch_status (ASDBus.session_conn) ==
						 DBUS_DISPATCH_DATA_REMAINS);
#endif
}