[feat] dynamicaly create remote device list
This commit is contained in:
@@ -11,7 +11,7 @@ OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
|
|||||||
|
|
||||||
all: teleportapp
|
all: teleportapp
|
||||||
|
|
||||||
resources.c: teleportapp.gresource.xml window.ui settings.ui
|
resources.c: teleportapp.gresource.xml window.ui settings.ui remote_list.ui
|
||||||
$(GLIB_COMPILE_RESOURCES) teleportapp.gresource.xml --target=$@ --sourcedir=. --generate-source
|
$(GLIB_COMPILE_RESOURCES) teleportapp.gresource.xml --target=$@ --sourcedir=. --generate-source
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ get (char *url, const gchar *output_file_path)
|
|||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
|
//url and absoulte path to download dir
|
||||||
get ("http://juliansparber.com/index.html", "./test_download");
|
get ("http://juliansparber.com/index.html", "./test_download");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
<gresource prefix="/org/gtk/teleportapp">
|
<gresource prefix="/org/gtk/teleportapp">
|
||||||
<file preprocess="xml-stripblanks">window.ui</file>
|
<file preprocess="xml-stripblanks">window.ui</file>
|
||||||
<file preprocess="xml-stripblanks">settings.ui</file>
|
<file preprocess="xml-stripblanks">settings.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">remote_list.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ struct _TeleportAppWindowPrivate
|
|||||||
{
|
{
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
GtkWidget *gears;
|
GtkWidget *gears;
|
||||||
|
GtkWidget *remote_devices_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||||
@@ -23,7 +24,12 @@ teleport_app_window_init (TeleportAppWindow *win)
|
|||||||
{
|
{
|
||||||
TeleportAppWindowPrivate *priv;
|
TeleportAppWindowPrivate *priv;
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
|
GtkBuilder *builder_remote_list;
|
||||||
GtkWidget *menu;
|
GtkWidget *menu;
|
||||||
|
GtkWidget *remote_list_row;
|
||||||
|
GtkLabel *remote_name;
|
||||||
|
GtkWidget *line;
|
||||||
|
GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
|
||||||
//GAction *action;
|
//GAction *action;
|
||||||
|
|
||||||
priv = teleport_app_window_get_instance_private (win);
|
priv = teleport_app_window_get_instance_private (win);
|
||||||
@@ -34,30 +40,28 @@ teleport_app_window_init (TeleportAppWindow *win)
|
|||||||
|
|
||||||
gtk_menu_button_set_popover(GTK_MENU_BUTTON (priv->gears), menu);
|
gtk_menu_button_set_popover(GTK_MENU_BUTTON (priv->gears), menu);
|
||||||
|
|
||||||
//action = g_settings_create_action (priv->settings, "show-words");
|
builder_remote_list = gtk_builder_new_from_resource ("/org/gtk/teleportapp/remote_list.ui");
|
||||||
//g_action_map_add_action (G_ACTION_MAP (win), action);
|
|
||||||
/*
|
|
||||||
const gchar *authors[] = {
|
|
||||||
"Julian Sparber <julian@sparber.net>",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
gtk_show_about_dialog (parent,
|
remote_list_row = GTK_WIDGET (gtk_builder_get_object (builder_remote_list, "remote_device_row"));
|
||||||
"authors", authors,
|
remote_name = GTK_LABEL (gtk_builder_get_object (builder_remote_list, "device_name"));
|
||||||
"comments", "",
|
gtk_label_set_text(remote_name, "Tobias's Laptop");
|
||||||
"copyright", "Copyright \xc2\xa9 2017 Julian Sparber",
|
gtk_list_box_insert(GTK_LIST_BOX(priv->remote_devices_list), remote_list_row, -1);
|
||||||
"license-type", GTK_LICENSE_AGPL_3_0,
|
|
||||||
"logo-icon-name", "",
|
|
||||||
"program-name", "",
|
|
||||||
"translator-credits", "translator-credits",
|
|
||||||
"version", "20",
|
|
||||||
"website", "https://wiki.gnome.org/Apps/teleport",
|
|
||||||
"website-label", "Teleport website",
|
|
||||||
NULL);
|
|
||||||
*/
|
|
||||||
|
|
||||||
//g_object_unref (action);
|
|
||||||
//g_object_unref (builder);
|
line = GTK_WIDGET (gtk_builder_get_object (builder_remote_list, "remote_space_row"));
|
||||||
|
gtk_list_box_insert(GTK_LIST_BOX(priv->remote_devices_list), line, -1);
|
||||||
|
|
||||||
|
builder_remote_list = gtk_builder_new_from_resource ("/org/gtk/teleportapp/remote_list.ui");
|
||||||
|
|
||||||
|
remote_list_row = GTK_WIDGET (gtk_builder_get_object (builder_remote_list, "remote_device_row"));
|
||||||
|
remote_name = GTK_LABEL (gtk_builder_get_object (builder_remote_list, "device_name"));
|
||||||
|
gtk_label_set_text(remote_name, "Tobias's Laptop");
|
||||||
|
gtk_list_box_insert(GTK_LIST_BOX(priv->remote_devices_list), remote_list_row, -1);
|
||||||
|
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
|
g_object_unref (menu);
|
||||||
|
g_object_unref (remote_list_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -83,6 +87,8 @@ teleport_app_window_class_init (TeleportAppWindowClass *class)
|
|||||||
"/org/gtk/teleportapp/window.ui");
|
"/org/gtk/teleportapp/window.ui");
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, gears);
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, gears);
|
||||||
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, remote_devices_list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TeleportAppWindow *
|
TeleportAppWindow *
|
||||||
|
|||||||
170
src/window.ui
170
src/window.ui
@@ -198,83 +198,10 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox" id="remote-devices-listbox">
|
<object class="GtkListBox" id="remote_devices_list">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="selection_mode">none</property>
|
<property name="selection_mode">none</property>
|
||||||
<child>
|
|
||||||
<object class="GtkListBoxRow" id="remote-device-1-row">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="activatable">false</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkGrid" id="remote-device-1-grid">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="row_spacing">0</property>
|
|
||||||
<property name="column_spacing">32</property>
|
|
||||||
<property name="margin_start">12</property>
|
|
||||||
<property name="margin_end">6</property>
|
|
||||||
<property name="margin_top">6</property>
|
|
||||||
<property name="margin_bottom">6</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="remote-device-1-name">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="valign">end</property>
|
|
||||||
<property name="label" translatable="yes">Jan's Librem</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="remote-device-1-description">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">Drop here to send</property>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label"/>
|
|
||||||
</style>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="scale" value="0.9"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="remote-device-1-send-file-btn">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<property name="label" translatable="yes">Send File</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -283,101 +210,6 @@
|
|||||||
<property name="orientation">horizontal</property>
|
<property name="orientation">horizontal</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkListBox" id="remote-device-1-files-listbox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="selection_mode">none</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListBoxRow" id="remote-device-1-file-1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="activatable">false</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkGrid" id="remote-device-1-file-1-grid">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="row_spacing">0</property>
|
|
||||||
<property name="column_spacing">16</property>
|
|
||||||
<property name="margin_start">12</property>
|
|
||||||
<property name="margin_end">6</property>
|
|
||||||
<property name="margin_top">6</property>
|
|
||||||
<property name="margin_bottom">6</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="remote-device-1-file-1-title">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">Sending app-mockup.png</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="scale" value="0.9"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkProgressBar" id="remote-device-1-file-1-progress">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="fraction">0.80</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="remote-device-1-file-1-progress-label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">100 MB / 5 GB</property>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label"/>
|
|
||||||
</style>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="scale" value="0.7"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="remote-device-1-file-1-button-cancel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<property name="label" translatable="yes">Cancel</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user