Commit 73a73aba authored by Guido Günther's avatar Guido Günther

basic surface raise support via list box

TODO: use a flowbox
parent 80ee8a3f
......@@ -40,6 +40,10 @@
<arg name="app_id" type="string" summary="The app_id of the view"/>
</request>
<request name="destroy" type="destructor" since="2">
<description summary="destroy the app_switcher interface instance"/>
</request>
<event name="app" since="2">
<description summary="report a running application"/>
<arg name="app_id" type="string" summary="the app_id of the application"/>
......
......@@ -28,10 +28,18 @@ static guint signals[N_SIGNALS] = { 0 };
typedef struct
{
GtkWidget *sw_favorites;
GtkWidget *evbox;
/* Favorites */
GtkWidget *sw_favorites;
GtkWidget *fb_favorites;
GSettings *settings;
/* Running apps */
GtkWidget *lb_running_apps;
GtkWidget *box_running_apps;
struct phosh_private_app_switcher *app_switcher;
} PhoshFavoritesPrivate;
......@@ -43,11 +51,43 @@ struct _PhoshFavorites
G_DEFINE_TYPE_WITH_PRIVATE(PhoshFavorites, phosh_favorites, GTK_TYPE_WINDOW)
void
row_activated_cb (GtkListBox *box, GtkListBoxRow *row, gpointer user_data)
{
PhoshFavorites *self = user_data;
PhoshFavoritesPrivate *priv;
GtkWidget *label;
const gchar *app_id;
g_return_if_fail (PHOSH_IS_FAVORITES (self));
priv = phosh_favorites_get_instance_private (self);
g_return_if_fail (priv->app_switcher);
label = gtk_bin_get_child (GTK_BIN (row));
g_return_if_fail (label);
app_id = gtk_label_get_label (GTK_LABEL (label));
g_return_if_fail (app_id);
g_debug("Will raise %s", app_id);
phosh_private_app_switcher_raise_app (priv->app_switcher, app_id);
}
void handle_app_switcher_app(
void *data, struct phosh_private_app_switcher *phosh_private_app_switcher,
const char *app_id)
{
g_warning ("got app");
PhoshFavorites *self = data;
PhoshFavoritesPrivate *priv;
GtkWidget *label;
g_return_if_fail (PHOSH_IS_FAVORITES (self));
priv = phosh_favorites_get_instance_private (self);
g_debug ("Found app %s", app_id);
label = gtk_label_new (app_id);
gtk_list_box_insert (GTK_LIST_BOX (priv->lb_running_apps), label, -1);
}
......@@ -55,7 +95,7 @@ void handle_app_switcher_list_apps_done(
void *data,
struct phosh_private_app_switcher *phosh_private_app_switcher)
{
g_warning ("got all apps");
g_debug ("Got all apps");
}
......@@ -66,18 +106,18 @@ static const struct phosh_private_app_switcher_listener app_switcher_listener =
static void
get_apps (PhoshFavorites *self)
fill_apps (PhoshFavorites *self)
{
PhoshFavoritesPrivate *priv = phosh_favorites_get_instance_private (self);
struct phosh_private *phosh_private;
struct phosh_private_app_switcher *app_switcher;
g_debug("Getting current app list from wlroots");
phosh_private = phosh_wayland_get_phosh_private (
phosh_wayland_get_default ());
g_return_if_fail (phosh_private);
app_switcher = phosh_private_get_app_switcher (phosh_private);
phosh_private_app_switcher_add_listener (app_switcher, &app_switcher_listener, self);
priv->app_switcher = phosh_private_get_app_switcher (phosh_private);
phosh_private_app_switcher_add_listener (priv->app_switcher, &app_switcher_listener, self);
phosh_private_app_switcher_list_apps (priv->app_switcher);
}
......@@ -264,7 +304,11 @@ phosh_favorites_constructed (GObject *object)
favorites_changed (priv->settings, "favorites", self);
/* Running Apps */
get_apps (self);
fill_apps (self);
g_signal_connect (priv->lb_running_apps,
"row-activated",
G_CALLBACK (row_activated_cb),
self);
}
......@@ -276,6 +320,11 @@ phosh_favorites_dispose (GObject *object)
g_clear_object (&priv->settings);
if (priv->app_switcher) {
// FIXME: phosh_app_switcher_destroy (priv->phosh_app_switcher);
priv->app_switcher = NULL;
}
G_OBJECT_CLASS (phosh_favorites_parent_class)->dispose (object);
}
......@@ -294,6 +343,8 @@ phosh_favorites_class_init (PhoshFavoritesClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, evbox);
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, sw_favorites);
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, lb_running_apps);
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, box_running_apps);
signals[APP_LAUNCHED] = g_signal_new ("app-launched",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
......
......@@ -8,75 +8,73 @@
<placeholder/>
</child>
<child>
<object class="GtkEventBox" id="evbox">
<property name="name">evbox</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkBox" id="box_running_apps">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Running Applications</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="lb_running_apps">
<property name="name">lb_runnng_apps</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="selection_mode">none</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<property name="label" translatable="yes">Running Applications</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="lb_running_apps">
<property name="name">lb_runnng_apps</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="selection_mode">none</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_favorites">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Favorites</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkEventBox" id="evbox">
<property name="name">evbox</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Favorites</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="sw_favorites">
<property name="name">sw_favorites</property>
......@@ -87,20 +85,20 @@
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment