[feat] add menu popover

This commit is contained in:
Julian Sparber
2017-02-22 23:58:49 +01:00
parent 616c0e5e54
commit 74d5d6f92b
2 changed files with 92 additions and 424 deletions

View File

@@ -8,28 +8,80 @@ struct _TeleportAppWindow
GtkApplicationWindow parent; GtkApplicationWindow parent;
}; };
G_DEFINE_TYPE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW); typedef struct _TeleportAppWindowPrivate TeleportAppWindowPrivate;
struct _TeleportAppWindowPrivate
{
GSettings *settings;
GtkWidget *gears;
};
G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW);
static void static void
teleport_app_window_init (TeleportAppWindow *win) teleport_app_window_init (TeleportAppWindow *win)
{ {
TeleportAppWindowPrivate *priv;
GtkBuilder *builder; GtkBuilder *builder;
GMenuModel *menu; GMenuModel *menu;
GAction *action; //GAction *action;
priv = teleport_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win)); gtk_widget_init_template (GTK_WIDGET (win));
builder = gtk_builder_new_from_resource ("/org/gtk/teleportapp/settings.ui"); builder = gtk_builder_new_from_resource ("/org/gtk/teleportapp/settings.ui");
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu")); menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
g_object_unref (builder); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
//action = g_settings_create_action (priv->settings, "show-words");
//g_action_map_add_action (G_ACTION_MAP (win), action);
/*
const gchar *authors[] = {
"Julian Sparber <julian@sparber.net>",
NULL
};
gtk_show_about_dialog (parent,
"authors", authors,
"comments", "",
"copyright", "Copyright \xc2\xa9 2017 Julian Sparber",
"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);
}
static void
teleport_app_window_dispose (GObject *object)
{
TeleportAppWindow *win;
TeleportAppWindowPrivate *priv;
win = TELEPORT_APP_WINDOW (object);
priv = teleport_app_window_get_instance_private (win);
//g_clear_object (&priv->settings);
G_OBJECT_CLASS (teleport_app_window_parent_class)->dispose (object);
} }
static void static void
teleport_app_window_class_init (TeleportAppWindowClass *class) teleport_app_window_class_init (TeleportAppWindowClass *class)
{ {
G_OBJECT_CLASS (class)->dispose = teleport_app_window_dispose;
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class), gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/teleportapp/window.ui"); "/org/gtk/teleportapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, gears);
} }
TeleportAppWindow * TeleportAppWindow *
@@ -42,4 +94,6 @@ teleport_app_window_new (TeleportApp *app)
teleport_app_window_open (TeleportAppWindow *win, teleport_app_window_open (TeleportAppWindow *win,
GFile *file) GFile *file)
{ {
TeleportAppWindowPrivate *priv;
priv = teleport_app_window_get_instance_private (win);
} }

View File

@@ -89,7 +89,6 @@
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Angela's Thinkpad</property> <property name="label" translatable="yes">Angela's Thinkpad</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">primary-button-chooser-grid</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -99,7 +98,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="primary-button-description"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
@@ -122,7 +121,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkGrid" id="primary-button-chooser-grid"> <object class="GtkGrid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="valign">center</property> <property name="valign">center</property>
@@ -167,174 +166,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="mouse-frame"> <object class="GtkFrame" id="remote-devices-frame">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="shadow_type">none</property>
<property name="label_yalign">0.45</property>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Mouse</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkFrame" id="mouse-frame-listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="mouse-listbox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="mouse-row">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">false</property>
<child>
<object class="GtkGrid" id="mouse-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">8</property>
<property name="margin_bottom">8</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="mouse-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="valign">end</property>
<property name="label" translatable="yes">Mouse Speed</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">primary-button-chooser-grid</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="GtkScale" id="mouse-speed-scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="draw_value">False</property>
<property name="width-request">300</property>
<property name="halign">end</property>
<property name="expand">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="mouse_speed_scale-atkobject">
<property name="AtkObject::accessible-description" translatable="yes">Double-click timeout</property>
</object>
</child>
</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>
<child>
<object class="GtkListBoxRow" id="mouse-natural-scrolling-row">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">false</property>
<child>
<object class="GtkGrid" id="mouse-natural-scrolling-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="mouse-natural-scrolling-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" comments="Translators: This switch reverses the scrolling direction for mices. The term used comes from OS X so use the same translation if possible.">Natural Scrolling</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">mouse-natural-scrolling-switch</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="mouse-natural-scrolling-description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Scrolling moves the content, not the view.</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="GtkSwitch" id="mouse-natural-scrolling-switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</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>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFrame" id="touchpad-frame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">12</property> <property name="margin_top">12</property>
@@ -342,7 +174,7 @@
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<property name="label_yalign">0.45</property> <property name="label_yalign">0.45</property>
<child type="label"> <child type="label">
<object class="GtkLabel" id="label3"> <object class="GtkLabel" id="remote-devices-network-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
@@ -353,29 +185,29 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="touchpad-frame-listbox"> <object class="GtkFrame" id="remote-devices-frame-listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
<property name="margin_bottom">12</property> <property name="margin_bottom">12</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkBox" id="touchpad-box"> <object class="GtkBox" id="remote-devices-box">
<property name="visible">True</property> <property name="visible">True</property>
<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="touchpad-listbox"> <object class="GtkListBox" id="remote-devices-listbox">
<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> <child>
<object class="GtkListBoxRow" id="touchpad-toggle-row"> <object class="GtkListBoxRow" id="remote-devices-toggle-row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="touchpad-toggle-grid"> <object class="GtkGrid" id="remote-devices-toggle-grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@@ -386,15 +218,14 @@
<property name="margin_bottom">6</property> <property name="margin_bottom">6</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="touchpad-toggle-label"> <object class="GtkLabel" id="remote-devices-toggle-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Touchpad</property> <property name="label" translatable="yes">Kim's Librem</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">touchpad-toggle-switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -404,12 +235,33 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="touchpad-toggle-switch"> <object class="GtkLabel" id="remote-devics-description-1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Drag and drop files here to send it</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-devices-send-file-btn">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">send File</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@@ -457,9 +309,8 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes" comments="Translators: This switch reverses the scrolling direction for touchpads. The term used comes from OS X so use the same translation if possible. ">Natural Scrolling</property> <property name="label" translatable="yes">Progressbar</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">touchpad-natural-scrolling-switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -468,26 +319,6 @@
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="touchpad-natural-scrolling-description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Scrolling moves the content, not the view.</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> <child>
<object class="GtkSwitch" id="touchpad-natural-scrolling-switch"> <object class="GtkSwitch" id="touchpad-natural-scrolling-switch">
<property name="visible">True</property> <property name="visible">True</property>
@@ -506,222 +337,6 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkListBoxRow" id="touchpad-speed-row">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">false</property>
<child>
<object class="GtkGrid" id="touchpad-speed-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">8</property>
<property name="margin_bottom">8</property>
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="touchpad-speed-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="valign">end</property>
<property name="label" translatable="yes">Touchpad Speed</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">touchpad-speed-scale</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="GtkScale" id="touchpad-speed-scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment11</property>
<property name="draw_value">False</property>
<property name="expand">True</property>
<property name="halign">end</property>
<child internal-child="accessible">
<object class="AtkObject" id="touchpad_speed_scale-atkobject">
<property name="AtkObject::accessible-description" translatable="yes">Double-click timeout</property>
</object>
</child>
</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>
<child>
<object class="GtkListBoxRow" id="tap-to-click-row">
<property name="visible">False</property>
<property name="can_focus">True</property>
<property name="activatable">false</property>
<child>
<object class="GtkGrid" id="tap-to-click-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="tap-to-click-label">
<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">Tap to Click</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">tap-to-click-switch</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="GtkSwitch" id="tap-to-click-switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</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>
<child>
<object class="GtkListBoxRow" id="two-finger-scrolling-row">
<property name="visible">False</property>
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
<property name="activatable">false</property>
<child>
<object class="GtkGrid" id="two-finger-scrolling-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="two-finger-scrolling-label">
<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">Two-finger Scrolling</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">two-finger-scrolling-switch</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="GtkSwitch" id="two-finger-scrolling-switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</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>
<child>
<object class="GtkListBoxRow" id="edge-scrolling-row">
<property name="visible">False</property>
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
<property name="activatable">false</property>
<child>
<object class="GtkGrid" id="edge-scrolling-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="edge-scrolling-label">
<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">Edge Scrolling</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edge-scrolling-switch</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="GtkSwitch" id="edge-scrolling-switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</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>
</object> </object>
@@ -733,7 +348,6 @@
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child type="titlebar"> <child type="titlebar">
<object class="GtkHeaderBar" id="header"> <object class="GtkHeaderBar" id="header">