[gnome-panel/wip/muktupavels/remove-panel-applet-private: 1/2] applet-frame: remove GpAppletFrame
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/remove-panel-applet-private: 1/2] applet-frame: remove GpAppletFrame
- Date: Mon, 13 Apr 2020 22:07:13 +0000 (UTC)
commit b9b45d70bb842aa77b40710e9cc4c43531ce16a2
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Apr 14 00:46:54 2020 +0300
applet-frame: remove GpAppletFrame
gnome-panel/Makefile.am | 2 -
gnome-panel/gp-applet-frame.c | 249 ---------------------------------------
gnome-panel/gp-applet-frame.h | 35 ------
gnome-panel/gp-applet-manager.c | 14 +--
gnome-panel/panel-applet-frame.c | 197 +++++++++++++++++++++++++++++--
gnome-panel/panel-applet-frame.h | 23 +---
po/POTFILES.in | 1 -
7 files changed, 198 insertions(+), 323 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 59dd4d4b6..569567940 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -11,8 +11,6 @@ bin_PROGRAMS = \
panel_sources = \
gp-add-applet-window.c \
gp-add-applet-window.h \
- gp-applet-frame.c \
- gp-applet-frame.h \
gp-applet-manager.c \
gp-applet-manager.h \
gp-application.c \
diff --git a/gnome-panel/gp-applet-manager.c b/gnome-panel/gp-applet-manager.c
index 1ca52939a..6ecae9d50 100644
--- a/gnome-panel/gp-applet-manager.c
+++ b/gnome-panel/gp-applet-manager.c
@@ -19,12 +19,12 @@
#include <string.h>
-#include "gp-applet-frame.h"
#include "gp-applet-manager.h"
#include "gp-module-manager.h"
#include "libgnome-panel/gp-applet-info-private.h"
#include "libgnome-panel/gp-initial-setup-dialog-private.h"
#include "libgnome-panel/gp-module-private.h"
+#include "panel-applet-frame.h"
#include "panel-lockdown.h"
struct _GpAppletManager
@@ -224,8 +224,7 @@ gp_applet_manager_load_applet (GpAppletManager *self,
GVariant *initial_settings;
GError *error;
GpApplet *applet;
- GpAppletFrame *frame;
- PanelAppletFrame *applet_frame;
+ PanelAppletFrame *frame;
GtkWidget *widget;
g_return_val_if_fail (iid != NULL, FALSE);
@@ -291,18 +290,17 @@ gp_applet_manager_load_applet (GpAppletManager *self,
gp_applet_set_orientation (applet, orientation);
gp_applet_set_position (applet, position);
- frame = g_object_new (GP_TYPE_APPLET_FRAME, NULL);
- gp_applet_frame_set_applet (frame, applet);
+ frame = g_object_new (PANEL_TYPE_APPLET_FRAME, NULL);
- applet_frame = PANEL_APPLET_FRAME (frame);
- _panel_applet_frame_set_iid (applet_frame, iid);
+ _panel_applet_frame_set_applet (frame, applet);
+ _panel_applet_frame_set_iid (frame, iid);
widget = GTK_WIDGET (applet);
gtk_container_add (GTK_CONTAINER (frame), widget);
gtk_widget_show (widget);
- _panel_applet_frame_activated (applet_frame, frame_act, NULL);
+ _panel_applet_frame_activated (frame, frame_act, NULL);
return TRUE;
}
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 3c3b94da6..d21ff687b 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -4,6 +4,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2016 - 2020 Alberts Muktupāvels
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -68,6 +69,8 @@ struct _PanelAppletFramePrivate {
PanelOrientation orientation;
+ GpApplet *applet;
+
gchar *iid;
GtkAllocation child_allocation;
@@ -326,6 +329,81 @@ button_event_in_rect (GdkEventButton *event,
return FALSE;
}
+static void
+popup_menu (GtkMenu *menu,
+ GpApplet *applet)
+{
+ gtk_menu_attach_to_widget (menu, GTK_WIDGET (applet), NULL);
+
+ gp_applet_popup_menu_at_widget (applet,
+ menu,
+ GTK_WIDGET (applet),
+ NULL);
+}
+
+static void
+move_cb (GtkMenuItem *menuitem,
+ PanelAppletFrame *self)
+{
+ _panel_applet_frame_applet_move (self);
+}
+
+static void
+remove_cb (GtkMenuItem *menuitem,
+ PanelAppletFrame *self)
+{
+ gp_applet_remove_from_panel (self->priv->applet);
+
+ _panel_applet_frame_applet_remove (self);
+}
+
+static void
+frame_popup_edit_menu (PanelAppletFrame *self,
+ guint button,
+ guint32 timestamp)
+{
+ GtkWidget *menu;
+ GtkWidget *menuitem;
+ gboolean movable;
+ gboolean removable;
+
+ menu = gtk_menu_new ();
+
+ movable = _panel_applet_frame_get_can_move (self);
+ removable = panel_layout_is_writable ();
+
+ menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_widget_show (menuitem);
+
+ g_signal_connect (menuitem, "activate", G_CALLBACK (move_cb), self);
+ gtk_widget_set_sensitive (menuitem, movable);
+
+ menuitem = gtk_menu_item_new_with_mnemonic (_("_Remove From Panel"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_widget_show (menuitem);
+
+ g_signal_connect (menuitem, "activate", G_CALLBACK (remove_cb), self);
+ gtk_widget_set_sensitive (menuitem, removable);
+
+ popup_menu (GTK_MENU (menu), self->priv->applet);
+}
+
+static void
+frame_popup_menu (PanelAppletFrame *self,
+ guint button,
+ guint32 timestamp)
+{
+ GtkWidget *menu;
+
+ menu = gp_applet_get_menu (self->priv->applet);
+
+ if (menu == NULL)
+ return;
+
+ popup_menu (GTK_MENU (menu), self->priv->applet);
+}
+
static gboolean
panel_applet_frame_button_changed (GtkWidget *widget,
GdkEventButton *event)
@@ -365,13 +443,9 @@ panel_applet_frame_button_changed (GtkWidget *widget,
gdk_seat_ungrab (seat);
if (modifiers == panel_bindings_get_mouse_button_modifier_keymask ())
- PANEL_APPLET_FRAME_GET_CLASS (frame)->popup_edit_menu (frame,
- event->button,
- event->time);
+ frame_popup_edit_menu (frame, event->button, event->time);
else
- PANEL_APPLET_FRAME_GET_CLASS (frame)->popup_menu (frame,
- event->button,
- event->time);
+ frame_popup_menu (frame, event->button, event->time);
return TRUE;
} else if (event->type == GDK_BUTTON_RELEASE)
@@ -490,9 +564,47 @@ panel_applet_frame_init (PanelAppletFrame *frame)
}
static void
-panel_applet_frame_init_properties (PanelAppletFrame *frame)
+update_flags (PanelAppletFrame *self)
+{
+ GpAppletFlags flags;
+ gboolean major;
+ gboolean minor;
+ gboolean has_handle;
+
+ flags = gp_applet_get_flags (self->priv->applet);
+
+ major = (flags & GP_APPLET_FLAGS_EXPAND_MAJOR) != 0;
+ minor = (flags & GP_APPLET_FLAGS_EXPAND_MINOR) != 0;
+ has_handle = (flags & GP_APPLET_FLAGS_HAS_HANDLE) != 0;
+
+ _panel_applet_frame_update_flags (self, major, minor, has_handle);
+}
+
+static void
+update_size_hints (PanelAppletFrame *self)
{
- PANEL_APPLET_FRAME_GET_CLASS (frame)->init_properties (frame);
+ guint n_elements;
+ gint *size_hints;
+
+ size_hints = gp_applet_get_size_hints (self->priv->applet, &n_elements);
+
+ _panel_applet_frame_update_size_hints (self, size_hints, n_elements);
+}
+
+static void
+panel_applet_frame_init_properties (PanelAppletFrame *self)
+{
+ update_flags (self);
+ update_size_hints (self);
+}
+
+static void
+frame_sync_menu_state (PanelAppletFrame *self,
+ gboolean movable,
+ gboolean removable,
+ gboolean locked_down)
+{
+ gp_applet_set_locked_down (self->priv->applet, locked_down);
}
static void
@@ -508,7 +620,41 @@ panel_applet_frame_sync_menu_state (PanelLockdown *lockdown,
removable = panel_layout_is_writable ();
locked_down = panel_lockdown_get_panels_locked_down_s ();
- PANEL_APPLET_FRAME_GET_CLASS (frame)->sync_menu_state (frame, movable, removable, locked_down);
+ frame_sync_menu_state (frame, movable, removable, locked_down);
+}
+
+static void
+frame_change_orientation (PanelAppletFrame *self,
+ PanelOrientation panel_orientation)
+{
+ GtkOrientation orientation;
+ GtkPositionType position;
+
+ switch (panel_orientation)
+ {
+ case PANEL_ORIENTATION_BOTTOM:
+ orientation = GTK_ORIENTATION_HORIZONTAL;
+ position = GTK_POS_BOTTOM;
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ orientation = GTK_ORIENTATION_VERTICAL;
+ position = GTK_POS_LEFT;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ orientation = GTK_ORIENTATION_VERTICAL;
+ position = GTK_POS_RIGHT;
+ break;
+ case PANEL_ORIENTATION_TOP:
+ orientation = GTK_ORIENTATION_HORIZONTAL;
+ position = GTK_POS_TOP;
+ default:
+ break;
+ }
+
+ gp_applet_set_orientation (self->priv->applet, orientation);
+ gp_applet_set_position (self->priv->applet, position);
+
+ gtk_widget_queue_resize (GTK_WIDGET (self));
}
void
@@ -532,7 +678,7 @@ panel_applet_frame_change_orientation (PanelAppletFrame *frame,
}
gtk_widget_reset_style (GTK_WIDGET (frame));
- PANEL_APPLET_FRAME_GET_CLASS (frame)->change_orientation (frame, orientation);
+ frame_change_orientation (frame, orientation);
}
void
@@ -545,6 +691,37 @@ panel_applet_frame_set_panel (PanelAppletFrame *frame,
frame->priv->panel = panel;
}
+static void
+flags_changed_cb (GpApplet *applet,
+ PanelAppletFrame *self)
+{
+ update_flags (self);
+}
+
+static void
+size_hints_changed_cb (GpApplet *applet,
+ PanelAppletFrame *self)
+{
+ update_size_hints (self);
+}
+
+void
+_panel_applet_frame_set_applet (PanelAppletFrame *self,
+ GpApplet *applet)
+{
+ self->priv->applet = applet;
+
+ g_signal_connect (applet,
+ "flags-changed",
+ G_CALLBACK (flags_changed_cb),
+ self);
+
+ g_signal_connect (applet,
+ "size-hints-changed",
+ G_CALLBACK (size_hints_changed_cb),
+ self);
+}
+
void
_panel_applet_frame_set_iid (PanelAppletFrame *frame,
const gchar *iid)
diff --git a/gnome-panel/panel-applet-frame.h b/gnome-panel/panel-applet-frame.h
index 84df78495..ee66f95c6 100644
--- a/gnome-panel/panel-applet-frame.h
+++ b/gnome-panel/panel-applet-frame.h
@@ -2,6 +2,7 @@
* panel-applet-frame.h: panel side container for applets
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2016 - 2020 Alberts Muktupāvels
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -25,6 +26,7 @@
#include <gtk/gtk.h>
+#include "libgnome-panel/gp-applet-private.h"
#include "panel-widget.h"
#include "applet.h"
@@ -46,24 +48,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (PanelAppletFrame, g_object_unref)
struct _PanelAppletFrameClass {
GtkEventBoxClass parent_class;
- void (*init_properties) (PanelAppletFrame *frame);
-
- void (*sync_menu_state) (PanelAppletFrame *frame,
- gboolean movable,
- gboolean removable,
- gboolean locked_down);
-
- void (*popup_menu) (PanelAppletFrame *frame,
- guint button,
- guint32 timestamp);
-
- void (*popup_edit_menu) (PanelAppletFrame *frame,
- guint button,
- guint32 timestamp);
-
- void (*change_orientation) (PanelAppletFrame *frame,
- PanelOrientation orientation);
-
void (*move_focus_out_of_applet) (PanelAppletFrame *frame,
GtkDirectionType direction);
};
@@ -102,6 +86,9 @@ gboolean panel_applet_frame_activating_get_locked_down (PanelAppletFram
gchar *panel_applet_frame_activating_get_settings_path (PanelAppletFrameActivating *frame_act);
gchar *panel_applet_frame_activating_get_initial_settings_path (PanelAppletFrameActivating
*frame_act);
+void _panel_applet_frame_set_applet (PanelAppletFrame *self,
+ GpApplet *applet);
+
void _panel_applet_frame_set_iid (PanelAppletFrame *frame,
const gchar *iid);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b21d2110c..113c15fc4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,7 +12,6 @@ gnome-panel/applet.c
gnome-panel/button-widget.c
gnome-panel/gnome-panel.desktop.in
gnome-panel/gp-add-applet-window.c
-gnome-panel/gp-applet-frame.c
gnome-panel/gp-arrow-button.c
gnome-panel/gp-main.c
gnome-panel/gp-properties-dialog.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]