kopia lustrzana https://gitlab.com/sane-project/frontends
Start menu implementation
rodzic
535a989951
commit
27ca94e008
117
src/xcam.c
117
src/xcam.c
|
@ -164,6 +164,7 @@ static struct option long_options[] = {
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static GtkApplication *app;
|
||||
/* Test if this machine is little endian (from coolscan.c) */
|
||||
static gboolean
|
||||
calc_little_endian (void)
|
||||
|
@ -745,6 +746,40 @@ device_activate_callback (GtkWidget * widget, gpointer data)
|
|||
g_idle_add (delayed_switch, data);
|
||||
}
|
||||
|
||||
static void action (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
G_GNUC_UNUSED gpointer user_data )
|
||||
{
|
||||
int i;
|
||||
g_action_change_state ( G_ACTION ( action ), parameter );
|
||||
|
||||
const gchar *attribut;
|
||||
attribut = g_variant_get_string ( parameter, NULL );
|
||||
for (i = 0; device[i]; ++i) {
|
||||
if (strcmp(attribut, device[i]->name) == 0) {
|
||||
g_idle_add (delayed_switch, device[i]);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if ( g_strcmp0 ( attribut, "red" ) == 0 )
|
||||
{
|
||||
red_clbk ( action, parameter );
|
||||
}
|
||||
else if ( g_strcmp0 ( attribut, "green" ) == 0 )
|
||||
{
|
||||
green_clbk ( action, parameter );
|
||||
}
|
||||
else if ( g_strcmp0 ( attribut, "blue" ) == 0 )
|
||||
{
|
||||
blue_clbk ( action, parameter );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
build_device_menu (void)
|
||||
{
|
||||
|
@ -760,34 +795,50 @@ build_device_menu (void)
|
|||
fprintf (stderr, "%s: %s\n", prog_name, sane_strstatus (status));
|
||||
exit (1);
|
||||
}
|
||||
/*
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
GVariant *state_scanner;
|
||||
state_scanner = g_variant_new_string ( "none" );
|
||||
GSimpleAction *scanner_action = g_simple_action_new_stateful ( "scanner", G_VARIANT_TYPE_STRING, state_scanner );
|
||||
|
||||
g_signal_connect ( scanner_action, "activate", G_CALLBACK ( action ), scanner_action );
|
||||
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (scanner_action));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
for (i = 0; device[i]; ++i)
|
||||
{
|
||||
item = gtk_menu_item_new_with_label ((char *) device[i]->name);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
GSimpleAction *action = g_simple_action_new (device[i]->name, NULL );
|
||||
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (action));
|
||||
create_item (menu, device[i]->name, "app.scanner", "audio-input-microphone", device[i]->name, NULL);
|
||||
/*
|
||||
item = gtk_menu_item_new_with_label ((char *) device[i]->name);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (device_activate_callback),
|
||||
(gpointer) device[i]);
|
||||
gtk_widget_show (item);
|
||||
gtk_widget_show (item);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
item = gtk_menu_item_new ();
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
*/
|
||||
create_item (menu, "Refresh device list...", "app.refresh", "audio-input-microphone", "Refresh device list...", NULL);
|
||||
/*
|
||||
item = gtk_menu_item_new_with_label ("Refresh device list...");
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (rescan_devices), 0);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
*/
|
||||
create_item (menu, "Specify device name...", "app.specify", "audio-input-microphone", "Specify device name...", NULL);
|
||||
/*
|
||||
item = gtk_menu_item_new_with_label ("Specify device name...");
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (prompt_for_device_name), 0);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
return menu;
|
||||
*/
|
||||
return menu;
|
||||
}
|
||||
|
@ -1600,46 +1651,6 @@ filename_changed_callback (GtkWidget * widget, gpointer data)
|
|||
DBG (DBG_debug, "xcam: filename_changed_callbackcallback: exit\n");
|
||||
}
|
||||
|
||||
static void create_item ( GMenu *menu,
|
||||
const gchar *const label,
|
||||
const gchar *const action,
|
||||
const gchar *const icon,
|
||||
const gchar *const target,
|
||||
const gchar *const accel )
|
||||
{
|
||||
g_return_if_fail ( G_IS_MENU ( menu ) );
|
||||
|
||||
GMenuItem *item = g_menu_item_new ( NULL, NULL );
|
||||
g_menu_item_set_attribute ( item, G_MENU_ATTRIBUTE_LABEL, "s", label, NULL );
|
||||
g_menu_item_set_attribute ( item, G_MENU_ATTRIBUTE_ACTION, "s", action, NULL );
|
||||
g_menu_item_set_attribute ( item, G_MENU_ATTRIBUTE_ICON, "s", icon, NULL );
|
||||
|
||||
if ( target )
|
||||
{
|
||||
g_menu_item_set_attribute ( item, "target", "s", target, NULL );
|
||||
}
|
||||
|
||||
g_menu_item_set_attribute ( item, "accel", "s", accel, NULL );
|
||||
g_menu_append_item ( menu, item );
|
||||
|
||||
g_object_unref ( item );
|
||||
}
|
||||
|
||||
static void create_submenu_item ( GMenu *menu,
|
||||
GMenu *submenu,
|
||||
const gchar *const label )
|
||||
{
|
||||
g_return_if_fail ( G_IS_MENU ( menu ) );
|
||||
|
||||
GMenuItem *item = g_menu_item_new ( NULL, NULL );
|
||||
|
||||
g_menu_item_set_attribute ( item, G_MENU_ATTRIBUTE_LABEL, "s", label, NULL );
|
||||
g_menu_item_set_submenu ( item, G_MENU_MODEL ( submenu ) );
|
||||
g_menu_append_item ( menu, item );
|
||||
|
||||
g_object_unref ( item );
|
||||
}
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
|
@ -1704,11 +1715,12 @@ activate(GApplication *app, gpointer *data) {
|
|||
|
||||
menu_bar = g_menu_new ();
|
||||
|
||||
win.devices.menu = build_device_menu ();
|
||||
|
||||
/* "Files" entry: */
|
||||
menu_files = build_files_menu ();
|
||||
g_menu_append_submenu (menu_bar, "File", G_MENU_MODEL (menu_files));
|
||||
|
||||
win.devices.menu = build_device_menu ();
|
||||
g_menu_append_submenu (menu_bar, "Device", G_MENU_MODEL (win.devices.menu));
|
||||
/*
|
||||
// "Devices" entry:
|
||||
win.devices.item = gtk_menu_item_new_with_label ("Devices");
|
||||
|
@ -1948,7 +1960,6 @@ activate(GApplication *app, gpointer *data) {
|
|||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
GtkApplication *app;
|
||||
int stat = 0;
|
||||
int ch;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue