~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to src/marlin-main.c

  • Committer: am.monkeyd at gmail
  • Date: 2010-11-08 13:17:02 UTC
  • Revision ID: am.monkeyd@gmail.com-20101108131702-rqeywh4r5pyx2ycz
let's roll

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <config.h>
 
2
#include "gof-directory-async.h"
 
3
#include "gof-window-slot.h"
 
4
#include "marlin-window-columns.h"
 
5
//#include <glib/gi18n.h>
 
6
//#include <libintl.h>
 
7
#include "marlin-global-preferences.h" 
 
8
#include "marlin-view-window.h"
 
9
 
 
10
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
11
 
 
12
 
 
13
static void     about (void);
 
14
static void     marlin_view_window_up (MarlinViewWindow *window);
 
15
static void     marlin_view_window_path_changed (MarlinViewWindow *window, const gchar *path, gpointer data);
 
16
 
 
17
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
18
        if ((array != NULL) && (destroy_func != NULL)) {
 
19
                int i;
 
20
                for (i = 0; i < array_length; i = i + 1) {
 
21
                        if (((gpointer*) array)[i] != NULL) {
 
22
                                destroy_func (((gpointer*) array)[i]);
 
23
                        }
 
24
                }
 
25
        }
 
26
}
 
27
 
 
28
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
29
        _vala_array_destroy (array, array_length, destroy_func);
 
30
        g_free (array);
 
31
}
 
32
 
 
33
 
 
34
int
 
35
main (int argc, char *argv[])
 
36
{
 
37
        MarlinViewWindow *window;
 
38
        GtkWidget       *vbox;
 
39
        GtkWidget       *hbox;
 
40
        GtkWidget       *btn;
 
41
        GtkWidget       *entry;
 
42
        gchar           *path;
 
43
 
 
44
        gtk_init (&argc, &argv);
 
45
        /* Initialize gettext support */
 
46
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
47
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
48
        textdomain (GETTEXT_PACKAGE);
 
49
 
 
50
        /* gsettings parameters */
 
51
        //GSettings  *settings;
 
52
        settings = g_settings_new ("org.gnome.marlin.preferences");
 
53
        /*gboolean showall = g_settings_get_boolean (settings, "showall");
 
54
        printf ("test gsettings showall: %d\n", showall);*/
 
55
 
 
56
        /*window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
57
        gtk_window_set_title (GTK_WINDOW (window), "marlin");
 
58
        gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
 
59
        gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
60
        g_signal_connect (window, "destroy", gtk_main_quit, NULL);*/
 
61
        
 
62
        //GOFDirectoryAsync *mydir;
 
63
        //MarlinWindowColumns *mwcols;
 
64
 
 
65
        if (argc > 1) {
 
66
                path = argv[1];
 
67
        } else {
 
68
                path = g_strdup(g_get_home_dir());
 
69
        }
 
70
        
 
71
        window = marlin_view_window_new (path);
 
72
 
 
73
        g_signal_connect (window, "show-about", (GCallback) about, NULL);
 
74
        g_signal_connect (window, "up", (GCallback) marlin_view_window_up, NULL);
 
75
        /*g_signal_connect (window, "back", (GCallback) __lambda22__marlin_view_window_back, NULL);
 
76
        g_signal_connect (window, "forward", (GCallback) __lambda23__marlin_view_window_forward, NULL);
 
77
        g_signal_connect (window, "refresh", (GCallback) __lambda24__marlin_view_window_refresh, NULL);*/
 
78
        g_signal_connect (window, "quit", (GCallback) gtk_main_quit, NULL);
 
79
        g_signal_connect (window, "path-changed", (GCallback) marlin_view_window_path_changed, NULL);
 
80
 
 
81
        GOFWindowSlot *slot;
 
82
        
 
83
        slot = gof_window_slot_new(g_file_new_for_commandline_arg (path), GTK_WIDGET (window));
 
84
        //mwcols = marlin_window_columns_new(g_file_new_for_commandline_arg (path), window);
 
85
 
 
86
        //marlin_view_window_set_content (window, slot->view_box);
 
87
 
 
88
        gtk_main ();
 
89
        g_free (path);  
 
90
        return 0;
 
91
}
 
92
 
 
93
/* TODO Move this horror to a separate vala file */
 
94
static void about (void) {
 
95
        GtkAboutDialog* _tmp0_ = NULL;
 
96
        GtkAboutDialog* about;
 
97
        gchar* _tmp1_;
 
98
        gchar* _tmp2_;
 
99
        gchar** _tmp3_ = NULL;
 
100
        gchar** _tmp4_;
 
101
        gint _tmp4__length1;
 
102
        gchar* _tmp5_;
 
103
        gchar** _tmp6_ = NULL;
 
104
        gchar** _tmp7_;
 
105
        gint _tmp7__length1;
 
106
        _tmp0_ = (GtkAboutDialog*) gtk_about_dialog_new ();
 
107
        about = g_object_ref_sink (_tmp0_);
 
108
        gtk_about_dialog_set_program_name (about, "Marlin");
 
109
        gtk_window_set_icon_name ((GtkWindow*) about, "system-file-manager");
 
110
        gtk_about_dialog_set_logo_icon_name (about, "system-file-manager");
 
111
        gtk_about_dialog_set_website (about, "http://www.elementary-project.com");
 
112
        gtk_about_dialog_set_website_label (about, "elementary-project.com");
 
113
        gtk_about_dialog_set_copyright (about, "Copyright 2010 elementary Developers");
 
114
        _tmp1_ = g_strdup ("ammonkey <am.monkeyd@gmail.com>");
 
115
        _tmp2_ = g_strdup ("Mathijs Henquet <mathijs.henquet@gmail.com>");
 
116
        _tmp3_ = g_new0 (gchar*, 2 + 1);
 
117
        _tmp3_[0] = _tmp1_;
 
118
        _tmp3_[1] = _tmp2_;
 
119
        _tmp4_ = _tmp3_;
 
120
        _tmp4__length1 = 2;
 
121
        gtk_about_dialog_set_authors (about, _tmp4_);
 
122
        _tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
 
123
        _tmp5_ = g_strdup ("Daniel Foré <dan@elementary-project.com>");
 
124
        _tmp6_ = g_new0 (gchar*, 1 + 1);
 
125
        _tmp6_[0] = _tmp5_;
 
126
        _tmp7_ = _tmp6_;
 
127
        _tmp7__length1 = 1;
 
128
        gtk_about_dialog_set_artists (about, _tmp7_);
 
129
        _tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
 
130
        gtk_dialog_run ((GtkDialog*) about);
 
131
        g_signal_emit_by_name ((GtkWidget*) about, "destroy");
 
132
        _g_object_unref0 (about);
 
133
}
 
134
 
 
135
static void
 
136
marlin_view_window_up (MarlinViewWindow *window)
 
137
{
 
138
        GOFWindowSlot *slot;
 
139
        GFile *parent;
 
140
 
 
141
        if ((slot = GOF_WINDOW_SLOT (marlin_view_window_get_active_slot(window))) == NULL)
 
142
                return;
 
143
        if (slot->location == NULL) 
 
144
                return;
 
145
        parent = g_file_get_parent (slot->location);
 
146
        if (parent == NULL) 
 
147
                return;
 
148
 
 
149
        if (slot->mwcols != NULL)
 
150
                marlin_window_columns_change_location (slot, parent);
 
151
        else
 
152
                gof_window_slot_change_location (slot, parent);
 
153
        g_object_unref (parent);
 
154
}
 
155
 
 
156
static void
 
157
marlin_view_window_path_changed (MarlinViewWindow *window, const gchar *path, gpointer data)
 
158
{
 
159
        GOFWindowSlot *slot;
 
160
        
 
161
        g_return_if_fail (path != NULL);
 
162
        //fprintf (stdout, "signal: path_changed(%s)\n", path);
 
163
        slot = gof_window_slot_new(g_file_new_for_commandline_arg (path), GTK_WIDGET (window));
 
164
}