Skip to content

Commit

Permalink
ja esta fazendo chamada no gio para mountar
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed May 9, 2011
1 parent e3a4e4a commit 7afe34b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
@@ -1,2 +1,2 @@
all:
gcc `pkg-config --libs --cflags gtk+-2.0` mountmatricula.c -o matricula
gcc `pkg-config --libs --cflags gtk+-2.0 gmodule-export-2.0` mountmatricula.c -o matricula
5 changes: 3 additions & 2 deletions src/gui.ui
Expand Up @@ -31,9 +31,10 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<object class="GtkButton" id="btn_connect">
<property name="label">gtk-connect</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
Expand Down Expand Up @@ -167,7 +168,7 @@
</child>
<action-widgets>
<action-widget response="0">button2</action-widget>
<action-widget response="1">button1</action-widget>
<action-widget response="1">btn_connect</action-widget>
</action-widgets>
</object>
</interface>
Binary file modified src/matricula
Binary file not shown.
76 changes: 71 additions & 5 deletions src/mountmatricula.c
Expand Up @@ -3,16 +3,73 @@
#include <gtk/gtk.h>
#include <gio/gio.h>

gchar SERVIDOR[] = "localhost";

static void
mount_mountable_done_cb (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
GFile *target;
GError *error = NULL;

target = g_file_mount_mountable_finish (G_FILE (object), res, &error);

g_print ("Destino, %s", target);

if (target == NULL)
g_printerr ("Error mounting location: %s\n", error->message);
else
g_object_unref (target);
/*
outstanding_mounts--;
if (outstanding_mounts == 0)
g_main_loop_quit (main_loop);
*/
}

void mount (char *username, char *password) {
GFile *file;
gchar *cmd;
GMountOperation *op;

cmd = g_strdup_printf("ssh://%s@%s:/home/%s",
username, SERVIDOR, username);

g_print ("mountando: %s\n", cmd);

file = g_file_new_for_commandline_arg (cmd);
op = g_mount_operation_new ();
g_mount_operation_set_password (op, password);
g_file_mount_mountable (file, 0, op, NULL, mount_mountable_done_cb, op);

}

void values_changed_cb (GtkWidget *widget, GtkBuilder *builder) {
g_print ("values changed");
GObject *obj;
gint u, p;

obj = gtk_builder_get_object(builder, "username");
u = gtk_entry_get_text_length (GTK_ENTRY(obj));

obj = gtk_builder_get_object(builder, "password");
p = gtk_entry_get_text_length (GTK_ENTRY(obj));

obj = gtk_builder_get_object(builder, "btn_connect");

if ((u < 1) || (p < 1))
gtk_widget_set_sensitive (GTK_WIDGET(obj), FALSE);
else
gtk_widget_set_sensitive (GTK_WIDGET(obj), TRUE);

}


int main (int argc, char *argv[]) {
GtkBuilder *builder;
GtkWidget *dialog;

GtkWidget *dialog, *obj;
gchar *username, *password;

gtk_init(&argc, &argv);
builder = gtk_builder_new();
Expand All @@ -34,8 +91,17 @@ int main (int argc, char *argv[]) {

gtk_builder_connect_signals (builder, builder);

dialog = gtk_builder_get_object (builder, "dialog");
gtk_dialog_run (GTK_DIALOG(dialog));
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "dialog"));
gint result = gtk_dialog_run (GTK_DIALOG(dialog));

if (result) {
obj = gtk_builder_get_object (builder, "username");
username = gtk_entry_get_text (GTK_ENTRY(obj));

obj = gtk_builder_get_object (builder, "password");
password = gtk_entry_get_text (GTK_ENTRY(obj));
mount (username, password);

}
gtk_main();
}

0 comments on commit 7afe34b

Please sign in to comment.