From 176b0599f3ff48fc1969222cd7f8282da2549359 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 29 May 2011 01:21:41 +0000 Subject: [PATCH] Unifiying the plugin API --- include/Panel.h | 4 ++-- src/applets/keyboard.c | 6 +++--- src/applets/main.c | 15 +++++++++++++-- src/common.h | 2 ++ src/panel.c | 36 +++++++++++++++++------------------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/include/Panel.h b/include/Panel.h index c719120..5d57255 100644 --- a/include/Panel.h +++ b/include/Panel.h @@ -39,8 +39,8 @@ typedef struct _PanelAppletHelper void (*about_dialog)(Panel * panel); int (*lock)(Panel * panel); void (*logout_dialog)(Panel * panel); - void (*position_menu)(GtkMenu * menu, gint * x, gint * y, - gboolean * push_in, gpointer data); + void (*position_menu)(Panel * panel, GtkMenu * menu, gint * x, gint * y, + gboolean * push_in); void (*preferences_dialog)(Panel * panel); void (*shutdown_dialog)(Panel * panel); int (*suspend)(Panel * panel); diff --git a/src/applets/keyboard.c b/src/applets/keyboard.c index 55f0106..87eb8b6 100644 --- a/src/applets/keyboard.c +++ b/src/applets/keyboard.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2010 Pierre Pronchery */ +/* Copyright (c) 2011 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -227,8 +227,8 @@ static void _on_keyboard_toggled(GtkWidget * widget, gpointer data) _init_idle(keyboard); if(keyboard->window == NULL) return; - keyboard->helper->position_menu((GtkMenu*)keyboard->window, &x, &y, - &push_in, keyboard->helper->panel); + keyboard->helper->position_menu(keyboard->helper->panel, + (GtkMenu*)keyboard->window, &x, &y, &push_in); gtk_window_move(GTK_WINDOW(keyboard->window), x, y); if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) gtk_widget_show(keyboard->window); diff --git a/src/applets/main.c b/src/applets/main.c index 807d077..5650996 100644 --- a/src/applets/main.c +++ b/src/applets/main.c @@ -288,6 +288,9 @@ static void _on_about(gpointer data) /* on_clicked */ +static void _clicked_position_menu(GtkMenu * menu, gint * x, gint * y, + gboolean * push_in, gpointer data); + static void _on_clicked(gpointer data) { Main * main = data; @@ -336,8 +339,16 @@ static void _on_clicked(gpointer data) _on_shutdown), data); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); gtk_widget_show_all(menu); - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, main->helper->position_menu, - main->helper->panel, 0, gtk_get_current_event_time()); + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, _clicked_position_menu, + main, 0, gtk_get_current_event_time()); +} + +static void _clicked_position_menu(GtkMenu * menu, gint * x, gint * y, + gboolean * push_in, gpointer data) +{ + Main * main = data; + + main->helper->position_menu(main->helper->panel, menu, x, y, push_in); } diff --git a/src/common.h b/src/common.h index 7fb581f..036e8e7 100644 --- a/src/common.h +++ b/src/common.h @@ -55,6 +55,8 @@ typedef struct _PanelPrefs # define PANEL_CLIENT_MESSAGE "DEFORAOS_DESKTOP_PANEL_CLIENT" +# define PANEL_CONFIG_FILE ".panel" + # define PANEL_ICON_SIZE_DEFAULT "panel-large" # define PANEL_ICON_SIZE_UNSET NULL # define PANEL_ICON_SIZE_SMALL "panel-small" diff --git a/src/panel.c b/src/panel.c index 01c63ff..d2d32f7 100644 --- a/src/panel.c +++ b/src/panel.c @@ -81,8 +81,6 @@ struct _Panel /* constants */ -#define PANEL_CONFIG_FILE ".panel" - static char const * _authors[] = { "Pierre Pronchery ", @@ -122,12 +120,12 @@ static int _panel_helper_lock(Panel * panel); #ifndef EMBEDDED static void _panel_helper_logout_dialog(Panel * panel); #endif -static void _panel_helper_position_menu(GtkMenu * menu, gint * x, gint * y, - gboolean * push_in, PanelPosition position, gpointer data); -static void _panel_helper_position_menu_bottom(GtkMenu * menu, gint * x, - gint * y, gboolean * push_in, gpointer data); -static void _panel_helper_position_menu_top(GtkMenu * menu, gint * x, gint * y, - gboolean * push_in, gpointer data); +static void _panel_helper_position_menu(Panel * panel, GtkMenu * menu, gint * x, + gint * y, gboolean * push_in, PanelPosition position); +static void _panel_helper_position_menu_bottom(Panel * panel, GtkMenu * menu, + gint * x, gint * y, gboolean * push_in); +static void _panel_helper_position_menu_top(Panel * panel, GtkMenu * menu, + gint * x, gint * y, gboolean * push_in); static void _panel_helper_preferences_dialog(Panel * panel); static void _panel_helper_shutdown_dialog(Panel * panel); static int _panel_helper_suspend(Panel * panel); @@ -684,6 +682,7 @@ static void _preferences_on_ok(gpointer data) /* private */ /* functions */ +/* config_get_filename */ static char * _config_get_filename(void) { char const * homedir; @@ -866,10 +865,9 @@ static void _logout_dialog_on_response(GtkWidget * widget, gint response) /* panel_helper_position_menu */ -static void _panel_helper_position_menu(GtkMenu * menu, gint * x, gint * y, - gboolean * push_in, PanelPosition position, gpointer data) +static void _panel_helper_position_menu(Panel * panel, GtkMenu * menu, gint * x, + gint * y, gboolean * push_in, PanelPosition position) { - Panel * panel = data; GtkRequisition req; gtk_widget_size_request(GTK_WIDGET(menu), &req); @@ -893,20 +891,20 @@ static void _panel_helper_position_menu(GtkMenu * menu, gint * x, gint * y, /* panel_helper_position_menu_bottom */ -static void _panel_helper_position_menu_bottom(GtkMenu * menu, gint * x, - gint * y, gboolean * push_in, gpointer data) +static void _panel_helper_position_menu_bottom(Panel * panel, GtkMenu * menu, + gint * x, gint * y, gboolean * push_in) { - _panel_helper_position_menu(menu, x, y, push_in, PANEL_POSITION_BOTTOM, - data); + _panel_helper_position_menu(panel, menu, x, y, push_in, + PANEL_POSITION_BOTTOM); } /* panel_helper_position_menu_top */ -static void _panel_helper_position_menu_top(GtkMenu * menu, gint * x, gint * y, - gboolean * push_in, gpointer data) +static void _panel_helper_position_menu_top(Panel * panel, GtkMenu * menu, + gint * x, gint * y, gboolean * push_in) { - _panel_helper_position_menu(menu, x, y, push_in, PANEL_POSITION_TOP, - data); + _panel_helper_position_menu(panel, menu, x, y, push_in, + PANEL_POSITION_TOP); }