Let plug-ins show windows and trigger messages as well
This commit is contained in:
parent
99302b8242
commit
8453eb9d3f
@ -39,6 +39,7 @@ typedef struct _PhonePluginHelper
|
|||||||
char const * variable, char const * value);
|
char const * variable, char const * value);
|
||||||
int (*error)(Phone * phone, char const * message, int ret);
|
int (*error)(Phone * phone, char const * message, int ret);
|
||||||
int (*event)(Phone * phone, PhoneEvent * event);
|
int (*event)(Phone * phone, PhoneEvent * event);
|
||||||
|
void (*message)(Phone * phone, PhoneMessage message, ...);
|
||||||
int (*request)(Phone * phone, ModemRequest * request);
|
int (*request)(Phone * phone, ModemRequest * request);
|
||||||
int (*trigger)(Phone * phone, ModemEventType event);
|
int (*trigger)(Phone * phone, ModemEventType event);
|
||||||
} PhonePluginHelper;
|
} PhonePluginHelper;
|
||||||
|
43
src/phone.c
43
src/phone.c
@ -300,6 +300,8 @@ static GtkWidget * _phone_messages_get_view(Phone * phone);
|
|||||||
static GtkWidget * _phone_progress_delete(GtkWidget * widget);
|
static GtkWidget * _phone_progress_delete(GtkWidget * widget);
|
||||||
static void _phone_progress_pulse(GtkWidget * widget);
|
static void _phone_progress_pulse(GtkWidget * widget);
|
||||||
|
|
||||||
|
static void _phone_message(Phone * phone, PhoneMessage message, ...);
|
||||||
|
|
||||||
static int _phone_request(Phone * phone, ModemRequest * request);
|
static int _phone_request(Phone * phone, ModemRequest * request);
|
||||||
|
|
||||||
static void _phone_show_contacts_dialog(Phone * phone, gboolean show,
|
static void _phone_show_contacts_dialog(Phone * phone, gboolean show,
|
||||||
@ -376,6 +378,7 @@ Phone * phone_new(char const * plugin, int retry)
|
|||||||
phone->helper.config_set = _phone_config_set;
|
phone->helper.config_set = _phone_config_set;
|
||||||
phone->helper.error = phone_error;
|
phone->helper.error = phone_error;
|
||||||
phone->helper.event = phone_event;
|
phone->helper.event = phone_event;
|
||||||
|
phone->helper.message = _phone_message;
|
||||||
phone->helper.request = _phone_request;
|
phone->helper.request = _phone_request;
|
||||||
phone->helper.trigger = _phone_trigger;
|
phone->helper.trigger = _phone_trigger;
|
||||||
phone->helper.phone = phone;
|
phone->helper.phone = phone;
|
||||||
@ -3255,6 +3258,46 @@ static void _phone_info(Phone * phone, GtkWidget * window, char const * message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* phone_message */
|
||||||
|
static void _phone_message(Phone * phone, PhoneMessage message, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
PhoneMessagePowerManagement power;
|
||||||
|
PhoneMessageShow show;
|
||||||
|
PhoneEvent event;
|
||||||
|
|
||||||
|
memset(&event, 0, sizeof(event));
|
||||||
|
va_start(ap, message);
|
||||||
|
switch(message)
|
||||||
|
{
|
||||||
|
case PHONE_MESSAGE_POWER_MANAGEMENT:
|
||||||
|
power = va_arg(ap, PhoneMessagePowerManagement);
|
||||||
|
if(power == PHONE_MESSAGE_POWER_MANAGEMENT_RESUME)
|
||||||
|
event.type = PHONE_EVENT_TYPE_SUSPEND;
|
||||||
|
else if(power == PHONE_MESSAGE_POWER_MANAGEMENT_SUSPEND)
|
||||||
|
event.type = PHONE_EVENT_TYPE_RESUME;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
phone_event(phone, &event);
|
||||||
|
break;
|
||||||
|
case PHONE_MESSAGE_SHOW:
|
||||||
|
show = va_arg(ap, PhoneMessageShow);
|
||||||
|
if(show == PHONE_MESSAGE_SHOW_CONTACTS)
|
||||||
|
phone_show_contacts(phone, TRUE);
|
||||||
|
else if(show == PHONE_MESSAGE_SHOW_DIALER)
|
||||||
|
phone_show_dialer(phone, TRUE);
|
||||||
|
else if(show == PHONE_MESSAGE_SHOW_LOGS)
|
||||||
|
phone_show_logs(phone, TRUE);
|
||||||
|
else if(show == PHONE_MESSAGE_SHOW_MESSAGES)
|
||||||
|
phone_show_messages(phone, TRUE);
|
||||||
|
else if(show == PHONE_MESSAGE_SHOW_SETTINGS)
|
||||||
|
phone_show_settings(phone, TRUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* phone_messages_filter_all */
|
/* phone_messages_filter_all */
|
||||||
static gboolean _phone_messages_filter_all(GtkTreeModel * model,
|
static gboolean _phone_messages_filter_all(GtkTreeModel * model,
|
||||||
GtkTreeIter * iter, gpointer data)
|
GtkTreeIter * iter, gpointer data)
|
||||||
|
@ -44,6 +44,8 @@ static int _systray_destroy(PhonePlugin * plugin);
|
|||||||
/* callbacks */
|
/* callbacks */
|
||||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||||
static void _systray_on_activate(gpointer data);
|
static void _systray_on_activate(gpointer data);
|
||||||
|
static void _systray_on_popup_menu(GtkStatusIcon * icon, guint button,
|
||||||
|
guint time, gpointer data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -90,6 +92,8 @@ static int _systray_init(PhonePlugin * plugin)
|
|||||||
systray->icon = gtk_status_icon_new_from_icon_name("phone-dialer");
|
systray->icon = gtk_status_icon_new_from_icon_name("phone-dialer");
|
||||||
g_signal_connect_swapped(systray->icon, "activate", G_CALLBACK(
|
g_signal_connect_swapped(systray->icon, "activate", G_CALLBACK(
|
||||||
_systray_on_activate), plugin);
|
_systray_on_activate), plugin);
|
||||||
|
g_signal_connect(systray->icon, "popup-menu", G_CALLBACK(
|
||||||
|
_systray_on_popup_menu), plugin);
|
||||||
systray->ab_window = NULL;
|
systray->ab_window = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
@ -144,4 +148,71 @@ static gboolean _activate_on_closex(gpointer data)
|
|||||||
gtk_widget_hide(systray->ab_window);
|
gtk_widget_hide(systray->ab_window);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* systray_on_popup_menu */
|
||||||
|
static void _popup_menu_on_show_dialer(gpointer data);
|
||||||
|
static void _popup_menu_on_show_logs(gpointer data);
|
||||||
|
static void _popup_menu_on_show_messages(gpointer data);
|
||||||
|
static void _popup_menu_on_show_settings(gpointer data);
|
||||||
|
|
||||||
|
static void _systray_on_popup_menu(GtkStatusIcon * icon, guint button,
|
||||||
|
guint time, gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
GtkWidget * menu;
|
||||||
|
GtkWidget * menuitem;
|
||||||
|
|
||||||
|
menu = gtk_menu_new();
|
||||||
|
menuitem = gtk_menu_item_new_with_mnemonic("Show _dialer");
|
||||||
|
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||||
|
_popup_menu_on_show_dialer), plugin);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
menuitem = gtk_menu_item_new_with_mnemonic("Show _logs");
|
||||||
|
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||||
|
_popup_menu_on_show_logs), plugin);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
menuitem = gtk_menu_item_new_with_mnemonic("Show _messages");
|
||||||
|
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||||
|
_popup_menu_on_show_messages), plugin);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
menuitem = gtk_menu_item_new_with_mnemonic("Show _settings");
|
||||||
|
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||||
|
_popup_menu_on_show_settings), plugin);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
gtk_widget_show_all(menu);
|
||||||
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _popup_menu_on_show_dialer(gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
|
||||||
|
plugin->helper->message(plugin->helper->phone, PHONE_MESSAGE_SHOW,
|
||||||
|
PHONE_MESSAGE_SHOW_DIALER);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _popup_menu_on_show_logs(gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
|
||||||
|
plugin->helper->message(plugin->helper->phone, PHONE_MESSAGE_SHOW,
|
||||||
|
PHONE_MESSAGE_SHOW_LOGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _popup_menu_on_show_messages(gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
|
||||||
|
plugin->helper->message(plugin->helper->phone, PHONE_MESSAGE_SHOW,
|
||||||
|
PHONE_MESSAGE_SHOW_MESSAGES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _popup_menu_on_show_settings(gpointer data)
|
||||||
|
{
|
||||||
|
PhonePlugin * plugin = data;
|
||||||
|
|
||||||
|
plugin->helper->message(plugin->helper->phone, PHONE_MESSAGE_SHOW,
|
||||||
|
PHONE_MESSAGE_SHOW_SETTINGS);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user