[feat] add popover to set users device name #7
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
<file alias="gtk/menus.ui">gtk/menus.ui</file>
|
<file alias="gtk/menus.ui">gtk/menus.ui</file>
|
||||||
<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">device_settings.ui</file>
|
||||||
<file preprocess="xml-stripblanks">remote_list.ui</file>
|
<file preprocess="xml-stripblanks">remote_list.ui</file>
|
||||||
<file compressed="true">style.css</file>
|
<file compressed="true">style.css</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
|
|||||||
53
src/device_settings.ui
Normal file
53
src/device_settings.ui
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<interface>
|
||||||
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
|
<object id="device-settings" class="GtkPopover">
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="margin">10</property>
|
||||||
|
<property name="column-spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Device name</property>
|
||||||
|
<property name="halign">GTK_ALIGN_START</property>
|
||||||
|
<property name="margin_bottom">6</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="GtkEntry" id="this_device_settings_entry">
|
||||||
|
<property name="visible">True</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="GtkButton" id="this_device_settings_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Rename</property>
|
||||||
|
<style>
|
||||||
|
<class name="suggested-action"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
@@ -37,10 +37,12 @@ struct _TeleportWindowPrivate
|
|||||||
{
|
{
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
GtkWidget *gears;
|
GtkWidget *gears;
|
||||||
|
GtkWidget *this_device_settings_button;
|
||||||
GtkWidget *remote_devices_box;
|
GtkWidget *remote_devices_box;
|
||||||
GtkWidget *this_device_name_label;
|
GtkWidget *this_device_name_label;
|
||||||
GtkWidget *remote_no_devices;
|
GtkWidget *remote_no_devices;
|
||||||
GtkWidget *remote_no_avahi;
|
GtkWidget *remote_no_avahi;
|
||||||
|
GtkWidget *this_device_settings_entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(TeleportWindow, teleport_window, GTK_TYPE_APPLICATION_WINDOW);
|
G_DEFINE_TYPE_WITH_PRIVATE(TeleportWindow, teleport_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||||
@@ -60,6 +62,15 @@ change_download_directory_cb (GtkWidget *widget,
|
|||||||
g_free(newDownloadDir);
|
g_free(newDownloadDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_click_this_device_settings_button (GtkWidget *widget,
|
||||||
|
gpointer user_data) {
|
||||||
|
TeleportWindowPrivate *priv = (TeleportWindowPrivate *) user_data;
|
||||||
|
g_settings_set_string (priv->settings,
|
||||||
|
"device-name",
|
||||||
|
gtk_entry_get_text (GTK_ENTRY (priv->this_device_settings_entry)));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teleport_window_init (TeleportWindow *win)
|
teleport_window_init (TeleportWindow *win)
|
||||||
{
|
{
|
||||||
@@ -120,6 +131,27 @@ teleport_window_init (TeleportWindow *win)
|
|||||||
//g_object_unref (menu);
|
//g_object_unref (menu);
|
||||||
//g_object_unref (label);
|
//g_object_unref (label);
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
|
|
||||||
|
/* Add popover for device settings */
|
||||||
|
builder = gtk_builder_new_from_resource ("/com/frac_tion/teleport/device_settings.ui");
|
||||||
|
menu = GTK_WIDGET (gtk_builder_get_object (builder, "device-settings"));
|
||||||
|
gtk_menu_button_set_popover(GTK_MENU_BUTTON (priv->this_device_settings_button), menu);
|
||||||
|
|
||||||
|
priv->this_device_settings_entry = GTK_WIDGET (gtk_builder_get_object (builder,
|
||||||
|
"this_device_settings_entry"));
|
||||||
|
g_settings_bind (priv->settings,
|
||||||
|
"device-name",
|
||||||
|
priv->this_device_settings_entry,
|
||||||
|
"text",
|
||||||
|
G_SETTINGS_BIND_GET);
|
||||||
|
|
||||||
|
g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "this_device_settings_button")),
|
||||||
|
"clicked", G_CALLBACK (on_click_this_device_settings_button), priv);
|
||||||
|
|
||||||
|
g_signal_connect (priv->this_device_settings_entry,
|
||||||
|
"activate", G_CALLBACK (on_click_this_device_settings_button), priv);
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,6 +220,7 @@ teleport_window_class_init (TeleportWindowClass *class)
|
|||||||
"/com/frac_tion/teleport/window.ui");
|
"/com/frac_tion/teleport/window.ui");
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, gears);
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, gears);
|
||||||
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, this_device_settings_button);
|
||||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, this_device_name_label);
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, this_device_name_label);
|
||||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, remote_no_devices);
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, remote_no_devices);
|
||||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, remote_devices_box);
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportWindow, remote_devices_box);
|
||||||
|
|||||||
@@ -132,8 +132,8 @@
|
|||||||
<class name="linked"/>
|
<class name="linked"/>
|
||||||
</style>
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkMenuButton" id="this-device-settings-button">
|
<object class="GtkMenuButton" id="this_device_settings_button">
|
||||||
<property name="visible">False</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="use-popover">True</property>
|
<property name="use-popover">True</property>
|
||||||
<property name="height_request">35</property>
|
<property name="height_request">35</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user