Updated the plug-in API for consistency with Phone's own plug-in API
This commit is contained in:
parent
a9e5f57efe
commit
6bc347e88b
|
@ -23,19 +23,21 @@
|
||||||
|
|
||||||
/* PanelApplet */
|
/* PanelApplet */
|
||||||
/* types */
|
/* types */
|
||||||
|
typedef struct _Panel Panel;
|
||||||
|
|
||||||
typedef struct _PanelApplet PanelApplet;
|
typedef struct _PanelApplet PanelApplet;
|
||||||
|
|
||||||
typedef struct _PanelAppletHelper
|
typedef struct _PanelAppletHelper
|
||||||
{
|
{
|
||||||
|
Panel * panel;
|
||||||
GtkIconSize icon_size;
|
GtkIconSize icon_size;
|
||||||
char const * (*config_get)(void * priv, char const * section,
|
char const * (*config_get)(Panel * panel, char const * section,
|
||||||
char const * variable);
|
char const * variable);
|
||||||
int (*error)(void * priv, char const * message, int ret);
|
int (*error)(Panel * panel, char const * message, int ret);
|
||||||
int (*logout_dialog)(void);
|
int (*logout_dialog)(void);
|
||||||
void (*position_menu)(GtkMenu * menu, gint * x, gint * y,
|
void (*position_menu)(GtkMenu * menu, gint * x, gint * y,
|
||||||
gboolean * push_in, gpointer data);
|
gboolean * push_in, gpointer data);
|
||||||
int (*shutdown_dialog)(void);
|
int (*shutdown_dialog)(void);
|
||||||
void * priv;
|
|
||||||
} PanelAppletHelper;
|
} PanelAppletHelper;
|
||||||
|
|
||||||
typedef GtkWidget * (*PanelAppletInitFunc)(PanelApplet * applet);
|
typedef GtkWidget * (*PanelAppletInitFunc)(PanelApplet * applet);
|
||||||
|
|
17
po/fr.po
17
po/fr.po
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Panel 0.0.5\n"
|
"Project-Id-Version: Panel 0.0.5\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2010-08-08 00:11+0200\n"
|
"POT-Creation-Date: 2010-08-10 00:58+0200\n"
|
||||||
"PO-Revision-Date: 2010-04-22 12:45+0200\n"
|
"PO-Revision-Date: 2010-04-22 12:45+0200\n"
|
||||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||||
"Language-Team: French\n"
|
"Language-Team: French\n"
|
||||||
|
@ -20,7 +20,8 @@ msgstr ""
|
||||||
msgid "Unknown"
|
msgid "Unknown"
|
||||||
msgstr "Inconnu"
|
msgstr "Inconnu"
|
||||||
|
|
||||||
#: ../src/applets/battery.c:182 ../src/run.c:196 ../src/run.c:200
|
#: ../src/applets/battery.c:182 ../src/panel.c:297 ../src/run.c:196
|
||||||
|
#: ../src/run.c:200
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr "Erreur"
|
msgstr "Erreur"
|
||||||
|
|
||||||
|
@ -61,8 +62,8 @@ msgstr "Verrouiller l'écran"
|
||||||
msgid "Logging out is disabled"
|
msgid "Logging out is disabled"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/applets/logout.c:67 ../src/panel.c:396 ../src/panel.c:401
|
#: ../src/applets/logout.c:67 ../src/panel.c:391 ../src/panel.c:396
|
||||||
#: ../src/panel.c:409
|
#: ../src/panel.c:404
|
||||||
msgid "Logout"
|
msgid "Logout"
|
||||||
msgstr "Déconnexion"
|
msgstr "Déconnexion"
|
||||||
|
|
||||||
|
@ -134,25 +135,25 @@ msgstr "Déplacer vers le bureau"
|
||||||
msgid "Maximize"
|
msgid "Maximize"
|
||||||
msgstr "Maximiser"
|
msgstr "Maximiser"
|
||||||
|
|
||||||
#: ../src/panel.c:388
|
#: ../src/panel.c:383
|
||||||
msgid ""
|
msgid ""
|
||||||
"This will log you out of the current session, therefore closing any "
|
"This will log you out of the current session, therefore closing any "
|
||||||
"application currently opened and losing any unsaved data.\n"
|
"application currently opened and losing any unsaved data.\n"
|
||||||
"Do you really want to proceed?"
|
"Do you really want to proceed?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/panel.c:449
|
#: ../src/panel.c:444
|
||||||
msgid ""
|
msgid ""
|
||||||
"This will shutdown your computer, therefore closing any application "
|
"This will shutdown your computer, therefore closing any application "
|
||||||
"currently opened and losing any unsaved data.\n"
|
"currently opened and losing any unsaved data.\n"
|
||||||
"Do you really want to proceed?"
|
"Do you really want to proceed?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/panel.c:465 ../src/panel.c:470 ../src/panel.c:477
|
#: ../src/panel.c:460 ../src/panel.c:465 ../src/panel.c:472
|
||||||
msgid "Shutdown"
|
msgid "Shutdown"
|
||||||
msgstr "Arrêter"
|
msgstr "Arrêter"
|
||||||
|
|
||||||
#: ../src/panel.c:469
|
#: ../src/panel.c:464
|
||||||
msgid "Restart"
|
msgid "Restart"
|
||||||
msgstr "Redémarrer"
|
msgstr "Redémarrer"
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ static GtkWidget * _clock_init(PanelApplet * applet)
|
||||||
applet->priv = clock;
|
applet->priv = clock;
|
||||||
clock->helper = applet->helper;
|
clock->helper = applet->helper;
|
||||||
clock->label = gtk_label_new(" \n ");
|
clock->label = gtk_label_new(" \n ");
|
||||||
if((clock->format = applet->helper->config_get(applet->helper->priv,
|
if((clock->format = applet->helper->config_get(applet->helper->panel,
|
||||||
"clock", "format")) == NULL)
|
"clock", "format")) == NULL)
|
||||||
#ifdef EMBEDDED
|
#ifdef EMBEDDED
|
||||||
clock->format = _("%H:%M");
|
clock->format = _("%H:%M");
|
||||||
|
@ -126,8 +126,8 @@ static gboolean _on_timeout(gpointer data)
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
if(gettimeofday(&tv, NULL) != 0)
|
if(gettimeofday(&tv, NULL) != 0)
|
||||||
return clock->helper->error(clock->helper->priv, "gettimeofday",
|
return clock->helper->error(clock->helper->panel,
|
||||||
TRUE);
|
"gettimeofday", TRUE);
|
||||||
t = tv.tv_sec;
|
t = tv.tv_sec;
|
||||||
localtime_r(&t, &tm);
|
localtime_r(&t, &tm);
|
||||||
strftime(buf, sizeof(buf), clock->format, &tm);
|
strftime(buf, sizeof(buf), clock->format, &tm);
|
||||||
|
|
|
@ -81,7 +81,7 @@ static GtkWidget * _cpu_init(PanelApplet * applet)
|
||||||
|
|
||||||
if((cpu = malloc(sizeof(*cpu))) == NULL)
|
if((cpu = malloc(sizeof(*cpu))) == NULL)
|
||||||
{
|
{
|
||||||
applet->helper->error(applet->helper->priv, "malloc", 0);
|
applet->helper->error(applet->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
applet->priv = cpu;
|
applet->priv = cpu;
|
||||||
|
@ -135,7 +135,7 @@ static gboolean _on_timeout(gpointer data)
|
||||||
gdouble value;
|
gdouble value;
|
||||||
|
|
||||||
if(sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
|
if(sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
|
||||||
return cpu->helper->error(cpu->helper->priv, "sysctl", TRUE);
|
return cpu->helper->error(cpu->helper->panel, "sysctl", TRUE);
|
||||||
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE]
|
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE]
|
||||||
+ cpu_time[CP_INTR];
|
+ cpu_time[CP_INTR];
|
||||||
total = used + cpu_time[CP_IDLE];
|
total = used + cpu_time[CP_IDLE];
|
||||||
|
|
|
@ -93,7 +93,7 @@ static GtkWidget * _cpufreq_init(PanelApplet * applet)
|
||||||
}
|
}
|
||||||
if((cpufreq = malloc(sizeof(*cpufreq))) == NULL)
|
if((cpufreq = malloc(sizeof(*cpufreq))) == NULL)
|
||||||
{
|
{
|
||||||
applet->helper->error(applet->helper->priv, "malloc", 0);
|
applet->helper->error(applet->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
applet->priv = cpufreq;
|
applet->priv = cpufreq;
|
||||||
|
@ -116,7 +116,7 @@ static GtkWidget * _cpufreq_init(PanelApplet * applet)
|
||||||
gtk_range_set_inverted(GTK_RANGE(cpufreq->scale), TRUE);
|
gtk_range_set_inverted(GTK_RANGE(cpufreq->scale), TRUE);
|
||||||
gtk_scale_set_value_pos(GTK_SCALE(cpufreq->scale), GTK_POS_RIGHT);
|
gtk_scale_set_value_pos(GTK_SCALE(cpufreq->scale), GTK_POS_RIGHT);
|
||||||
gtk_box_pack_start(GTK_BOX(ret), cpufreq->scale, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(ret), cpufreq->scale, FALSE, FALSE, 0);
|
||||||
cpufreq->timeout = g_timeout_add(500, _on_timeout, cpufreq);
|
cpufreq->timeout = g_timeout_add(1000, _on_timeout, cpufreq);
|
||||||
_on_timeout(cpufreq);
|
_on_timeout(cpufreq);
|
||||||
pango_font_description_free(desc);
|
pango_font_description_free(desc);
|
||||||
gtk_widget_show_all(ret);
|
gtk_widget_show_all(ret);
|
||||||
|
|
|
@ -104,16 +104,16 @@ static gboolean _init_idle(gpointer data)
|
||||||
|
|
||||||
if(keyboard->window != NULL)
|
if(keyboard->window != NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if((p = keyboard->helper->config_get(keyboard->helper->priv, "keyboard",
|
if((p = keyboard->helper->config_get(keyboard->helper->panel,
|
||||||
"command")) != NULL)
|
"keyboard", "command")) != NULL)
|
||||||
argv[2] = p;
|
argv[2] = p;
|
||||||
if(g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
|
if(g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
|
||||||
NULL, &keyboard->pid, NULL, &out, NULL, &error)
|
NULL, &keyboard->pid, NULL, &out, NULL, &error)
|
||||||
!= TRUE)
|
!= TRUE)
|
||||||
return keyboard->helper->error(keyboard->helper->priv,
|
return keyboard->helper->error(keyboard->helper->panel,
|
||||||
argv[0], FALSE);
|
argv[0], FALSE);
|
||||||
if((size = read(out, buf, sizeof(buf) - 1)) <= 0) /* XXX may block */
|
if((size = read(out, buf, sizeof(buf) - 1)) <= 0) /* XXX may block */
|
||||||
return keyboard->helper->error(keyboard->helper->priv,
|
return keyboard->helper->error(keyboard->helper->panel,
|
||||||
"read", FALSE); /* XXX not very explicit... */
|
"read", FALSE); /* XXX not very explicit... */
|
||||||
buf[size] = '\0';
|
buf[size] = '\0';
|
||||||
if(sscanf(buf, "%lu", &xid) != 1)
|
if(sscanf(buf, "%lu", &xid) != 1)
|
||||||
|
@ -153,7 +153,7 @@ static void _on_keyboard_toggled(GtkWidget * widget, gpointer data)
|
||||||
if(keyboard->window == NULL)
|
if(keyboard->window == NULL)
|
||||||
return;
|
return;
|
||||||
keyboard->helper->position_menu((GtkMenu*)keyboard->window, &x, &y,
|
keyboard->helper->position_menu((GtkMenu*)keyboard->window, &x, &y,
|
||||||
&push_in, keyboard->helper->priv);
|
&push_in, keyboard->helper->panel);
|
||||||
gtk_window_move(GTK_WINDOW(keyboard->window), x, y);
|
gtk_window_move(GTK_WINDOW(keyboard->window), x, y);
|
||||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
|
||||||
gtk_widget_show(keyboard->window);
|
gtk_widget_show(keyboard->window);
|
||||||
|
|
|
@ -75,7 +75,7 @@ static void _on_clicked(gpointer data)
|
||||||
char const * p;
|
char const * p;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
|
||||||
if((p = helper->config_get(helper->priv, "lock", "command")) != NULL)
|
if((p = helper->config_get(helper->panel, "lock", "command")) != NULL)
|
||||||
command = p;
|
command = p;
|
||||||
if(g_spawn_command_line_async(command, &error) != TRUE)
|
if(g_spawn_command_line_async(command, &error) != TRUE)
|
||||||
helper->error(NULL, error->message, 0);
|
helper->error(NULL, error->message, 0);
|
||||||
|
|
|
@ -315,7 +315,7 @@ static void _on_clicked(gpointer data)
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
gtk_widget_show_all(menu);
|
gtk_widget_show_all(menu);
|
||||||
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, main->helper->position_menu,
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, main->helper->position_menu,
|
||||||
main->helper->priv, 0, gtk_get_current_event_time());
|
main->helper->panel, 0, gtk_get_current_event_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ static void _on_lock(gpointer data)
|
||||||
char const * p;
|
char const * p;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
|
||||||
if((p = helper->config_get(helper->priv, "lock", "command")) != NULL)
|
if((p = helper->config_get(helper->panel, "lock", "command")) != NULL)
|
||||||
command = p;
|
command = p;
|
||||||
if(g_spawn_command_line_async(command, &error) != TRUE)
|
if(g_spawn_command_line_async(command, &error) != TRUE)
|
||||||
helper->error(NULL, error->message, 0);
|
helper->error(NULL, error->message, 0);
|
||||||
|
|
|
@ -77,7 +77,7 @@ static GtkWidget * _memory_init(PanelApplet * applet)
|
||||||
|
|
||||||
if((memory = malloc(sizeof(*memory))) == NULL)
|
if((memory = malloc(sizeof(*memory))) == NULL)
|
||||||
{
|
{
|
||||||
applet->helper->error(applet->helper->priv, "malloc", 0);
|
applet->helper->error(applet->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
applet->priv = memory;
|
applet->priv = memory;
|
||||||
|
@ -125,7 +125,8 @@ static gboolean _on_timeout(gpointer data)
|
||||||
gdouble value;
|
gdouble value;
|
||||||
|
|
||||||
if(sysinfo(&sy) != 0)
|
if(sysinfo(&sy) != 0)
|
||||||
return memory->helper->error(memory->helper->priv, "sysinfo", TRUE);
|
return memory->helper->error(memory->helper->panel, "sysinfo",
|
||||||
|
TRUE);
|
||||||
value = sy.sharedram;
|
value = sy.sharedram;
|
||||||
value /= sy.totalram;
|
value /= sy.totalram;
|
||||||
gtk_range_set_value(GTK_RANGE(memory->scale), value);
|
gtk_range_set_value(GTK_RANGE(memory->scale), value);
|
||||||
|
|
|
@ -104,7 +104,7 @@ static GtkWidget * _pager_init(PanelApplet * applet)
|
||||||
|
|
||||||
if((pager = malloc(sizeof(*pager))) == NULL)
|
if((pager = malloc(sizeof(*pager))) == NULL)
|
||||||
{
|
{
|
||||||
applet->helper->error(applet->helper->priv, "malloc", 0);
|
applet->helper->error(applet->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
applet->priv = pager;
|
applet->priv = pager;
|
||||||
|
@ -258,7 +258,7 @@ static void _pager_do(Pager * pager)
|
||||||
g_free(names[i]);
|
g_free(names[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), "Desk %ld\n", i + 1);
|
snprintf(buf, sizeof(buf), "Desk %lu\n", i + 1);
|
||||||
pager->widgets[i] = gtk_button_new_with_label(buf);
|
pager->widgets[i] = gtk_button_new_with_label(buf);
|
||||||
if(i == cur)
|
if(i == cur)
|
||||||
gtk_widget_set_sensitive(pager->widgets[i], FALSE);
|
gtk_widget_set_sensitive(pager->widgets[i], FALSE);
|
||||||
|
|
|
@ -77,7 +77,7 @@ static GtkWidget * _swap_init(PanelApplet * applet)
|
||||||
|
|
||||||
if((swap = malloc(sizeof(*swap))) == NULL)
|
if((swap = malloc(sizeof(*swap))) == NULL)
|
||||||
{
|
{
|
||||||
applet->helper->error(applet->helper->priv, "malloc", 0);
|
applet->helper->error(applet->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
applet->priv = swap;
|
applet->priv = swap;
|
||||||
|
@ -125,7 +125,8 @@ static gboolean _on_timeout(gpointer data)
|
||||||
gdouble value;
|
gdouble value;
|
||||||
|
|
||||||
if(sysinfo(&sy) != 0)
|
if(sysinfo(&sy) != 0)
|
||||||
return swap->helper->error(swap->helper->priv, "sysinfo", TRUE);
|
return swap->helper->error(swap->helper->panel, "sysinfo",
|
||||||
|
TRUE);
|
||||||
if((value = sy.totalswap - sy.freeswap) != 0.0 && sy.totalswap != 0)
|
if((value = sy.totalswap - sy.freeswap) != 0.0 && sy.totalswap != 0)
|
||||||
value /= sy.totalswap;
|
value /= sy.totalswap;
|
||||||
gtk_range_set_value(GTK_RANGE(swap->scale), value);
|
gtk_range_set_value(GTK_RANGE(swap->scale), value);
|
||||||
|
|
|
@ -79,7 +79,7 @@ static GtkWidget * _systray_init(PanelApplet * applet)
|
||||||
|
|
||||||
if((systray = malloc(sizeof(*systray))) == NULL)
|
if((systray = malloc(sizeof(*systray))) == NULL)
|
||||||
{
|
{
|
||||||
applet->helper->error(applet->helper->priv, "malloc", 0);
|
applet->helper->error(applet->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
applet->priv = systray;
|
applet->priv = systray;
|
||||||
|
|
|
@ -161,7 +161,7 @@ static Task * _task_new(Tasks * tasks, Window window, char const * name,
|
||||||
|
|
||||||
if((task = malloc(sizeof(*task))) == NULL)
|
if((task = malloc(sizeof(*task))) == NULL)
|
||||||
{
|
{
|
||||||
tasks->helper->error(tasks->helper->priv, "malloc", 0);
|
tasks->helper->error(tasks->helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
task->tasks = tasks;
|
task->tasks = tasks;
|
||||||
|
|
|
@ -129,11 +129,11 @@ static Volume * _volume_new(PanelAppletHelper * helper)
|
||||||
|
|
||||||
if((volume = malloc(sizeof(*volume))) == NULL)
|
if((volume = malloc(sizeof(*volume))) == NULL)
|
||||||
{
|
{
|
||||||
helper->error(helper->priv, "malloc", 0);
|
helper->error(helper->panel, "malloc", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
volume->helper = helper;
|
volume->helper = helper;
|
||||||
if((volume->device = helper->config_get(helper->priv, "volume",
|
if((volume->device = helper->config_get(helper->panel, "volume",
|
||||||
"device")) == NULL)
|
"device")) == NULL)
|
||||||
volume->device = "/dev/mixer";
|
volume->device = "/dev/mixer";
|
||||||
#ifdef AUDIO_MIXER_DEVINFO
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
|
@ -141,7 +141,7 @@ static Volume * _volume_new(PanelAppletHelper * helper)
|
||||||
volume->outputs = -1;
|
volume->outputs = -1;
|
||||||
if((volume->fd = open(volume->device, O_RDWR)) < 0)
|
if((volume->fd = open(volume->device, O_RDWR)) < 0)
|
||||||
{
|
{
|
||||||
helper->error(helper->priv, volume->device, 0);
|
helper->error(helper->panel, volume->device, 0);
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
for(i = 0; volume->outputs == -1 || volume->mix == -1; i++)
|
for(i = 0; volume->outputs == -1 || volume->mix == -1; i++)
|
||||||
|
@ -158,7 +158,7 @@ static Volume * _volume_new(PanelAppletHelper * helper)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if((volume->fd = open(volume->device, O_RDWR)) < 0)
|
if((volume->fd = open(volume->device, O_RDWR)) < 0)
|
||||||
helper->error(helper->priv, volume->device, 0);
|
helper->error(helper->panel, volume->device, 0);
|
||||||
#endif
|
#endif
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
@ -169,10 +169,10 @@ static void _volume_delete(Volume * volume)
|
||||||
{
|
{
|
||||||
#ifdef AUDIO_MIXER_DEVINFO
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
if(volume->fd >= 0 && close(volume->fd) != 0)
|
if(volume->fd >= 0 && close(volume->fd) != 0)
|
||||||
volume->helper->error(volume->helper->priv, volume->device, 0);
|
volume->helper->error(volume->helper->panel, volume->device, 0);
|
||||||
#else /* XXX equivalent for now */
|
#else /* XXX equivalent for now */
|
||||||
if(volume->fd >= 0 && close(volume->fd) != 0)
|
if(volume->fd >= 0 && close(volume->fd) != 0)
|
||||||
volume->helper->error(volume->helper->priv, volume->device, 0);
|
volume->helper->error(volume->helper->panel, volume->device, 0);
|
||||||
#endif
|
#endif
|
||||||
free(volume);
|
free(volume);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ static gdouble _volume_get(Volume * volume)
|
||||||
mc.type = AUDIO_MIXER_VALUE;
|
mc.type = AUDIO_MIXER_VALUE;
|
||||||
mc.un.value.num_channels = md.un.v.num_channels;
|
mc.un.value.num_channels = md.un.v.num_channels;
|
||||||
if(ioctl(volume->fd, AUDIO_MIXER_READ, &mc) < 0)
|
if(ioctl(volume->fd, AUDIO_MIXER_READ, &mc) < 0)
|
||||||
volume->helper->error(volume->helper->priv,
|
volume->helper->error(volume->helper->panel,
|
||||||
"AUDIO_MIXER_READ", 0);
|
"AUDIO_MIXER_READ", 0);
|
||||||
else
|
else
|
||||||
ret = mc.un.value.level[0] / 255.0;
|
ret = mc.un.value.level[0] / 255.0;
|
||||||
|
@ -218,7 +218,7 @@ static gdouble _volume_get(Volume * volume)
|
||||||
if(volume->fd < 0)
|
if(volume->fd < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if(ioctl(volume->fd, MIXER_READ(SOUND_MIXER_VOLUME), &value) < 0)
|
if(ioctl(volume->fd, MIXER_READ(SOUND_MIXER_VOLUME), &value) < 0)
|
||||||
volume->helper->error(volume->helper->priv, "MIXER_READ", 0);
|
volume->helper->error(volume->helper->panel, "MIXER_READ", 0);
|
||||||
else
|
else
|
||||||
ret = ((value & 0xff) + ((value & 0xff00) >> 8)) / 200.0;
|
ret = ((value & 0xff) + ((value & 0xff00) >> 8)) / 200.0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -260,7 +260,7 @@ int _volume_set(Volume * volume, gdouble value)
|
||||||
for(j = 1; j < mc.un.value.num_channels; j++) /* XXX overflow */
|
for(j = 1; j < mc.un.value.num_channels; j++) /* XXX overflow */
|
||||||
mc.un.value.level[j] = mc.un.value.level[0];
|
mc.un.value.level[j] = mc.un.value.level[0];
|
||||||
if(ioctl(volume->fd, AUDIO_MIXER_WRITE, &mc) < 0)
|
if(ioctl(volume->fd, AUDIO_MIXER_WRITE, &mc) < 0)
|
||||||
ret |= volume->helper->error(volume->helper->priv,
|
ret |= volume->helper->error(volume->helper->panel,
|
||||||
"AUDIO_MIXER_WRITE", 0);
|
"AUDIO_MIXER_WRITE", 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ int _volume_set(Volume * volume, gdouble value)
|
||||||
fprintf(stderr, "DEBUG: %s(%lf) 0x%04x\n", __func__, value, v);
|
fprintf(stderr, "DEBUG: %s(%lf) 0x%04x\n", __func__, value, v);
|
||||||
# endif
|
# endif
|
||||||
if(ioctl(volume->fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &v) < 0)
|
if(ioctl(volume->fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &v) < 0)
|
||||||
ret |= volume->helper->error(volume->helper->priv,
|
ret |= volume->helper->error(volume->helper->panel,
|
||||||
"MIXER_WRITE", 0);
|
"MIXER_WRITE", 0);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -19,12 +19,11 @@
|
||||||
# define PANEL_COMMON_H
|
# define PANEL_COMMON_H
|
||||||
|
|
||||||
# include <gtk/gtk.h>
|
# include <gtk/gtk.h>
|
||||||
|
# include "Panel.h"
|
||||||
|
|
||||||
|
|
||||||
/* Panel */
|
/* Panel */
|
||||||
/* types */
|
/* types */
|
||||||
typedef struct _Panel Panel;
|
|
||||||
|
|
||||||
typedef enum _PanelPosition
|
typedef enum _PanelPosition
|
||||||
{
|
{
|
||||||
PANEL_POSITION_BOTH,
|
PANEL_POSITION_BOTH,
|
||||||
|
|
23
src/panel.c
23
src/panel.c
|
@ -24,7 +24,6 @@
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include "Panel.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#define _(string) gettext(string)
|
#define _(string) gettext(string)
|
||||||
|
@ -65,9 +64,9 @@ struct _Panel
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
/* helpers */
|
/* helpers */
|
||||||
static char const * _panel_helper_config_get(void * priv, char const * section,
|
static char const * _panel_helper_config_get(Panel * panel,
|
||||||
char const * variable);
|
char const * section, char const * variable);
|
||||||
static int _panel_helper_error(void * priv, char const * message, int ret);
|
static int _panel_helper_error(Panel * panel, char const * message, int ret);
|
||||||
#ifndef EMBEDDED
|
#ifndef EMBEDDED
|
||||||
static int _panel_helper_logout_dialog(void);
|
static int _panel_helper_logout_dialog(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -110,7 +109,7 @@ Panel * panel_new(PanelPrefs * prefs)
|
||||||
if(gtk_icon_size_lookup(prefs->iconsize, &panel->icon_width,
|
if(gtk_icon_size_lookup(prefs->iconsize, &panel->icon_width,
|
||||||
&panel->icon_height) != TRUE)
|
&panel->icon_height) != TRUE)
|
||||||
error_set_print(PACKAGE, 0, "Invalid panel size");
|
error_set_print(PACKAGE, 0, "Invalid panel size");
|
||||||
panel->helper.priv = panel;
|
panel->helper.panel = panel;
|
||||||
panel->helper.config_get = _panel_helper_config_get;
|
panel->helper.config_get = _panel_helper_config_get;
|
||||||
panel->helper.error = _panel_helper_error;
|
panel->helper.error = _panel_helper_error;
|
||||||
panel->helper.icon_size = prefs->iconsize;
|
panel->helper.icon_size = prefs->iconsize;
|
||||||
|
@ -295,7 +294,7 @@ int panel_error(Panel * panel, char const * message, int ret)
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR,
|
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR,
|
||||||
GTK_BUTTONS_CLOSE, "%s: %s", message, strerror(errno));
|
GTK_BUTTONS_CLOSE, "%s: %s", message, strerror(errno));
|
||||||
gtk_window_set_title(GTK_WINDOW(dialog), "Error");
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
|
||||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -351,11 +350,9 @@ int panel_load(Panel * panel, char const * applet)
|
||||||
/* functions */
|
/* functions */
|
||||||
/* helpers */
|
/* helpers */
|
||||||
/* panel_helper_config_get */
|
/* panel_helper_config_get */
|
||||||
static char const * _panel_helper_config_get(void * priv, char const * section,
|
static char const * _panel_helper_config_get(Panel * panel,
|
||||||
char const * variable)
|
char const * section, char const * variable)
|
||||||
{
|
{
|
||||||
Panel * panel = priv;
|
|
||||||
|
|
||||||
return config_get(panel->config, section, variable);
|
return config_get(panel->config, section, variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,11 +360,9 @@ static char const * _panel_helper_config_get(void * priv, char const * section,
|
||||||
/* panel_helper_error */
|
/* panel_helper_error */
|
||||||
static int _error_text(char const * message, int ret);
|
static int _error_text(char const * message, int ret);
|
||||||
|
|
||||||
static int _panel_helper_error(void * priv, char const * message, int ret)
|
static int _panel_helper_error(Panel * panel, char const * message, int ret)
|
||||||
{
|
{
|
||||||
Panel * panel = priv;
|
if(panel == NULL)
|
||||||
|
|
||||||
if(priv == NULL)
|
|
||||||
return _error_text(message, ret);
|
return _error_text(message, ret);
|
||||||
return panel_error(panel, message, ret);
|
return panel_error(panel, message, ret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user