Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device file access extended #18

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions src/Device.vala
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,80 @@ namespace KDEConnectIndicator {
});
}
}


public void browse_home () {
if (!has_plugin ("kdeconnect_sftp"))
return;
if (is_mounted ())
open_file (mount_point + "/storage/sdcard0");

else {
mount();
Timeout.add (1000, ()=> { // idle for a few second to let sftp kickin
open_file (mount_point + "/storage/sdcard0");
return false;
});
}
}
public void browse_camera () {
if (!has_plugin ("kdeconnect_sftp"))
return;
if (is_mounted ())
open_file (mount_point+ "/storage/sdcard0/DCIM");

else {
mount();
Timeout.add (1000, ()=> { // idle for a few second to let sftp kickin
open_file (mount_point + "/storage/sdcard0/DCIM");
return false;
});
}
}
public void browse_pictures () {
if (!has_plugin ("kdeconnect_sftp"))
return;
if (is_mounted ())
open_file (mount_point+ "/storage/sdcard0/Pictures");

else {
mount();
Timeout.add (1000, ()=> { // idle for a few second to let sftp kickin
open_file (mount_point + "/storage/sdcard0/Pictures");
return false;
});
}
}
public void browse_download () {
if (!has_plugin ("kdeconnect_sftp"))
return;
if (is_mounted ())
open_file (mount_point+ "/storage/sdcard0/Download");

else {
mount();
Timeout.add (1000, ()=> { // idle for a few second to let sftp kickin
open_file (mount_point + "/storage/sdcard0/Download");
return false;
});
}
}
public void browse_music () {
if (!has_plugin ("kdeconnect_sftp"))
return;
if (is_mounted ())
open_file (mount_point+ "/storage/sdcard0/Music");

else {
mount();
Timeout.add (1000, ()=> { // idle for a few second to let sftp kickin
open_file (mount_point + "/storage/sdcard0/Music");
return false;
});
}
}


public bool is_mounted () {
try {
var return_variant = conn.call_sync (
Expand Down
49 changes: 49 additions & 0 deletions src/DeviceIndicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ namespace KDEConnectIndicator {
private Gtk.MenuItem battery_item;
private Gtk.MenuItem status_item;
private Gtk.MenuItem browse_item;

private Gtk.MenuItem browse_home_item;
private Gtk.MenuItem browse_camera_item;
private Gtk.MenuItem browse_pictures_item;
private Gtk.MenuItem browse_download_item;
private Gtk.MenuItem browse_music_item;

private Gtk.MenuItem send_item;
private Gtk.SeparatorMenuItem separator;
private Gtk.MenuItem pair_item;
Expand All @@ -36,6 +43,18 @@ namespace KDEConnectIndicator {
menu.append (new Gtk.SeparatorMenuItem ());
browse_item = new Gtk.MenuItem.with_label ("Browse device");
menu.append(browse_item);

browse_home_item = new Gtk.MenuItem.with_label ("Browse home folder");
menu.append(browse_home_item);
browse_camera_item = new Gtk.MenuItem.with_label ("Browse camera pictures");
menu.append(browse_camera_item);
browse_pictures_item = new Gtk.MenuItem.with_label ("Browse pictures");
menu.append(browse_pictures_item);
browse_download_item = new Gtk.MenuItem.with_label ("Browse download");
menu.append(browse_download_item);
browse_music_item = new Gtk.MenuItem.with_label ("Browse music");
menu.append(browse_music_item);

send_item = new Gtk.MenuItem.with_label ("Send file");
menu.append(send_item);
separator = new Gtk.SeparatorMenuItem ();
Expand All @@ -58,6 +77,24 @@ namespace KDEConnectIndicator {
browse_item.activate.connect (() => {
device.browse ();
});

browse_home_item.activate.connect (() => {
device.browse_home ();
});
browse_camera_item.activate.connect (() => {
device.browse_camera ();
});
browse_pictures_item.activate.connect (() => {
device.browse_pictures ();
});
browse_download_item.activate.connect (() => {
device.browse_download ();
});
browse_music_item.activate.connect (() => {
device.browse_music ();
});


send_item.activate.connect (() => {
Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
"Select file", null, Gtk.FileChooserAction.OPEN,
Expand Down Expand Up @@ -159,6 +196,18 @@ namespace KDEConnectIndicator {

browse_item.visible = paired && device.has_plugin ("kdeconnect_sftp");
browse_item.sensitive = reachable;

browse_home_item.visible = paired && device.has_plugin ("kdeconnect_sftp");
browse_home_item.sensitive = reachable;
browse_camera_item.visible = paired && device.has_plugin ("kdeconnect_sftp");
browse_camera_item.sensitive = reachable;
browse_pictures_item.visible = paired && device.has_plugin ("kdeconnect_sftp");
browse_pictures_item.sensitive = reachable;
browse_download_item.visible = paired && device.has_plugin ("kdeconnect_sftp");
browse_download_item.sensitive = reachable;
browse_music_item.visible = paired && device.has_plugin ("kdeconnect_sftp");
browse_music_item.sensitive = reachable;

send_item.visible = paired && device.has_plugin ("kdeconnect_share");
send_item.sensitive = reachable;
separator.visible = browse_item.visible || send_item.visible;
Expand Down