~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to src/socket.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2009-01-01 18:40:50 UTC
  • mfrom: (1.1.8 upstream) (3.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20090101184050-u635kualu7amyt4a
Tags: 0.15-1ubuntu1
* Merge from debian experimental, remaining change:
  - patches/20_add_debdiff_as_diff_type.dpatch: Also recognize .dpatch files
    as diff's
  - debian/geany.xpm: Replace icon with a .xpm of the new one

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *      along with this program; if not, write to the Free Software
19
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $Id: socket.c 2287 2008-02-27 13:17:29Z eht16 $
 
21
 * $Id: socket.c 2991 2008-09-24 12:07:22Z ntrel $
22
22
 */
23
23
 
24
24
/*
77
77
#include "support.h"
78
78
#include "ui_utils.h"
79
79
#include "utils.h"
 
80
#include "encodings.h"
80
81
 
81
82
 
82
83
 
141
142
 
142
143
        socket_fd_write_all(sock, "open\n", 5);
143
144
 
144
 
        for(i = 1; i < argc && argv[i] != NULL; i++)
 
145
        for (i = 1; i < argc && argv[i] != NULL; i++)
145
146
        {
146
 
                filename = get_argv_filename(argv[i]);
 
147
                filename = main_get_argv_filename(argv[i]);
147
148
 
148
149
                /* if the filename is valid or if a new file should be opened is check on the other side */
149
150
                if (filename != NULL)
472
473
#endif
473
474
 
474
475
 
 
476
static void handle_input_filename(const gchar *buf)
 
477
{
 
478
        gchar *utf8_filename, *locale_filename;
 
479
 
 
480
        /* we never know how the input is encoded, so do the best auto detection we can */
 
481
        if (! g_utf8_validate(buf, -1, NULL))
 
482
                utf8_filename = encodings_convert_to_utf8(buf, -1, NULL);
 
483
        else
 
484
                utf8_filename = g_strdup(buf);
 
485
 
 
486
        locale_filename = utils_get_locale_from_utf8(utf8_filename);
 
487
        g_free(utf8_filename);
 
488
        if (locale_filename)
 
489
                main_handle_filename(locale_filename);
 
490
        g_free(locale_filename);
 
491
}
 
492
 
 
493
 
475
494
gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpointer data)
476
495
{
477
496
        gint fd, sock;
489
508
        {
490
509
                if (strncmp(buf, "open", 4) == 0)
491
510
                {
492
 
                        document_delay_colourise();
493
 
 
494
511
                        while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.')
495
512
                        {
496
 
                                g_strstrip(buf); /* remove \n char */
497
 
 
498
 
                                if (g_file_test(buf, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
499
 
                                        document_open_file(buf, FALSE, NULL, NULL);
500
 
                                else
501
 
                                {       /* create new file if it doesn't exist */
502
 
                                        gint idx;
503
 
 
504
 
                                        idx = document_new_file(buf, NULL, NULL);
505
 
                                        if (DOC_IDX_VALID(idx))
506
 
                                                ui_add_recent_file(doc_list[idx].file_name);
507
 
                                        else
508
 
                                                geany_debug("got data from socket, but it does not look like a filename");
509
 
                                }
 
513
                                handle_input_filename(g_strstrip(buf));
510
514
                        }
511
 
                        document_colourise_new();
512
515
 
513
 
                        gtk_window_deiconify(GTK_WINDOW(app->window));
514
516
#ifdef G_OS_WIN32
515
 
                        gtk_window_present(GTK_WINDOW(app->window));
 
517
                        /* we need to bring the main window up with gtk_window_present() but this is not
 
518
                         * enough, instead we need to iconify it so that gtk_window_deiconify() will
 
519
                         * bring it in the foreground */
 
520
                        gtk_window_present(GTK_WINDOW(main_widgets.window));
 
521
                        gtk_window_iconify(GTK_WINDOW(main_widgets.window));
516
522
#endif
 
523
                        gtk_window_deiconify(GTK_WINDOW(main_widgets.window));
517
524
                }
518
525
                else if (strncmp(buf, "line", 4) == 0)
519
526
                {