Example #1
0
static GtkWidget *
create_add_emblems_dialog (CajaEmblemSidebar *emblem_sidebar,
                           GSList *emblems)
{
    GtkWidget *dialog, *label, *table, *image;
    GtkWidget *first_entry, *entry, *scroller, *hbox;
    Emblem *emblem;
    GSList *list;
    int num_emblems;

    first_entry = NULL;

    dialog = gtk_dialog_new_with_buttons (_("Add Emblems..."),
                                          NULL,
                                          0,
                                          GTK_STOCK_CANCEL,
                                          GTK_RESPONSE_CANCEL,
                                          GTK_STOCK_OK,
                                          GTK_RESPONSE_OK,
                                          GTK_STOCK_HELP,
                                          GTK_RESPONSE_HELP,
                                          NULL);

    gtk_dialog_set_default_response (GTK_DIALOG (dialog),
                                     GTK_RESPONSE_OK);

    /* FIXME:  make a better message */
    if (g_slist_length (emblems) > 1)
    {
        label = gtk_label_new (_("Enter a descriptive name next to each emblem.  This name will be used in other places to identify the emblem."));
    }
    else
    {
        label = gtk_label_new (_("Enter a descriptive name next to the emblem.  This name will be used in other places to identify the emblem."));
    }

    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                        label, FALSE, FALSE, 8);
    gtk_widget_show (label);

    scroller = eel_scrolled_wrap_table_new (TRUE, GTK_SHADOW_NONE, &table);
    eel_wrap_table_set_x_spacing (EEL_WRAP_TABLE (table), 8);
    eel_wrap_table_set_y_spacing (EEL_WRAP_TABLE (table), 8);

    num_emblems=0;
    list = emblems;
    while (list != NULL)
    {
        /* walk through the list of emblems, and create an image
         * and entry for each one
         */

        emblem = (Emblem *)list->data;
        list = list->next;

        image = gtk_image_new_from_pixbuf (emblem->pixbuf);

        hbox = gtk_hbox_new (TRUE, 0);
        gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);

        entry = gtk_entry_new ();
        gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
        g_signal_connect (entry, "changed",
                          G_CALLBACK (emblem_name_entry_changed_cb),
                          emblem);

        gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
        gtk_container_add (GTK_CONTAINER (table), hbox);

        if (num_emblems == 0)
        {
            first_entry = entry;
        }

        num_emblems++;
    }

    gtk_container_set_border_width (GTK_CONTAINER (dialog), 8);
    gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                        scroller, TRUE, TRUE, 8);
    gtk_widget_show_all (scroller);

    gtk_widget_grab_focus (first_entry);

    /* we expand the window to hold up to about 4 emblems, but after that
     * let the scroller do its thing.  Is there a better way to do this?
     */
    gtk_window_set_default_size (GTK_WINDOW (dialog), 400,
                                 MIN (120+(60*num_emblems), 350));

    g_object_set_data_full (G_OBJECT (dialog), "emblems-to-add",
                            emblems, (GDestroyNotify)destroy_emblem_list);

    return dialog;
}
Example #2
0
GtkWidget*
create_convpreset_editor (void)
{
  GtkWidget *convpreset_editor;
  GtkWidget *dialog_vbox7;
  GtkWidget *vbox27;
  GtkWidget *hbox70;
  GtkWidget *label105;
  GtkWidget *title;
  GtkWidget *hbox96;
  GtkWidget *label120;
  GtkWidget *ext;
  GtkWidget *hbox72;
  GtkWidget *label106;
  GtkWidget *hbox93;
  GtkWidget *encoder;
  GtkWidget *custom4;
  GtkWidget *label124;
  GtkWidget *hbox73;
  GtkWidget *label107;
  GtkWidget *method;
  GtkWidget *frame9;
  GtkWidget *alignment21;
  GtkWidget *table2;
  GtkWidget *apev2;
  GtkWidget *id3v1;
  GtkWidget *oggvorbis;
  GtkWidget *flac;
  GtkWidget *hbox104;
  GtkWidget *id3v2;
  GtkWidget *id3v2_version;
  GtkWidget *mp4;
  GtkWidget *label125;
  GtkWidget *dialog_action_area6;
  GtkWidget *convpreset_cancel;
  GtkWidget *convpreset_ok;

  convpreset_editor = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (convpreset_editor), _("Edit Encoder Preset"));
  gtk_window_set_modal (GTK_WINDOW (convpreset_editor), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (convpreset_editor), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox7 = gtk_dialog_get_content_area (GTK_DIALOG (convpreset_editor));
  gtk_widget_show (dialog_vbox7);

  vbox27 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox27);
  gtk_box_pack_start (GTK_BOX (dialog_vbox7), vbox27, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox27), 12);

  hbox70 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox70);
  gtk_box_pack_start (GTK_BOX (vbox27), hbox70, FALSE, TRUE, 0);

  label105 = gtk_label_new (_("Title:"));
  gtk_widget_show (label105);
  gtk_box_pack_start (GTK_BOX (hbox70), label105, FALSE, FALSE, 0);

  title = gtk_entry_new ();
  gtk_widget_show (title);
  gtk_box_pack_start (GTK_BOX (hbox70), title, TRUE, TRUE, 0);
  gtk_entry_set_text (GTK_ENTRY (title), _("Untitled Encoder"));
  gtk_entry_set_invisible_char (GTK_ENTRY (title), 9679);
  gtk_entry_set_activates_default (GTK_ENTRY (title), TRUE);

  hbox96 = gtk_hbox_new (FALSE, 9);
  gtk_widget_show (hbox96);
  gtk_box_pack_start (GTK_BOX (vbox27), hbox96, FALSE, TRUE, 0);

  label120 = gtk_label_new (_("Output file extension:"));
  gtk_widget_show (label120);
  gtk_box_pack_start (GTK_BOX (hbox96), label120, FALSE, FALSE, 0);

  ext = gtk_entry_new ();
  gtk_widget_show (ext);
  gtk_box_pack_start (GTK_BOX (hbox96), ext, TRUE, TRUE, 0);
  gtk_widget_set_tooltip_text (ext, _("E.g. mp3"));
  gtk_entry_set_invisible_char (GTK_ENTRY (ext), 9679);
  gtk_entry_set_activates_default (GTK_ENTRY (ext), TRUE);

  hbox72 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox72);
  gtk_box_pack_start (GTK_BOX (vbox27), hbox72, FALSE, TRUE, 0);

  label106 = gtk_label_new (_("Command line:"));
  gtk_widget_show (label106);
  gtk_box_pack_start (GTK_BOX (hbox72), label106, FALSE, FALSE, 0);

  hbox93 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox93);
  gtk_box_pack_start (GTK_BOX (hbox72), hbox93, TRUE, TRUE, 0);

  encoder = gtk_entry_new ();
  gtk_widget_show (encoder);
  gtk_box_pack_start (GTK_BOX (hbox93), encoder, TRUE, TRUE, 0);
  gtk_widget_set_tooltip_text (encoder, _("Example: lame - %o\n%i for input file, %o for output file, - for stdin"));
  gtk_entry_set_invisible_char (GTK_ENTRY (encoder), 9679);
  gtk_entry_set_activates_default (GTK_ENTRY (encoder), TRUE);

  custom4 = encoder_cmdline_help_link_create ("custom4", "", "", 0, 0);
  gtk_widget_show (custom4);
  gtk_box_pack_start (GTK_BOX (hbox93), custom4, TRUE, TRUE, 0);
  gtk_widget_set_can_focus(custom4, FALSE);
  gtk_widget_set_can_default(custom4, FALSE);

  label124 = gtk_label_new (_("<small>%o - output file name\n%i - temporary input file name</small>"));
  gtk_widget_show (label124);
  gtk_box_pack_start (GTK_BOX (vbox27), label124, FALSE, FALSE, 0);
  gtk_label_set_use_markup (GTK_LABEL (label124), TRUE);

  hbox73 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox73);
  gtk_box_pack_start (GTK_BOX (vbox27), hbox73, FALSE, TRUE, 0);

  label107 = gtk_label_new (_("Method:"));
  gtk_widget_show (label107);
  gtk_box_pack_start (GTK_BOX (hbox73), label107, FALSE, FALSE, 0);

  method = gtk_combo_box_text_new ();
  gtk_widget_show (method);
  gtk_box_pack_start (GTK_BOX (hbox73), method, TRUE, TRUE, 0);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (method), _("Pipe"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (method), _("Temp File"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (method), _("Source File"));

  frame9 = gtk_frame_new (NULL);
  gtk_widget_show (frame9);
  gtk_box_pack_start (GTK_BOX (vbox27), frame9, FALSE, FALSE, 0);

  alignment21 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_show (alignment21);
  gtk_container_add (GTK_CONTAINER (frame9), alignment21);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment21), 0, 0, 12, 0);

  table2 = gtk_table_new (2, 3, FALSE);
  gtk_widget_show (table2);
  gtk_container_add (GTK_CONTAINER (alignment21), table2);
  gtk_container_set_border_width (GTK_CONTAINER (table2), 8);
  gtk_table_set_col_spacings (GTK_TABLE (table2), 8);

  apev2 = gtk_check_button_new_with_mnemonic (_("APEv2"));
  gtk_widget_show (apev2);
  gtk_table_attach (GTK_TABLE (table2), apev2, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  id3v1 = gtk_check_button_new_with_mnemonic (_("ID3v1"));
  gtk_widget_show (id3v1);
  gtk_table_attach (GTK_TABLE (table2), id3v1, 2, 3, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  oggvorbis = gtk_check_button_new_with_mnemonic (_("OggVorbis"));
  gtk_widget_show (oggvorbis);
  gtk_table_attach (GTK_TABLE (table2), oggvorbis, 2, 3, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  flac = gtk_check_button_new_with_mnemonic (_("FLAC"));
  gtk_widget_show (flac);
  gtk_table_attach (GTK_TABLE (table2), flac, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  hbox104 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox104);
  gtk_table_attach (GTK_TABLE (table2), hbox104, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);

  id3v2 = gtk_check_button_new_with_mnemonic (_("ID3v2"));
  gtk_widget_show (id3v2);
  gtk_box_pack_start (GTK_BOX (hbox104), id3v2, FALSE, FALSE, 0);

  id3v2_version = gtk_combo_box_text_new ();
  gtk_widget_show (id3v2_version);
  gtk_box_pack_start (GTK_BOX (hbox104), id3v2_version, TRUE, TRUE, 0);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id3v2_version), "2.3");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (id3v2_version), "2.4");

  mp4 = gtk_check_button_new_with_mnemonic (_("MP4"));
  gtk_widget_show (mp4);
  gtk_table_attach (GTK_TABLE (table2), mp4, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label125 = gtk_label_new (_("<b>Tag writer</b>"));
  gtk_widget_show (label125);
  gtk_frame_set_label_widget (GTK_FRAME (frame9), label125);
  gtk_label_set_use_markup (GTK_LABEL (label125), TRUE);

  dialog_action_area6 = gtk_dialog_get_action_area (GTK_DIALOG (convpreset_editor));
  gtk_widget_show (dialog_action_area6);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area6), GTK_BUTTONBOX_END);

  convpreset_cancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (convpreset_cancel);
  gtk_dialog_add_action_widget (GTK_DIALOG (convpreset_editor), convpreset_cancel, GTK_RESPONSE_CANCEL);
  gtk_widget_set_can_default(convpreset_cancel, TRUE);

  convpreset_ok = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (convpreset_ok);
  gtk_dialog_add_action_widget (GTK_DIALOG (convpreset_editor), convpreset_ok, GTK_RESPONSE_OK);
  gtk_widget_set_can_default(convpreset_ok, TRUE);

  g_signal_connect ((gpointer) encoder, "changed",
                    G_CALLBACK (on_encoder_changed),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (convpreset_editor, convpreset_editor, "convpreset_editor");
  GLADE_HOOKUP_OBJECT_NO_REF (convpreset_editor, dialog_vbox7, "dialog_vbox7");
  GLADE_HOOKUP_OBJECT (convpreset_editor, vbox27, "vbox27");
  GLADE_HOOKUP_OBJECT (convpreset_editor, hbox70, "hbox70");
  GLADE_HOOKUP_OBJECT (convpreset_editor, label105, "label105");
  GLADE_HOOKUP_OBJECT (convpreset_editor, title, "title");
  GLADE_HOOKUP_OBJECT (convpreset_editor, hbox96, "hbox96");
  GLADE_HOOKUP_OBJECT (convpreset_editor, label120, "label120");
  GLADE_HOOKUP_OBJECT (convpreset_editor, ext, "ext");
  GLADE_HOOKUP_OBJECT (convpreset_editor, hbox72, "hbox72");
  GLADE_HOOKUP_OBJECT (convpreset_editor, label106, "label106");
  GLADE_HOOKUP_OBJECT (convpreset_editor, hbox93, "hbox93");
  GLADE_HOOKUP_OBJECT (convpreset_editor, encoder, "encoder");
  GLADE_HOOKUP_OBJECT (convpreset_editor, custom4, "custom4");
  GLADE_HOOKUP_OBJECT (convpreset_editor, label124, "label124");
  GLADE_HOOKUP_OBJECT (convpreset_editor, hbox73, "hbox73");
  GLADE_HOOKUP_OBJECT (convpreset_editor, label107, "label107");
  GLADE_HOOKUP_OBJECT (convpreset_editor, method, "method");
  GLADE_HOOKUP_OBJECT (convpreset_editor, frame9, "frame9");
  GLADE_HOOKUP_OBJECT (convpreset_editor, alignment21, "alignment21");
  GLADE_HOOKUP_OBJECT (convpreset_editor, table2, "table2");
  GLADE_HOOKUP_OBJECT (convpreset_editor, apev2, "apev2");
  GLADE_HOOKUP_OBJECT (convpreset_editor, id3v1, "id3v1");
  GLADE_HOOKUP_OBJECT (convpreset_editor, oggvorbis, "oggvorbis");
  GLADE_HOOKUP_OBJECT (convpreset_editor, flac, "flac");
  GLADE_HOOKUP_OBJECT (convpreset_editor, hbox104, "hbox104");
  GLADE_HOOKUP_OBJECT (convpreset_editor, id3v2, "id3v2");
  GLADE_HOOKUP_OBJECT (convpreset_editor, id3v2_version, "id3v2_version");
  GLADE_HOOKUP_OBJECT (convpreset_editor, mp4, "mp4");
  GLADE_HOOKUP_OBJECT (convpreset_editor, label125, "label125");
  GLADE_HOOKUP_OBJECT_NO_REF (convpreset_editor, dialog_action_area6, "dialog_action_area6");
  GLADE_HOOKUP_OBJECT (convpreset_editor, convpreset_cancel, "convpreset_cancel");
  GLADE_HOOKUP_OBJECT (convpreset_editor, convpreset_ok, "convpreset_ok");

  return convpreset_editor;
}
Example #3
0
GtkWidget*
create_select_dsp_plugin (void)
{
  GtkWidget *select_dsp_plugin;
  GtkWidget *dialog_vbox10;
  GtkWidget *vbox31;
  GtkWidget *hbox85;
  GtkWidget *label113;
  GtkWidget *plugin;
  GtkWidget *dialog_action_area9;
  GtkWidget *cancelbutton7;
  GtkWidget *okbutton7;

  select_dsp_plugin = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (select_dsp_plugin), _("Select DSP Plugin"));
  gtk_window_set_modal (GTK_WINDOW (select_dsp_plugin), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (select_dsp_plugin), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox10 = gtk_dialog_get_content_area (GTK_DIALOG (select_dsp_plugin));
  gtk_widget_show (dialog_vbox10);

  vbox31 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox31);
  gtk_box_pack_start (GTK_BOX (dialog_vbox10), vbox31, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox31), 12);

  hbox85 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox85);
  gtk_box_pack_start (GTK_BOX (vbox31), hbox85, FALSE, FALSE, 0);

  label113 = gtk_label_new (_("Plugin"));
  gtk_widget_show (label113);
  gtk_box_pack_start (GTK_BOX (hbox85), label113, FALSE, FALSE, 0);

  plugin = gtk_combo_box_text_new ();
  gtk_widget_show (plugin);
  gtk_box_pack_start (GTK_BOX (hbox85), plugin, TRUE, TRUE, 0);
  gtk_widget_set_size_request (plugin, 232, -1);

  dialog_action_area9 = gtk_dialog_get_action_area (GTK_DIALOG (select_dsp_plugin));
  gtk_widget_show (dialog_action_area9);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area9), GTK_BUTTONBOX_END);

  cancelbutton7 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (cancelbutton7);
  gtk_dialog_add_action_widget (GTK_DIALOG (select_dsp_plugin), cancelbutton7, GTK_RESPONSE_CANCEL);
  gtk_widget_set_can_default(cancelbutton7, TRUE);

  okbutton7 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton7);
  gtk_dialog_add_action_widget (GTK_DIALOG (select_dsp_plugin), okbutton7, GTK_RESPONSE_OK);
  gtk_widget_set_can_default(okbutton7, TRUE);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (select_dsp_plugin, select_dsp_plugin, "select_dsp_plugin");
  GLADE_HOOKUP_OBJECT_NO_REF (select_dsp_plugin, dialog_vbox10, "dialog_vbox10");
  GLADE_HOOKUP_OBJECT (select_dsp_plugin, vbox31, "vbox31");
  GLADE_HOOKUP_OBJECT (select_dsp_plugin, hbox85, "hbox85");
  GLADE_HOOKUP_OBJECT (select_dsp_plugin, label113, "label113");
  GLADE_HOOKUP_OBJECT (select_dsp_plugin, plugin, "plugin");
  GLADE_HOOKUP_OBJECT_NO_REF (select_dsp_plugin, dialog_action_area9, "dialog_action_area9");
  GLADE_HOOKUP_OBJECT (select_dsp_plugin, cancelbutton7, "cancelbutton7");
  GLADE_HOOKUP_OBJECT (select_dsp_plugin, okbutton7, "okbutton7");

  return select_dsp_plugin;
}
Example #4
0
int 
main (int    argc,
      char **argv)
{
  GtkWidget *window;
  GError    *error = NULL;

  /* Setup translation domain */
  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");

  /* Initialize the threading system */
  if (G_LIKELY (!g_thread_supported ()))
    g_thread_init (NULL);

  /* Set debug level */
#ifdef G_ENABLE_DEBUG
  g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
#endif

  /* Set application name */
  g_set_application_name (_("Mixer"));

  /* Initialize GTK+ */
  gtk_init (&argc, &argv);

  /* Initialize Xfconf */
  if (G_UNLIKELY (!xfconf_init (&error)))
    {
      if (G_LIKELY (error != NULL))
        {
          g_print (_("Failed to initialize xfconf: %s"), error->message);
          g_error_free (error);
        }

      return EXIT_FAILURE;
    }

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Initialize the mixer library */
  xfce_mixer_init ();

  /* Use volume control icon for all mixer windows */
  gtk_window_set_default_icon_name ("multimedia-volume-control");

  /* Warn users if there were no sound cards detected by GStreamer */
  if (G_UNLIKELY (g_list_length (xfce_mixer_get_cards ()) <= 0))
  {
      GtkWidget *dlg = gtk_dialog_new_with_buttons (_("No ALSA Devices Found"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, 0, NULL);
      GtkWidget *label = gtk_label_new (_("No ALSA audio devices were detected. Enable the internal audio device, or connect a USB or HAT audio device."));
      gtk_container_set_border_width (GTK_CONTAINER (dlg), 10);
      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
      gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
      gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), label, TRUE, TRUE, 0);
      gtk_widget_show_all (dlg);
      gtk_dialog_run (GTK_DIALOG (dlg));
      return EXIT_FAILURE;
  }

  /* Create the mixer window */
  window = xfce_mixer_window_new ();

  /* Display the mixer window */
  gtk_widget_show (window);

  g_bus_watch_name (G_BUS_TYPE_SESSION, "org.lxde.volumealsa", 0, volumealsa_device_changed, NULL, window, NULL);

  /* Enter the GTK+ main loop */
  gtk_main ();

  /* Destroy the window */
  gtk_widget_destroy (window);

  /* Shutdown the mixer library */
  xfce_mixer_shutdown ();

  /* Shutdown Xfconf */
  xfconf_shutdown ();

  return EXIT_SUCCESS;
}
Example #5
0
static void gtk_assert_dialog_init(GtkAssertDialog* dlg)
{
    GtkWidget *continuebtn;

    {
        GtkWidget *vbox, *hbox, *image;

        /* start the main vbox */
        gtk_widget_push_composite_child ();
        vbox = gtk_vbox_new (FALSE, 8);
        gtk_container_set_border_width (GTK_CONTAINER(vbox), 8);
        gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), vbox, true, true, 5);


        /* add the icon+message hbox */
        hbox = gtk_hbox_new (FALSE, 0);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

        /* icon */
        image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
        gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 12);

        {
            GtkWidget *vbox2, *info;

            /* message */
            vbox2 = gtk_vbox_new (FALSE, 0);
            gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
            info = gtk_label_new ("An assertion failed!");
            gtk_box_pack_start (GTK_BOX(vbox2), info, TRUE, TRUE, 8);

            /* assert message */
            dlg->message = gtk_label_new (NULL);
            gtk_label_set_selectable (GTK_LABEL (dlg->message), TRUE);
            gtk_label_set_line_wrap (GTK_LABEL (dlg->message), TRUE);
            gtk_label_set_justify (GTK_LABEL (dlg->message), GTK_JUSTIFY_LEFT);
            gtk_widget_set_size_request (GTK_WIDGET(dlg->message), 450, -1);

            gtk_box_pack_end (GTK_BOX(vbox2), GTK_WIDGET(dlg->message), TRUE, TRUE, 8);
        }

        /* add the expander */
        dlg->expander = gtk_expander_new_with_mnemonic ("Back_trace:");
        gtk_box_pack_start (GTK_BOX(vbox), dlg->expander, TRUE, TRUE, 0);
        g_signal_connect (GTK_EXPANDER(dlg->expander), "activate",
                            G_CALLBACK(gtk_assert_dialog_expander_callback), dlg);
    }

    {
        GtkWidget *hbox, *vbox, *button, *sw;

        /* create expander's vbox */
        vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (dlg->expander), vbox);

        /* add a scrollable window under the expander */
        sw = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start (GTK_BOX(vbox), sw, TRUE, TRUE, 8);

        /* add the treeview to the scrollable window */
        dlg->treeview = gtk_assert_dialog_create_backtrace_list_model ();
        gtk_widget_set_size_request (GTK_WIDGET(dlg->treeview), -1, 180);
        gtk_container_add (GTK_CONTAINER (sw), dlg->treeview);

        /* create button's hbox */
        hbox = gtk_hbutton_box_new ();
        gtk_box_pack_end (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        gtk_button_box_set_layout (GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);

        /* add the buttons */
        button = gtk_assert_dialog_add_button_to (GTK_BOX(hbox), "Save to _file",
                                                GTK_STOCK_SAVE);
        g_signal_connect (button, "clicked",
                            G_CALLBACK(gtk_assert_dialog_save_backtrace_callback), dlg);

        button = gtk_assert_dialog_add_button_to (GTK_BOX(hbox), "Copy to clip_board",
                                                  GTK_STOCK_COPY);
        g_signal_connect (button, "clicked", G_CALLBACK(gtk_assert_dialog_copy_callback), dlg);
    }

    /* add the checkbutton */
    dlg->shownexttime = gtk_check_button_new_with_mnemonic("Show this _dialog the next time");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dlg->shownexttime), TRUE);
    gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dlg))), dlg->shownexttime, false, true, 8);

    /* add the stop button */
    gtk_assert_dialog_add_button (dlg, "_Stop", GTK_STOCK_QUIT, GTK_ASSERT_DIALOG_STOP);

    /* add the continue button */
    continuebtn = gtk_assert_dialog_add_button (dlg, "_Continue", GTK_STOCK_YES, GTK_ASSERT_DIALOG_CONTINUE);
    gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_ASSERT_DIALOG_CONTINUE);
    g_signal_connect (continuebtn, "clicked", G_CALLBACK(gtk_assert_dialog_continue_callback), dlg);

    /* complete creation */
    dlg->callback = NULL;
    dlg->userdata = NULL;

    /* the resizable property of this window is modified by the expander:
       when it's collapsed, the window must be non-resizable! */
    gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
    gtk_widget_pop_composite_child ();
    gtk_widget_show_all (GTK_WIDGET(dlg));
}
Example #6
0
void send_raw_file(GtkAction *action, gpointer data)
{
	GtkWidget *file_select;

	file_select = gtk_file_chooser_dialog_new(_("Send RAW File"),
	              GTK_WINDOW(Fenetre),
	              GTK_FILE_CHOOSER_ACTION_OPEN,
	              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
	              GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
	              NULL);

	if(fic_defaut != NULL)
		gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_select), fic_defaut);

	if(gtk_dialog_run(GTK_DIALOG(file_select)) == GTK_RESPONSE_ACCEPT)
	{
		gchar *fileName;
		gchar *msg;

		fileName = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_select));

		if(!g_file_test(fileName, G_FILE_TEST_IS_REGULAR))
		{
			msg = g_strdup_printf(_("Error opening file\n"));
			show_message(msg, MSG_ERR);
			g_free(msg);
			g_free(fileName);
			gtk_widget_destroy(file_select);
			return;
		}

		Fichier = open(fileName, O_RDONLY);
		if(Fichier != -1)
		{
			GtkWidget *Bouton_annuler, *Box;

			fic_defaut = g_strdup(fileName);
			msg = g_strdup_printf(_("%s : transfer in progress..."), fileName);

			gtk_statusbar_push(GTK_STATUSBAR(StatusBar), id, msg);
			car_written = 0;
			current_buffer_position = 0;
			bytes_read = 0;
			nb_car = lseek(Fichier, 0L, SEEK_END);
			lseek(Fichier, 0L, SEEK_SET);

			Window = gtk_dialog_new();
			gtk_window_set_title(GTK_WINDOW(Window), msg);
			g_free(msg);
			Box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
			gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(Window))), Box);
			ProgressBar = gtk_progress_bar_new();

			gtk_box_pack_start(GTK_BOX(Box), ProgressBar, FALSE, FALSE, 5);

			Bouton_annuler = gtk_button_new_with_label(_("Cancel"));
			g_signal_connect(GTK_WIDGET(Bouton_annuler), "clicked", G_CALLBACK(close_all), NULL);

			gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(Window))), Bouton_annuler);

			g_signal_connect(GTK_WIDGET(Window), "delete_event", G_CALLBACK(close_all), NULL);

			gtk_window_set_default_size(GTK_WINDOW(Window), 250, 100);
			gtk_window_set_modal(GTK_WINDOW(Window), TRUE);
			gtk_widget_show_all(Window);

			add_input();
		}
		else
		{
			msg = g_strdup_printf(_("Cannot read file %s: %s\n"), fileName, strerror(errno));
			show_message(msg, MSG_ERR);
			g_free(msg);
		}
		g_free(fileName);
	}
	gtk_widget_destroy(file_select);
}
Example #7
0
gint
gnc_dialog_run (GtkDialog *dialog, const gchar *pref_name)
{
    GtkWidget *perm, *temp;
    gboolean ask = TRUE;
    gint response;

    /* Does the user want to see this question? If not, return the
     * previous answer. */
    response = gnc_prefs_get_int(GNC_PREFS_GROUP_WARNINGS_PERM, pref_name);
    if (response != 0)
        return response;
    response = gnc_prefs_get_int(GNC_PREFS_GROUP_WARNINGS_TEMP, pref_name);
    if (response != 0)
        return response;

    /* Add in the checkboxes to find out if the answer should be remembered. */
#if 0
    if (GTK_IS_MESSAGE_DIALOG(dialog))
    {
        GtkMessageType type;
        g_object_get(dialog, "message-type", &type, (gchar*)NULL);
        ask = (type == GTK_MESSAGE_QUESTION);
    }
    else
    {
        ask = FALSE;
    }
#endif
    perm = gtk_check_button_new_with_mnemonic
           (ask
            ? _("Remember and don't _ask me again.")
            : _("Don't _tell me again."));
    temp = gtk_check_button_new_with_mnemonic
           (ask
            ? _("Remember and don't ask me again this _session.")
            : _("Don't tell me again this _session."));
    gtk_widget_show(perm);
    gtk_widget_show(temp);
    gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), perm, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), temp, TRUE, TRUE, 0);
    g_signal_connect(perm, "clicked", G_CALLBACK(gnc_perm_button_cb), temp);

    /* OK. Present the dialog. */
    response = gtk_dialog_run(dialog);
    if ((response == GTK_RESPONSE_NONE) || (response == GTK_RESPONSE_DELETE_EVENT))
    {
        return GTK_RESPONSE_CANCEL;
    }

    if (response != GTK_RESPONSE_CANCEL)
    {
        /* Save the answer? */
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm)))
        {
            gnc_prefs_set_int(GNC_PREFS_GROUP_WARNINGS_PERM, pref_name, response);
        }
        else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(temp)))
        {
            gnc_prefs_set_int(GNC_PREFS_GROUP_WARNINGS_TEMP, pref_name, response);
        }
    }
    return response;
}
static void
polkit_mate_authentication_dialog_constructed (GObject *object)
{
  PolkitMateAuthenticationDialog *dialog;
  GtkWidget *hbox;
  GtkWidget *main_vbox;
  GtkWidget *vbox;
  GtkWidget *table_alignment;
  GtkWidget *table;
  GtkWidget *details_expander;
  GtkWidget *details_vbox;
  GtkWidget *label;
  GtkWidget *image;
  GtkWidget *content_area;
  GtkWidget *action_area;
  gboolean have_user_combobox;
  gchar *s;
  guint rows;

  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);

  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);

  have_user_combobox = FALSE;

  dialog->priv->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
                                                            GTK_STOCK_CANCEL,
                                                            GTK_RESPONSE_CANCEL);
  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
                                                          _("_Authenticate"),
                                                          GTK_RESPONSE_OK);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));

  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
  gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
  gtk_box_set_spacing (GTK_BOX (action_area), 6);
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
  gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION);

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);

  image = get_image (dialog);
  gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);

  main_vbox = gtk_vbox_new (FALSE, 10);
  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);

  /* main message */
  label = gtk_label_new (NULL);
  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
  gtk_label_set_markup (GTK_LABEL (label), s);
  g_free (s);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);

  /* secondary message */
  label = gtk_label_new (NULL);
  if (g_strv_length (dialog->priv->users) > 1)
    {
          gtk_label_set_markup (GTK_LABEL (label),
                                _("An application is attempting to perform an action that requires privileges. "
                                  "Authentication as one of the users below is required to perform this action."));
    }
  else
    {
      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
        {
          gtk_label_set_markup (GTK_LABEL (label),
                                _("An application is attempting to perform an action that requires privileges. "
                                  "Authentication is required to perform this action."));
        }
      else
        {
          gtk_label_set_markup (GTK_LABEL (label),
                                _("An application is attempting to perform an action that requires privileges. "
                                  "Authentication as the super user is required to perform this action."));
        }
    }
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);

  /* user combobox */
  if (g_strv_length (dialog->priv->users) > 1)
    {
      dialog->priv->user_combobox = gtk_combo_box_new ();
      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);

      create_user_combobox (dialog);

      have_user_combobox = TRUE;
    }
  else
    {
      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
    }

  /* password entry */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);

  table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
  gtk_box_pack_start (GTK_BOX (vbox), table_alignment, FALSE, FALSE, 0);
  table = gtk_table_new (1, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_container_add (GTK_CONTAINER (table_alignment), table);
  dialog->priv->password_entry = gtk_entry_new ();
  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
  dialog->priv->prompt_label = add_row (table, 0, _("_Password:"), dialog->priv->password_entry);

  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
                            G_CALLBACK (gtk_window_activate_default),
                            dialog);

  dialog->priv->table_alignment = table_alignment;
  /* initially never show the password entry stuff; we'll toggle it on/off so it's
   * only shown when prompting for a password */
  gtk_widget_set_no_show_all (dialog->priv->table_alignment, TRUE);

  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
  label = gtk_label_new (NULL);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  dialog->priv->info_label = label;

  /* Details */
  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);

  details_vbox = gtk_vbox_new (FALSE, 10);
  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);

  table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
  gtk_box_pack_start (GTK_BOX (details_vbox), table_alignment, FALSE, FALSE, 0);
  table = gtk_table_new (1, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_container_add (GTK_CONTAINER (table_alignment), table);

  /* TODO: sort keys? */
  rows = 0;
  if (dialog->priv->details != NULL)
    {
      guint n;
      gchar **keys;

      keys = polkit_details_get_keys (dialog->priv->details);
      for (n = 0; keys[n] != NULL; n++)
        {
          const gchar *key = keys[n];
          const gchar *value;

          value = polkit_details_lookup (dialog->priv->details, key);

          label = gtk_label_new (NULL);
          s = g_strdup_printf ("<small>%s</small>", value);
          gtk_label_set_markup (GTK_LABEL (label), s);
          g_free (s);
          gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
          add_row (table, rows, s, label);
          g_free (s);

          rows++;
        }
      g_strfreev (keys);
    }

  /* --- */

  label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
                       dialog->priv->action_id,
                       dialog->priv->action_id);
  gtk_label_set_markup (GTK_LABEL (label), s);
  g_free (s);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
  add_row (table, rows++, _("<small><b>Action:</b></small>"), label);
  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);

  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
  gtk_widget_set_tooltip_markup (label, s);
  g_free (s);

  /* --- */

  label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
                       dialog->priv->vendor_url,
                       dialog->priv->vendor);
  gtk_label_set_markup (GTK_LABEL (label), s);
  g_free (s);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0);
  add_row (table, rows++, _("<small><b>Vendor:</b></small>"), label);

  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
  gtk_widget_set_tooltip_markup (label, s);
  g_free (s);

  if (have_user_combobox)
    {
      /* ... and make the password entry and "Authenticate" button insensitive */
      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
    }
  else
    {
    }

  gtk_widget_realize (GTK_WIDGET (dialog));

}
gint
dialog_I (PlugInImageVals * image_vals,
          PlugInDrawableVals * drawable_vals,
          PlugInVals * vals,
          PlugInUIVals * ui_vals,
          PlugInColVals * col_vals,
          PlugInDialogVals * dialog_vals)
{
    gint32 image_ID;
    gint32 layer_ID;
    gint orig_width, orig_height;
    GtkWidget *main_hbox;
    GtkWidget *vbox;
    GtkWidget *vbox2;
    GtkWidget *vbox3;
    GtkWidget *hbox;
    GtkWidget *hbox2;
    GtkWidget *frame;

    GtkWidget *filler;
    GtkWidget *pres_use_image;
    GtkWidget *disc_use_image;
    GtkWidget *rigmask_use_image;
    //GtkWidget *noninter_button;
    GtkWidget *resetvalues_event_box;
    GtkWidget *resetvalues_button;
    GtkWidget *resetvalues_icon;

    GtkWidget *flatten_event_box;
    GtkWidget *flatten_button;
    GtkWidget *flatten_icon;
    GtkWidget *show_info_event_box;
    GtkWidget *show_info_button;
    GtkWidget *show_info_icon;
    GtkWidget *dump_event_box;
    GtkWidget *dump_button;
    GtkWidget *dump_icon;
    //GtkWidget *lastvalues_event_box;
    //GtkWidget *lastvalues_button;
    //GtkWidget *lastvalues_icon;
    gboolean has_mask = FALSE;
    GimpUnit unit;
    gdouble xres, yres;
    GtkWidget * v_separator;
    GtkWidget *info_title_label;
    GtkWidget * info_label;

    CarverData * carver_data;

    image_ID = image_vals->image_ID;
    layer_ID = drawable_vals->layer_ID;

    state = g_new (PlugInVals, 1);
    memcpy (state, vals, sizeof (PlugInVals));

    ui_state = g_new (PlugInUIVals, 1);
    memcpy (ui_state, ui_vals, sizeof (PlugInUIVals));

    dialog_state = dialog_vals;

    orig_width = gimp_drawable_width (layer_ID);
    orig_height = gimp_drawable_height (layer_ID);

    g_assert (gimp_drawable_is_layer (layer_ID) == TRUE);

    interface_I_data.orig_width = orig_width;
    interface_I_data.orig_height = orig_height;
    interface_I_data.col_vals = col_vals;
    interface_I_data.vmap_layer_ID = -1;

    reader_go = TRUE;

    if (gimp_layer_get_mask (layer_ID) != -1)
    {
        has_mask = TRUE;
    }

    dlg = gtk_dialog_new_with_buttons (_("GIMP LiquidRescale Plug-In"),
                                       NULL, 0,
                                       //GIMP_STOCK_RESET, RESPONSE_RESET,
                                       //GTK_STOCK_REFRESH, RESPONSE_REFRESH,
                                       GTK_STOCK_GO_BACK, RESPONSE_NONINTERACTIVE,
                                       GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);

    gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);

    gtk_window_set_keep_above(GTK_WINDOW (dlg), TRUE);

    if (dialog_state->has_pos)
    {
        //printf("move window, x,y=%i,%i\n", dialog_state->x, dialog_state->y); fflush(stdout);
        gtk_window_move (GTK_WINDOW(dlg), dialog_state->x, dialog_state->y);
        dialog_state->has_pos = FALSE;
    }

    g_signal_connect (dlg, "response", G_CALLBACK (callback_dialog_I_response),
                      (gpointer) (NULL));

    /* dlg_tips = gtk_tooltips_new (); */

    main_hbox = gtk_hbox_new (FALSE, 12);
    gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12);
    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area(GTK_DIALOG (dlg))), main_hbox);

    vbox = gtk_vbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
    gtk_widget_show (vbox);

    /*  New size  */

    frame = gimp_frame_new (_("Set width and height"));
    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
    gtk_widget_show (frame);

    hbox = gtk_hbox_new (FALSE, 4);
    gtk_container_add (GTK_CONTAINER (frame), hbox);
    gtk_widget_show (hbox);

    vbox3 = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (hbox), vbox3, FALSE, FALSE, 0);
    gtk_widget_show (vbox3);

    unit = gimp_image_get_unit (image_ID);
    gimp_image_get_resolution (image_ID, &xres, &yres);

    coordinates =
        alt_coordinates_new (unit, "%p", TRUE, TRUE, SPIN_BUTTON_WIDTH,
                             ALT_SIZE_ENTRY_UPDATE_SIZE, ui_state->chain_active,
                             TRUE, _("Width:"), state->new_width, xres, 2,
                             GIMP_MAX_IMAGE_SIZE, 0, orig_width,
                             _("Height:"), state->new_height, yres, 2,
                             GIMP_MAX_IMAGE_SIZE, 0, orig_height);

    interface_I_data.coordinates = coordinates;

    g_signal_connect (ALT_SIZE_ENTRY (coordinates), "value-changed",
                      G_CALLBACK (callback_size_changed),
                      (gpointer) & interface_I_data);

    g_signal_connect (ALT_SIZE_ENTRY (coordinates), "refval-changed",
                      G_CALLBACK (callback_size_changed),
                      (gpointer) & interface_I_data);

    g_signal_connect (ALT_SIZE_ENTRY (coordinates), "coordinates-alarm",
                      G_CALLBACK (callback_alarm_triggered),
                      (gpointer) & interface_I_data);

    gtk_box_pack_start (GTK_BOX (vbox3), coordinates, FALSE, FALSE, 0);
    gtk_widget_show (coordinates);

    /* Aux layer usage icons */

    hbox2 = gtk_hbox_new (FALSE, 10);
    gtk_container_set_border_width (GTK_CONTAINER (hbox2), 4);
    gtk_box_pack_start (GTK_BOX (vbox3), hbox2, FALSE, FALSE, 0);
    gtk_widget_show (hbox2);

    filler = gtk_image_new ();
    gtk_box_pack_start (GTK_BOX (hbox2), filler, TRUE, TRUE, 0);
    gtk_widget_show (filler);
    filler = gtk_image_new ();
    gtk_box_pack_end (GTK_BOX (hbox2), filler, TRUE, TRUE, 0);
    gtk_widget_show (filler);

    pres_use_image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_GREEN,
                     GTK_ICON_SIZE_MENU);

    gtk_box_pack_start (GTK_BOX (hbox2), pres_use_image, FALSE, FALSE, 0);

    gtk_widget_show (pres_use_image);

    disc_use_image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_RED,
                     GTK_ICON_SIZE_MENU);

    gtk_box_pack_start (GTK_BOX (hbox2), disc_use_image, FALSE, FALSE, 0);

    gtk_widget_show (disc_use_image);

    rigmask_use_image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_BLUE,
                        GTK_ICON_SIZE_MENU);

    gtk_widget_show (rigmask_use_image);

    gtk_box_pack_start (GTK_BOX (hbox2), rigmask_use_image, FALSE, FALSE, 0);

    update_info_aux_use_icons(vals, ui_vals, pres_use_image, disc_use_image, rigmask_use_image);


    /* Reset size button */

    vbox2 = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_end (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
    gtk_widget_show (vbox2);

    resetvalues_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), resetvalues_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (resetvalues_event_box);

    gimp_help_set_help_data (resetvalues_event_box,
                             _
                             ("Reset width and height to their original values"),
                             NULL);

    resetvalues_button = gtk_button_new ();
    resetvalues_icon =
        gtk_image_new_from_stock (GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (resetvalues_button), resetvalues_icon);
    gtk_widget_show (resetvalues_icon);
    gtk_container_add (GTK_CONTAINER (resetvalues_event_box),
                       resetvalues_button);
    gtk_widget_show (resetvalues_button);

    g_signal_connect (resetvalues_button, "clicked",
                      G_CALLBACK (callback_resetvalues_button),
                      (gpointer) & interface_I_data);

    /* Map info */

    v_separator = gtk_vseparator_new();
    gtk_box_pack_start (GTK_BOX (main_hbox), v_separator, TRUE, TRUE, 0);
    gtk_widget_show(v_separator);

    vbox = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
    gtk_widget_show (vbox);

    hbox2 = gtk_hbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
    gtk_widget_show (hbox2);

    info_title_label = gtk_label_new ("");
    /* Please keep the <b> and </b> tags in translations */
    gtk_label_set_markup(GTK_LABEL(info_title_label), _("<b>Map</b>"));
    gtk_box_pack_start (GTK_BOX (hbox2), info_title_label, FALSE, FALSE, 0);
    gtk_widget_show (info_title_label);

    hbox = gtk_hbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    vbox2 = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
    gtk_widget_show (vbox2);

    show_info_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), show_info_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (show_info_event_box);

    gimp_help_set_help_data (show_info_event_box,
                             _
                             ("Show/hide internal map information"),
                             NULL);

    show_info_button = gtk_toggle_button_new ();
    show_info_icon =
        gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (show_info_button), show_info_icon);
    gtk_widget_show (show_info_icon);
    gtk_container_add (GTK_CONTAINER (show_info_event_box),
                       show_info_button);
    gtk_widget_show (show_info_button);

    g_signal_connect (show_info_button, "toggled",
                      G_CALLBACK (callback_show_info_button),
                      (gpointer) & interface_I_data);


    flatten_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), flatten_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (flatten_event_box);

    gimp_help_set_help_data (flatten_event_box,
                             _
                             ("Reset the internal map"),
                             NULL);

    flatten_button = gtk_button_new ();
    flatten_icon =
        gtk_image_new_from_stock (GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (flatten_button), flatten_icon);
    gtk_widget_show (flatten_icon);
    gtk_container_add (GTK_CONTAINER (flatten_event_box),
                       flatten_button);
    gtk_widget_show (flatten_button);

    g_signal_connect (flatten_button, "clicked",
                      G_CALLBACK (callback_flatten_button),
                      (gpointer) & interface_I_data);

    dump_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), dump_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (dump_event_box);

    gimp_help_set_help_data (dump_event_box,
                             _
                             ("Dump the internal map on a new layer (RGB images only)"),
                             NULL);

    dump_button = gtk_button_new ();
    dump_icon =
        gtk_image_new_from_stock (GIMP_STOCK_VISIBLE, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (dump_button), dump_icon);
    gtk_widget_show (dump_icon);
    gtk_container_add (GTK_CONTAINER (dump_event_box),
                       dump_button);
    gtk_widget_show (dump_button);

    g_signal_connect (dump_button, "clicked",
                      G_CALLBACK (callback_dump_button),
                      (gpointer) & interface_I_data);

    gtk_widget_set_sensitive(dump_button, FALSE);
    interface_I_data.dump_button = dump_button;

    info_label = gtk_label_new("");
    //set_info_label_text (info_label, orig_width, orig_height, 0, 0, state->enl_step / 100);
    gtk_label_set_selectable(GTK_LABEL(info_label), TRUE);
    //gtk_container_add (GTK_CONTAINER (info_frame), info_label);
    gtk_box_pack_start (GTK_BOX (hbox), info_label, TRUE, TRUE, 0);
    gtk_label_set_justify(GTK_LABEL (info_label), GTK_JUSTIFY_LEFT);
    gtk_widget_show (info_label);

    //interface_I_data.info_frame = info_frame;
    interface_I_data.info_label = info_label;

    callback_show_info_button(show_info_button, (gpointer) &interface_I_data);


    /*
    noninter_button = gtk_button_new_with_mnemonic ("_Non-interactive");

    g_signal_connect (GTK_BUTTON (noninter_button), "clicked",
                      G_CALLBACK (callback_noninter_button), (gpointer) dlg);

    gtk_box_pack_start (GTK_BOX (vbox2), noninter_button, FALSE, FALSE, 0);
    gtk_widget_show (noninter_button);
    */

    /* Initialize the carver */

    AUX_LAYER_STATUS(state->pres_layer_ID, ui_state->pres_status);
    AUX_LAYER_STATUS(state->disc_layer_ID, ui_state->disc_status);
    AUX_LAYER_STATUS(state->rigmask_layer_ID, ui_state->rigmask_status);
    gimp_image_undo_group_start(image_ID);
    carver_data = render_init_carver(image_vals, drawable_vals, state, TRUE);
    gimp_image_undo_group_end(image_ID);
    if (carver_data == NULL)
    {
        return RESPONSE_FATAL;
    }
    interface_I_data.carver_data = carver_data;

    image_vals->image_ID = carver_data->image_ID;
    drawable_vals->layer_ID = carver_data->layer_ID;

    set_info_label_text (&interface_I_data);

    //set_alarm (ALARM_DELAY);
    size_changed = 1;

    /* register size reader */

    g_timeout_add (READER_INTERVAL, check_size_changes, NULL);

    /*  Show the main containers  */

    gtk_widget_show (main_hbox);
    gtk_widget_show (dlg);
    gtk_main ();


    lqr_carver_destroy (carver_data->carver);

    switch (dialog_I_response)
    {
    case RESPONSE_NONINTERACTIVE:
        switch (state->output_target)
        {
        case OUTPUT_TARGET_NEW_LAYER:
        case OUTPUT_TARGET_NEW_IMAGE:
            state->output_target = OUTPUT_TARGET_SAME_LAYER;
            break;
        case OUTPUT_TARGET_SAME_LAYER:
        default:
            break;
        }
    case GTK_RESPONSE_OK:
        /*  Save ui values  */
        ui_state->chain_active =
            gimp_chain_button_get_active (GIMP_COORDINATES_CHAINBUTTON
                                          (coordinates));

        /* save all */
        memcpy (vals, state, sizeof (PlugInVals));
        memcpy (ui_vals, ui_state, sizeof (PlugInUIVals));
        break;
    default:
        break;
    }

    gtk_widget_destroy (dlg);

    reader_go = FALSE;

    return dialog_I_response;
}
Example #10
0
/**
 * Uploading a VikTrwLayer
 *
 * @param vtl VikTrwLayer
 * @param trk if not null, the track to upload
 */
void osm_traces_upload_viktrwlayer ( VikTrwLayer *vtl, VikTrack *trk )
{
  GtkWidget *dia = gtk_dialog_new_with_buttons (_("OSM upload"),
                                                 VIK_GTK_WINDOW_FROM_LAYER(vtl),
                                                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_STOCK_CANCEL,
                                                 GTK_RESPONSE_REJECT,
                                                 GTK_STOCK_OK,
                                                 GTK_RESPONSE_ACCEPT,
                                                 NULL);

  const gchar *name = NULL;
  GtkWidget *user_label, *user_entry;
  GtkWidget *password_label, *password_entry;
  GtkWidget *name_label, *name_entry;
  GtkWidget *description_label, *description_entry;
  GtkWidget *tags_label, *tags_entry;
  GtkWidget *visibility;
  GtkWidget *anonymize_checkbutton = NULL;
  const OsmTraceVis_t *vis_t;

  user_label = gtk_label_new(_("Email:"));
  user_entry = gtk_entry_new();
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), user_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), user_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_markup(GTK_WIDGET(user_entry),
                        _("The email used as login\n"
                        "<small>Enter the email you use to login into www.openstreetmap.org.</small>"));

  password_label = gtk_label_new(_("Password:"));
  password_entry = gtk_entry_new();
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), password_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), password_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_markup(GTK_WIDGET(password_entry),
                        _("The password used to login\n"
                        "<small>Enter the password you use to login into www.openstreetmap.org.</small>"));

  osm_login_widgets ( user_entry, password_entry );

  name_label = gtk_label_new(_("File's name:"));
  name_entry = gtk_entry_new();
  if (trk != NULL)
    name = trk->name;
  else
    name = vik_layer_get_name(VIK_LAYER(vtl));
  gtk_entry_set_text(GTK_ENTRY(name_entry), name);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), name_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), name_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_markup(GTK_WIDGET(name_entry),
                        _("The name of the file on OSM\n"
                        "<small>This is the name of the file created on the server."
			"This is not the name of the local file.</small>"));

  description_label = gtk_label_new(_("Description:"));
  description_entry = gtk_entry_new();
  const gchar *description = NULL;
  if (trk != NULL)
    description = trk->description;
  else {
    VikTRWMetadata *md = vik_trw_layer_get_metadata (vtl);
    description = md ? md->description : NULL;
  }
  if (description)
    gtk_entry_set_text(GTK_ENTRY(description_entry), description);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), description_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), description_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_text(GTK_WIDGET(description_entry),
                        _("The description of the trace"));

  if (trk != NULL) {
    GtkWidget *label = gtk_label_new(_("Anonymize Times:"));
    anonymize_checkbutton = gtk_check_button_new ();
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), label, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), anonymize_checkbutton, FALSE, FALSE, 0);
    gtk_widget_set_tooltip_text(GTK_WIDGET(anonymize_checkbutton),
                                _("Anonymize times of the trace.\n"
                                  "<small>You may choose to make the trace identifiable, yet mask the actual real time values</small>"));
  }

  tags_label = gtk_label_new(_("Tags:"));
  tags_entry = gtk_entry_new();
  VikTRWMetadata *md = vik_trw_layer_get_metadata (vtl);
  if (md->keywords)
    gtk_entry_set_text(GTK_ENTRY(tags_entry), md->keywords);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), tags_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), tags_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_text(GTK_WIDGET(tags_entry),
                        _("The tags associated to the trace"));

  visibility = vik_combo_box_text_new();
  for (vis_t = OsmTraceVis; vis_t->combostr != NULL; vis_t++)
    vik_combo_box_text_append (visibility, vis_t->combostr);

  // Set identifiable by default or use the settings for the value
  if ( last_active < 0 ) {
    gint find_entry = -1;
    gint wanted_entry = -1;
    gchar *vis = NULL;
    if ( a_settings_get_string ( VIK_SETTINGS_OSM_TRACE_VIS, &vis ) ) {
      // Use setting
      if ( vis ) {
        for (vis_t = OsmTraceVis; vis_t->apistr != NULL; vis_t++) {
          find_entry++;
          if (!strcmp(vis, vis_t->apistr)) {
            wanted_entry = find_entry;
          }
        }
      }
      // If not found set it to the first entry, otherwise use the entry
      last_active = ( wanted_entry < 0 ) ? 0 : wanted_entry;
    }
    else
      last_active = 0;
  }
  gtk_combo_box_set_active(GTK_COMBO_BOX(visibility), last_active);
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), GTK_WIDGET(visibility), FALSE, FALSE, 0);

  /* User should think about it first... */
  gtk_dialog_set_default_response ( GTK_DIALOG(dia), GTK_RESPONSE_REJECT );

  gtk_widget_show_all ( dia );
  gtk_widget_grab_focus ( description_entry );

  if ( gtk_dialog_run ( GTK_DIALOG(dia) ) == GTK_RESPONSE_ACCEPT )
  {
    gchar *title = NULL;

    /* overwrite authentication info */
    osm_set_login(gtk_entry_get_text(GTK_ENTRY(user_entry)),
                  gtk_entry_get_text(GTK_ENTRY(password_entry)));

    /* Storing data for the future thread */
    OsmTracesInfo *info = g_malloc(sizeof(OsmTracesInfo));
    info->name        = g_strdup(gtk_entry_get_text(GTK_ENTRY(name_entry)));
    info->description = g_strdup(gtk_entry_get_text(GTK_ENTRY(description_entry)));
    /* TODO Normalize tags: they will be used as URL part */
    info->tags        = g_strdup(gtk_entry_get_text(GTK_ENTRY(tags_entry)));
    info->vistype     = &OsmTraceVis[gtk_combo_box_get_active(GTK_COMBO_BOX(visibility))];
    info->vtl         = VIK_TRW_LAYER(g_object_ref(vtl));
    info->trk         = trk;
    if (trk != NULL && anonymize_checkbutton != NULL )
      info->anonymize_times = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(anonymize_checkbutton));
    else
      info->anonymize_times = FALSE;

    // Save visibility value for default reuse
    last_active = gtk_combo_box_get_active(GTK_COMBO_BOX(visibility));
    a_settings_set_string ( VIK_SETTINGS_OSM_TRACE_VIS, OsmTraceVis[last_active].apistr );

    title = g_strdup_printf(_("Uploading %s to OSM"), info->name);

    /* launch the thread */
    a_background_thread(VIK_GTK_WINDOW_FROM_LAYER(vtl),          /* parent window */
			title,                                   /* description string */
			(vik_thr_func) osm_traces_upload_thread, /* function to call within thread */
			info,                                    /* pass along data */
			(vik_thr_free_func) oti_free,            /* function to free pass along data */
			(vik_thr_free_func) NULL,
			1 );
    g_free ( title ); title = NULL;
  }
  gtk_widget_destroy ( dia );
}
int
main (int argc, char **argv)
{
    GdkScreen *screen;
    GtkWidget *nb;
    GtkWidget *general_vbox;
    GtkWidget *behaviour_vbox;
    GtkWidget *placement_vbox;
    GtkWidget *widget;
    GtkWidget *vbox;
    GtkWidget *vbox1;
    GtkWidget *hbox;
    GtkWidget *hbox1;
    GtkWidget *hbox2;
    GtkWidget *hbox3;
    GtkWidget *content_area;
    gchar *str;
    const char *current_wm;
    int i;

    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    gtk_init (&argc, &argv);

    screen = gdk_display_get_default_screen (gdk_display_get_default ());
    current_wm = gdk_x11_screen_get_window_manager_name (screen);

    if (g_strcmp0 (current_wm, WM_COMMON_METACITY) == 0) {
        mate_metacity_config_tool ();
        return 0;
    }

    if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) {
        wm_unsupported ();
        return 1;
    }

    marco_settings = g_settings_new (MARCO_SCHEMA);

    /* Window */
    dialog_win = gtk_dialog_new_with_buttons (_("Window Preferences"),
                                              NULL,
                                              GTK_DIALOG_MODAL,
                                              GTK_STOCK_HELP,
                                              GTK_RESPONSE_HELP,
                                              GTK_STOCK_CLOSE,
                                              GTK_RESPONSE_CLOSE,
                                              NULL);
    //gtk_window_set_resizable (GTK_WINDOW (dialog_win), FALSE);
    gtk_window_set_icon_name (GTK_WINDOW (dialog_win), "preferences-system-windows");
    gtk_container_set_border_width (GTK_CONTAINER (dialog_win), 10);

    nb = gtk_notebook_new ();

    general_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    behaviour_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    placement_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

    widget = gtk_label_new (_("General"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), general_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    widget = gtk_label_new (_("Behaviour"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), behaviour_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    widget = gtk_label_new (_("Placement"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), placement_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    /* Compositing manager */
    widget = title_label_new (N_("Compositing Manager"));
    gtk_box_pack_start (GTK_BOX (general_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    compositing_checkbutton = gtk_check_button_new_with_mnemonic (_("Enable software _compositing window manager"));
    compositing_fast_alt_tab_checkbutton = gtk_check_button_new_with_mnemonic (_("Disable _thumbnails in Alt-Tab"));
    gtk_box_pack_start (GTK_BOX (vbox), compositing_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox1), compositing_fast_alt_tab_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox1, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (general_vbox), hbox, FALSE, FALSE, 6);

    /* Titlebar buttons */
    widget = title_label_new (N_("Titlebar Buttons"));
    gtk_box_pack_start (GTK_BOX (general_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    widget = gtk_label_new (_("Position:"));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    titlebar_layout_optionmenu = gtk_combo_box_text_new ();
    gtk_box_pack_start (GTK_BOX (hbox), titlebar_layout_optionmenu, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (general_vbox), hbox, FALSE, FALSE, 6);

    /* New Windows */
    widget = title_label_new (N_("New Windows"));
    gtk_box_pack_start (GTK_BOX (placement_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    center_new_windows_checkbutton = gtk_check_button_new_with_mnemonic (_("Center _new windows"));
    gtk_box_pack_start (GTK_BOX (hbox), center_new_windows_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (placement_vbox), hbox, FALSE, FALSE, 6);

    /* Window Snapping */
    widget = title_label_new (N_("Window Snapping"));
    gtk_box_pack_start (GTK_BOX (placement_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    side_by_side_tiling_checkbutton = gtk_check_button_new_with_mnemonic (_("Enable side by side _tiling"));
    gtk_box_pack_start (GTK_BOX (hbox), side_by_side_tiling_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (placement_vbox), hbox, FALSE, FALSE, 6);

    /* Window Selection */
    widget = title_label_new (N_("Window Selection"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    focus_mode_checkbutton = gtk_check_button_new_with_mnemonic (_("_Select windows when the mouse moves over them"));
    gtk_box_pack_start (GTK_BOX (vbox), focus_mode_checkbutton, FALSE, FALSE, 6);

    focus_mode_mouse_checkbutton = gtk_check_button_new_with_mnemonic (_("U_nselect windows when the mouse leaves them"));
    gtk_box_pack_start (GTK_BOX (hbox1), focus_mode_mouse_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 6);

    autoraise_checkbutton = gtk_check_button_new_with_mnemonic (_("_Raise selected windows after an interval"));
    gtk_box_pack_start (GTK_BOX (hbox2), autoraise_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 6);

    autoraise_delay_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    autoraise_delay_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 10, 0.2);

    widget = gtk_label_new_with_mnemonic (_("_Interval before raising:"));
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), widget, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), autoraise_delay_slider, TRUE, TRUE, 6);
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), autoraise_delay_slider);
    widget = gtk_label_new (_("seconds"));
    gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider), 0.2, 1.0);
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), widget, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), autoraise_delay_hbox, FALSE, FALSE, 6);

    gtk_box_pack_start (GTK_BOX (hbox3), vbox1, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox3, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    /* Titlebar Action */
    widget = title_label_new (N_("Titlebar Action"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    widget = gtk_label_new_with_mnemonic (_("_Double-click titlebar to perform this action:"));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    double_click_titlebar_optionmenu = gtk_combo_box_text_new ();
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), double_click_titlebar_optionmenu);
    gtk_box_pack_start (GTK_BOX (hbox), double_click_titlebar_optionmenu, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    /* Movement Key */
    widget = title_label_new (N_("Movement Key"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    widget = gtk_label_new_with_mnemonic (_("To move a window, press-and-hold this key then grab the window:"));
#if GTK_CHECK_VERSION (3, 16, 0)
    gtk_label_set_xalign (GTK_LABEL (widget), 0.0);
    gtk_label_set_yalign (GTK_LABEL (widget), 0.0);
#else
    gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0);
#endif
    gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 6);

    alt_click_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), alt_click_vbox);
    gtk_box_pack_start (GTK_BOX (vbox), alt_click_vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    reload_mouse_modifiers ();

    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Right"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Left"));
    str = g_settings_get_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY);
    gtk_combo_box_set_active (GTK_COMBO_BOX (titlebar_layout_optionmenu),
                              g_strcmp0 (str, MARCO_BUTTON_LAYOUT_RIGHT) == 0 ? 0 : 1);
    g_free (str);

    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Roll up"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Horizontally"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Vertically"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Minimize"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("None"));
    gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                              g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));

    set_alt_click_value ();
    gtk_range_set_value (GTK_RANGE (autoraise_delay_slider),
                         g_settings_get_int (marco_settings, MARCO_AUTORAISE_DELAY_KEY) / 1000.0);
    gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                              g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));

    g_signal_connect (G_OBJECT (dialog_win), "response",
                      G_CALLBACK (response_cb), NULL);

    g_signal_connect (G_OBJECT (dialog_win), "destroy",
                      G_CALLBACK (gtk_main_quit), NULL);

    g_signal_connect (marco_settings, "changed",
                      G_CALLBACK (marco_settings_changed_callback), NULL);

    g_settings_bind (marco_settings,
                     MARCO_COMPOSITING_MANAGER_KEY,
                     compositing_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_COMPOSITING_FAST_ALT_TAB_KEY,
                     compositing_fast_alt_tab_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_SIDE_BY_SIDE_TILING_KEY,
                     side_by_side_tiling_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_CENTER_NEW_WINDOWS_KEY,
                     center_new_windows_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY,
                      G_CALLBACK (mouse_focus_changed_callback), NULL);
    /* Initialize the checkbox state appropriately */
    mouse_focus_changed_callback(marco_settings, MARCO_FOCUS_KEY, NULL);

    g_signal_connect (focus_mode_checkbutton, "toggled",
                      G_CALLBACK (mouse_focus_toggled_callback), NULL);
    g_signal_connect (focus_mode_mouse_checkbutton, "toggled",
                      G_CALLBACK (mouse_focus_toggled_callback), NULL);

    g_settings_bind (marco_settings,
                     MARCO_AUTORAISE_KEY,
                     autoraise_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_signal_connect (autoraise_delay_slider, "value_changed",
                      G_CALLBACK (autoraise_delay_value_changed_callback), NULL);

    g_signal_connect (double_click_titlebar_optionmenu, "changed",
                      G_CALLBACK (double_click_titlebar_changed_callback), NULL);

    g_signal_connect (titlebar_layout_optionmenu, "changed",
                      G_CALLBACK (titlebar_layout_changed_callback), NULL);

    g_signal_connect (G_OBJECT (screen), "window_manager_changed",
                      G_CALLBACK (wm_changed_callback), NULL);

    i = 0;
    while (i < n_mouse_modifiers) {
        g_signal_connect (G_OBJECT (mouse_modifiers[i].radio), "toggled",
                          G_CALLBACK (alt_click_radio_toggled_callback),
                          &mouse_modifiers[i]);
        ++i;
    }

    /* update sensitivity */
    update_sensitivity ();

    capplet_set_icon (dialog_win, "preferences-system-windows");
    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog_win));
    gtk_box_pack_start (GTK_BOX (content_area), nb, TRUE, TRUE, 0);
    gtk_widget_show_all (dialog_win);

    gtk_main ();

    g_object_unref (marco_settings);

    return 0;
}
Example #12
0
bool RunLinuxDialog()
{
	GtkWidget *dialog;
	int return_value;

	/* Create the widgets */
	dialog = gtk_dialog_new_with_buttons (
		"GSdx Config",
		NULL, /* parent window*/
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		"OK", GTK_RESPONSE_ACCEPT,
		// "Cancel", GTK_RESPONSE_REJECT, // Drop because it is too annoying to support call back this way
		NULL);

	// The main area for the whole dialog box.
	GtkWidget* main_box     = gtk_vbox_new(false, 5);
	GtkWidget* central_box  = gtk_vbox_new(false, 5);
	GtkWidget* advanced_box = gtk_vbox_new(false, 5);
	GtkWidget* debug_box    = gtk_vbox_new(false, 5);

	// Grab a logo, to make things look nice.
	GdkPixbuf* logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL);
	GtkWidget* logo_image  = gtk_image_new_from_pixbuf(logo_pixmap);
	gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0);

	GtkWidget* main_table   = CreateTableInBox(main_box    , NULL                                   , 2  , 2);

	GtkWidget* shader_table = CreateTableInBox(central_box , "Custom Shader Settings"               , 9  , 2);
	GtkWidget* hw_table     = CreateTableInBox(central_box , "Hardware Mode Settings"               , 7  , 2);
	GtkWidget* sw_table     = CreateTableInBox(central_box , "Software Mode Settings"               , 2  , 2);

	GtkWidget* hack_table   = CreateTableInBox(advanced_box, "Hacks"                                , 7 , 2);
	GtkWidget* gl_table     = CreateTableInBox(advanced_box, "OpenGL Very Advanced Custom Settings" , 6 , 2);

	GtkWidget* record_table = CreateTableInBox(debug_box   , "Recording Settings"                   , 4  , 3);
	GtkWidget* debug_table  = CreateTableInBox(debug_box   , "OpenGL / GSdx Debug Settings"         , 6  , 3);

	// Populate all the tables
	populate_main_table(main_table);

	populate_shader_table(shader_table);
	populate_hw_table(hw_table);
	populate_sw_table(sw_table);

	populate_hack_table(hack_table);
	populate_gl_table(gl_table);

	populate_debug_table(debug_table);
	populate_record_table(record_table);

	// Handle some nice tab
	GtkWidget* notebook = gtk_notebook_new();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box , gtk_label_new("Global Settings"));
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_box, gtk_label_new("Advanced Settings"));
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), debug_box   , gtk_label_new("Debug/Recording Settings"));

	// Put everything in the big box.
	gtk_container_add(GTK_CONTAINER(main_box), notebook);

	// Put the box in the dialog and show it to the world.
	gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box);
	gtk_widget_show_all (dialog);
	return_value = gtk_dialog_run (GTK_DIALOG (dialog));

	// Compatibility & not supported option
	int mode_width = theApp.GetConfig("ModeWidth", 640);
	int mode_height = theApp.GetConfig("ModeHeight", 480);
	theApp.SetConfig("ModeHeight", mode_height);
	theApp.SetConfig("ModeWidth", mode_width);
	theApp.SetConfig("msaa", 0);
	theApp.SetConfig("windowed", 1);

	gtk_widget_destroy (dialog);

	return (return_value == GTK_RESPONSE_ACCEPT);
}
Example #13
0
/* dialog stuff */
static gint
max_rgb_dialog (GimpDrawable *drawable)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *preview;
  GtkWidget *frame;
  GtkWidget *max;
  GtkWidget *min;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, TRUE);

  dialog = gimp_dialog_new (_("Maximum RGB Value"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  preview = gimp_zoom_preview_new_from_drawable_id (drawable->drawable_id);
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
  gtk_widget_show (preview);

  g_signal_connect_swapped (preview, "invalidated",
                            G_CALLBACK (main_function),
                            drawable);

  frame = gimp_int_radio_group_new (FALSE, NULL,
                                    G_CALLBACK (gimp_radio_button_update),
                                    &pvals.max_p, pvals.max_p,

                                    _("_Hold the maximal channels"),
                                    MAX_CHANNELS, &max,

                                    _("Ho_ld the minimal channels"),
                                    MIN_CHANNELS, &min,

                                    NULL);

  g_signal_connect_swapped (max, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);
  g_signal_connect_swapped (min, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
Example #14
0
static gboolean
shift_dialog (gint32        image_ID,
              GimpDrawable *drawable)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *preview;
  GtkWidget *frame;
  GtkWidget *size_entry;
  GtkWidget *vertical;
  GtkWidget *horizontal;
  GimpUnit   unit;
  gdouble    xres;
  gdouble    yres;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Shift"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_vbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  preview = gimp_drawable_preview_new (drawable, NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
  gtk_widget_show (preview);

  g_signal_connect_swapped (preview, "invalidated",
                            G_CALLBACK (shift),
                            drawable);

  frame = gimp_int_radio_group_new (FALSE, NULL,
                                    G_CALLBACK (gimp_radio_button_update),
                                    &shvals.orientation, shvals.orientation,

                                    _("Shift _horizontally"),
                                    HORIZONTAL, &horizontal,

                                    _("Shift _vertically"),
                                    VERTICAL,   &vertical,

                                    NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  g_signal_connect_swapped (horizontal, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);
  g_signal_connect_swapped (vertical, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  /*  Get the image resolution and unit  */
  gimp_image_get_resolution (image_ID, &xres, &yres);
  unit = gimp_image_get_unit (image_ID);

  size_entry = gimp_size_entry_new (1, unit, "%a", TRUE, FALSE, FALSE,
                                    SPIN_BUTTON_WIDTH,
                                    GIMP_SIZE_ENTRY_UPDATE_SIZE);

  gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_entry), GIMP_UNIT_PIXEL);
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_entry), 0, xres, TRUE);
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (size_entry), 0,
                                         1.0, 200.0);
  gtk_table_set_col_spacing (GTK_TABLE (size_entry), 0, 4);
  gtk_table_set_col_spacing (GTK_TABLE (size_entry), 2, 12);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (size_entry), 0,
                              (gdouble) shvals.shift_amount);
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (size_entry),
                                _("Shift _amount:"), 1, 0, 0.0);

  g_signal_connect (size_entry, "value-changed",
                    G_CALLBACK (shift_amount_callback),
                    preview);
  gtk_box_pack_start (GTK_BOX (main_vbox), size_entry, FALSE, FALSE, 0);
  gtk_widget_show (size_entry);

  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
Example #15
0
/* depending on type of filter, often only vtl or track will be given.
 * the other can be NULL.
 */
static void acquire ( VikWindow *vw,
                      VikLayersPanel *vlp,
                      VikViewport *vvp,
                      vik_datasource_mode_t mode,
                      VikDataSourceInterface *source_interface,
                      VikTrwLayer *vtl,
                      VikTrack *track,
                      gpointer userdata,
                      VikDataSourceCleanupFunc cleanup_function )
{
  /* for manual dialogs */
  GtkWidget *dialog = NULL;
  GtkWidget *status;
  gchar *cmd = NULL;
  gchar *extra = NULL;
  gchar *cmd_off = NULL;
  gchar *extra_off = NULL;
  acq_dialog_widgets_t *w;
  gpointer user_data;
  gpointer options = NULL;

  acq_vik_t avt;
  avt.vlp = vlp;
  avt.vvp = vvp;
  avt.vw = vw;
  avt.userdata = userdata;

  /* for UI builder */
  gpointer pass_along_data;
  VikLayerParamData *paramdatas = NULL;

  w_and_interface_t *wi;

  /*** INIT AND CHECK EXISTENCE ***/
  if ( source_interface->init_func )
    user_data = source_interface->init_func(&avt);
  else
    user_data = NULL;
  pass_along_data = user_data;

  if ( source_interface->check_existence_func ) {
    gchar *error_str = source_interface->check_existence_func();
    if ( error_str ) {
      a_dialog_error_msg ( GTK_WINDOW(vw), error_str );
      g_free ( error_str );
      return;
    }
  }    

  /* BUILD UI & GET OPTIONS IF NECESSARY. */

  /* POSSIBILITY 0: NO OPTIONS. DO NOTHING HERE. */
  /* POSSIBILITY 1: ADD_SETUP_WIDGETS_FUNC */
  if ( source_interface->add_setup_widgets_func ) {
    dialog = gtk_dialog_new_with_buttons ( "", GTK_WINDOW(vw), 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL );

    gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
    GtkWidget *response_w = NULL;
#if GTK_CHECK_VERSION (2, 20, 0)
    response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
#endif

    source_interface->add_setup_widgets_func(dialog, vvp, user_data);
    gtk_window_set_title ( GTK_WINDOW(dialog), _(source_interface->window_title) );

    if ( response_w )
      gtk_widget_grab_focus ( response_w );

    if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_ACCEPT ) {
      source_interface->cleanup_func(user_data);
      gtk_widget_destroy(dialog);
      return;
    }
  }
  /* POSSIBILITY 2: UI BUILDER */
  else if ( source_interface->params ) {
    paramdatas = a_uibuilder_run_dialog ( source_interface->window_title, GTK_WINDOW(vw),
			source_interface->params, source_interface->params_count,
			source_interface->params_groups, source_interface->params_groups_count,
			source_interface->params_defaults );
    if ( paramdatas )
      pass_along_data = paramdatas;
    else
      return; /* TODO: do we have to free anything here? */
  }

  /* CREATE INPUT DATA & GET COMMAND STRING */

  if ( source_interface->inputtype == VIK_DATASOURCE_INPUTTYPE_TRWLAYER ) {
    gchar *name_src = a_gpx_write_tmp_file ( vtl, NULL );

    ((VikDataSourceGetCmdStringFuncWithInput) source_interface->get_cmd_string_func)
	( pass_along_data, &cmd, &extra, name_src );

    util_add_to_deletion_list ( name_src );

    g_free ( name_src );
  } else if ( source_interface->inputtype == VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK ) {
    gchar *name_src = a_gpx_write_tmp_file ( vtl, NULL );
    gchar *name_src_track = a_gpx_write_track_tmp_file ( track, NULL );

    ((VikDataSourceGetCmdStringFuncWithInputInput) source_interface->get_cmd_string_func)
	( pass_along_data, &cmd, &extra, name_src, name_src_track );

    util_add_to_deletion_list ( name_src );
    util_add_to_deletion_list ( name_src_track );

    g_free ( name_src );
    g_free ( name_src_track );
  } else if ( source_interface->inputtype == VIK_DATASOURCE_INPUTTYPE_TRACK ) {
    gchar *name_src_track = a_gpx_write_track_tmp_file ( track, NULL );

    ((VikDataSourceGetCmdStringFuncWithInput) source_interface->get_cmd_string_func)
	( pass_along_data, &cmd, &extra, name_src_track );

    g_free ( name_src_track );
  } else if ( source_interface->get_cmd_string_func )
    source_interface->get_cmd_string_func ( pass_along_data, &cmd, &extra, &options );

  /* Get data for Off command */
  if ( source_interface->off_func ) {
    source_interface->off_func ( pass_along_data, &cmd_off, &extra_off );
  }

  /* cleanup for option dialogs */
  if ( source_interface->add_setup_widgets_func ) {
    gtk_widget_destroy(dialog);
    dialog = NULL;
  } else if ( source_interface->params ) {
    a_uibuilder_free_paramdatas ( paramdatas, source_interface->params, source_interface->params_count );
  }

  w = g_malloc(sizeof(*w));
  wi = g_malloc(sizeof(*wi));
  wi->w = w;
  wi->w->source_interface = source_interface;
  wi->cmd = cmd;
  wi->extra = extra; /* usually input data type (?) */
  wi->options = options;
  wi->vtl = vtl;
  wi->creating_new_layer = (!vtl); // Default if Auto Layer Management is passed in

  dialog = gtk_dialog_new_with_buttons ( "", GTK_WINDOW(vw), 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL );
  gtk_dialog_set_response_sensitive ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT, FALSE );
  gtk_window_set_title ( GTK_WINDOW(dialog), _(source_interface->window_title) );

  w->dialog = dialog;
  w->running = TRUE;
  status = gtk_label_new (_("Working..."));
  gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), status, FALSE, FALSE, 5 );
  gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
  // May not want to see the dialog at all
  if ( source_interface->is_thread || source_interface->keep_dialog_open )
    gtk_widget_show_all(dialog);
  w->status = status;

  w->vw = vw;
  w->vlp = vlp;
  w->vvp = vvp;
  if ( source_interface->add_progress_widgets_func ) {
    source_interface->add_progress_widgets_func ( dialog, user_data );
  }
  w->user_data = user_data;

  if ( mode == VIK_DATASOURCE_ADDTOLAYER ) {
    VikLayer *current_selected = vik_layers_panel_get_selected ( w->vlp );
    if ( IS_VIK_TRW_LAYER(current_selected) ) {
      wi->vtl = VIK_TRW_LAYER(current_selected);
      wi->creating_new_layer = FALSE;
    }
  }
  else if ( mode == VIK_DATASOURCE_CREATENEWLAYER ) {
    wi->creating_new_layer = TRUE;
  }
  else if ( mode == VIK_DATASOURCE_MANUAL_LAYER_MANAGEMENT ) {
    // Don't create in acquire - as datasource will perform the necessary actions
    wi->creating_new_layer = FALSE;
    VikLayer *current_selected = vik_layers_panel_get_selected ( w->vlp );
    if ( IS_VIK_TRW_LAYER(current_selected) )
      wi->vtl = VIK_TRW_LAYER(current_selected);
  }
  if ( wi->creating_new_layer ) {
    wi->vtl = VIK_TRW_LAYER ( vik_layer_create ( VIK_LAYER_TRW, w->vvp, FALSE ) );
    vik_layer_rename ( VIK_LAYER ( wi->vtl ), _(source_interface->layer_title) );
  }

  if ( source_interface->is_thread ) {
    if ( cmd ) {
#if GLIB_CHECK_VERSION (2, 32, 0)
      g_thread_try_new ( "get_from_anything", (GThreadFunc)get_from_anything, wi, NULL );
#else
      g_thread_create ( (GThreadFunc)get_from_anything, wi, FALSE, NULL );
#endif
      gtk_dialog_run ( GTK_DIALOG(dialog) );
      if (w->running) {
        // Cancel and mark for thread to finish
        w->running = FALSE;
        // NB Thread will free memory
      } else {
        if ( cmd_off ) {
          /* Turn off */
          a_babel_convert_from (NULL, cmd_off, extra_off, NULL, NULL, NULL);
          g_free ( cmd_off );
        }
        if ( extra_off )
          g_free ( extra_off );

        // Thread finished by normal completion - free memory
        g_free ( w );
        g_free ( wi );
      }
    }
    else {
      // This shouldn't happen...
      gtk_label_set_text ( GTK_LABEL(w->status), _("Unable to create command\nAcquire method failed.") );
      gtk_dialog_run (GTK_DIALOG (dialog));
    }
  }
  else {
    // bypass thread method malarkly - you'll just have to wait...
    if ( source_interface->process_func ) {
      gboolean result = source_interface->process_func ( wi->vtl, cmd, extra, (BabelStatusFunc) progress_func, w, options );
      if ( !result )
        a_dialog_msg ( GTK_WINDOW(vw), GTK_MESSAGE_ERROR, _("Error: acquisition failed."), NULL );
    }
    g_free ( cmd );
    g_free ( extra );
    g_free ( options );

    on_complete_process ( wi );
    // Actually show it if necessary
    if ( wi->w->source_interface->keep_dialog_open )
      gtk_dialog_run ( GTK_DIALOG(dialog) );

    g_free ( w );
    g_free ( wi );
  }

  gtk_widget_destroy ( dialog );

  if ( cleanup_function )
    cleanup_function ( source_interface );
}
Example #16
0
static gboolean
decompose_dialog (void)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *label;
  GtkWidget *combo;
  GtkWidget *toggle;
  gint       j;
  gint       extract_idx;
  gboolean   run;

  extract_idx = 0;
  for (j = 0; j < G_N_ELEMENTS (extract); j++)
    {
      if (extract[j].dialog &&
          g_ascii_strcasecmp (decovals.extract_type, extract[j].type) == 0)
        {
          extract_idx = j;
          break;
        }
    }

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Decompose"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_vbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  frame = gimp_frame_new (_("Extract Channels"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

  vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (frame), vbox);
  gtk_widget_show (vbox);

  hbox = gtk_hbox_new (FALSE, 6);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new_with_mnemonic (_("Color _model:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  combo = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);
  for (j = 0; j < G_N_ELEMENTS (extract); j++)
    {
      if (extract[j].dialog)
        {
          gchar *label = g_strdup (gettext (extract[j].type));
          gchar *l;

          for (l = label; *l; l++)
            if (*l == '-' || *l == '_')
              *l = ' ';

          gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (combo),
                                     GIMP_INT_STORE_LABEL, label,
                                     GIMP_INT_STORE_VALUE, j,
                                     -1);
          g_free (label);
        }
    }

  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
  gtk_widget_show (combo);

  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);

  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
                              extract_idx,
                              G_CALLBACK (gimp_int_combo_box_get_active),
                              &extract_idx);

  toggle = gtk_check_button_new_with_mnemonic (_("_Decompose to layers"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                decovals.as_layers);
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &decovals.as_layers);

  toggle =
    gtk_check_button_new_with_mnemonic (_("_Foreground as registration color"));
  gimp_help_set_help_data (toggle, _("Pixels in the foreground color will "
                                     "appear black in all output images.  "
                                     "This can be used for things like crop "
                                     "marks that have to show up on all "
                                     "channels."), PLUG_IN_PROC);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                decovals.use_registration);
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &decovals.use_registration);

  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  if (run)
    strncpy (decovals.extract_type, extract[extract_idx].type, sizeof decovals.extract_type - 1);

  return run;
}
static GObject *
gdict_source_dialog_constructor (GType                  type,
				 guint                  n_construct_properties,
				 GObjectConstructParam *construct_params)
{
  GObject *object;
  GdictSourceDialog *dialog;
  GtkWidget *vbox;
  GError *error = NULL;

  object = G_OBJECT_CLASS (gdict_source_dialog_parent_class)->constructor (type,
									   n_construct_properties,
									   construct_params);
  dialog = GDICT_SOURCE_DIALOG (object);

  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
  
  gtk_widget_push_composite_child ();

  /* get the UI from the GtkBuilder file */
  dialog->builder = gtk_builder_new ();
  gtk_builder_add_from_file (dialog->builder, GDICT_SOURCE_UI, &error);

  if (error) {
    g_critical ("Unable to load the user interface definition file: %s",
                error->message);
    g_error_free (error);
    g_assert_not_reached ();
  }
  
  /* the main widget */
  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                     GTK_WIDGET (gtk_builder_get_object (dialog->builder, "source_root")));

  /* the transport combo changes the UI by changing the visible widgets
   * bound to the transport's own options.
   */
  dialog->transport_combo = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "transport_combo"));
  g_signal_connect (dialog->transport_combo, "changed",
  		    G_CALLBACK (transport_combo_changed_cb),
  		    dialog);

  /* the help button is always visible */
  dialog->help_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
  					       GTK_STOCK_HELP,
					       GTK_RESPONSE_HELP);
  
  vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "db-vbox"));
  dialog->db_chooser = gdict_database_chooser_new ();
  gtk_box_pack_start (GTK_BOX (vbox), dialog->db_chooser, TRUE, TRUE, 0);
  gtk_widget_show (dialog->db_chooser);

  vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "strat-vbox"));
  dialog->strat_chooser = gdict_strategy_chooser_new ();
  gtk_box_pack_start (GTK_BOX (vbox), dialog->strat_chooser, TRUE, TRUE, 0);
  gtk_widget_show (dialog->strat_chooser);

  /* the UI changes depending on the action that the source dialog
   * should perform
   */
  switch (dialog->action)
    {
    case GDICT_SOURCE_DIALOG_VIEW:
      /* disable every editable widget */
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "name_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "description_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "hostname_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "port_entry")), FALSE);
      
      gtk_widget_set_sensitive (dialog->transport_combo, FALSE);

      /* we just allow closing the dialog */
      dialog->close_button  = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CLOSE,
      						     GTK_RESPONSE_CLOSE);
      break;
    case GDICT_SOURCE_DIALOG_CREATE:
      dialog->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CANCEL,
      						     GTK_RESPONSE_CANCEL);
      dialog->add_button    = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_ADD,
      						     GTK_RESPONSE_ACCEPT);
      /* the "add" button sensitivity is controlled by the transport_combo
       * since it's the only setting that makes a source usable.
       */
      gtk_widget_set_sensitive (dialog->add_button, FALSE);
      break;
    case GDICT_SOURCE_DIALOG_EDIT:
      dialog->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CANCEL,
      						     GTK_RESPONSE_CANCEL);
      dialog->close_button  = gtk_dialog_add_button (GTK_DIALOG (dialog),
		      	 			     GTK_STOCK_CLOSE,
						     GTK_RESPONSE_CLOSE);
      break;
    default:
      g_assert_not_reached ();
      break;
    }
  
  /* this will take care of updating the contents of the dialog
   * based on the action
   */
  update_dialog_ui (dialog);
  
  gtk_widget_pop_composite_child ();
  
  return object;
}
Example #18
0
static GtkWidget *
create_dialog (void)
{
  GtkWidget *notebook;
  GtkWidget *hbox;
  GtkWidget *preview_box;

  gimp_ui_init (PLUG_IN_BINARY, TRUE);

  dialog = gimp_dialog_new (_("GIMPressionist"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  g_signal_connect (dialog, "response",
                    G_CALLBACK (dialog_response),
                    NULL);
  g_signal_connect (dialog, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);

  preview_box = create_preview ();
  gtk_box_pack_start (GTK_BOX (hbox), preview_box, FALSE, FALSE, 0);
  gtk_widget_show (preview_box);

  notebook = gtk_notebook_new ();
  gtk_box_pack_start (GTK_BOX (hbox), notebook, TRUE, TRUE, 5);
  gtk_widget_show (notebook);

  create_presetpage (GTK_NOTEBOOK (notebook));
  create_paperpage (GTK_NOTEBOOK (notebook));
  create_brushpage (GTK_NOTEBOOK (notebook));
  create_orientationpage (GTK_NOTEBOOK (notebook));
  create_sizepage (GTK_NOTEBOOK (notebook));
  create_placementpage (GTK_NOTEBOOK (notebook));
  create_colorpage (GTK_NOTEBOOK (notebook));
  create_generalpage (GTK_NOTEBOOK (notebook));

  updatepreview (NULL, NULL);

  /*
   * This is to make sure the values from the pcvals will be reflected
   * in the GUI here. Otherwise they will be set to the defaults.
   * */
  restore_values ();

  gtk_widget_show (dialog);

  return dialog;
}
Example #19
0
static void real_view_format_dialog (windata_t *vwin, series_view *sview)
{
    struct view_toggler vt;
    GtkWidget *dlg, *vbox;
    GtkWidget *tmp, *hbox;
    GtkWidget *b1, *b2;
    GSList *group;
    int std;

    dlg = gretl_dialog_new(_("gretl: data format"), vwin->main,
			   GRETL_DLG_BLOCK);

    vbox = gtk_dialog_get_content_area(GTK_DIALOG(dlg));

    std = (sview->view == VIEW_STANDARD);

    vt.view = sview->view;
    vt.digits = sview->digits;
    vt.format = sview->format;
    vt.target_vwin = vwin;
    vt.sview = sview;

    hbox = gtk_hbox_new(FALSE, 5);
    tmp = gtk_label_new(_("Select data format"));
    gtk_box_pack_start(GTK_BOX(hbox), tmp, FALSE, FALSE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);

    /* standard format radio option */
    hbox = gtk_hbox_new(FALSE, 5);
    b1 = gtk_radio_button_new_with_label(NULL, _("Standard format"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b1), std);
    gtk_box_pack_start(GTK_BOX(hbox), b1, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);

    /* custom format radio option */
    hbox = gtk_hbox_new(FALSE, 5);
    group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(b1));
    b2 = gtk_radio_button_new_with_label(group, _("Show"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b2), !std);
    gtk_box_pack_start(GTK_BOX(hbox), b2, FALSE, FALSE, 5);

    /* with spinner for number of digits */
    vt.spin = gtk_spin_button_new_with_range(1, 15, 1);
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(vt.spin), sview->digits);
    g_signal_connect(G_OBJECT(vt.spin), "value-changed",
		     G_CALLBACK(series_view_set_digits), &vt.digits);
    gtk_widget_set_sensitive(vt.spin, !std);
    gtk_box_pack_start(GTK_BOX(hbox), vt.spin, FALSE, FALSE, 0);

    /* and selector for digits / decimal places */
    vt.combo = gtk_combo_box_text_new();
    combo_box_append_text(vt.combo, _("significant figures"));
    combo_box_append_text(vt.combo, _("decimal places"));
    if (sview->format == 'g') {
	gtk_combo_box_set_active(GTK_COMBO_BOX(vt.combo), 0);
    } else {
	gtk_combo_box_set_active(GTK_COMBO_BOX(vt.combo), 1);
    }
    g_signal_connect(G_OBJECT(GTK_COMBO_BOX(vt.combo)), "changed",
		     G_CALLBACK(series_view_set_fmt), &vt.format);
    gtk_widget_set_sensitive(vt.combo, !std);
    gtk_box_pack_start(GTK_BOX(hbox), vt.combo, FALSE, FALSE, 5);

    /* connect toggle signal */
    g_signal_connect(G_OBJECT(b1), "toggled",
                     G_CALLBACK(series_view_toggle_view), &vt);

    /* pack the custom line */
    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);

    hbox = gtk_dialog_get_action_area(GTK_DIALOG(dlg));

    /* Cancel button */
    cancel_delete_button(hbox, dlg);
   
    /* OK button */
    tmp = ok_button(hbox);
    g_signal_connect(G_OBJECT(tmp), "clicked",
		     G_CALLBACK(reformat_callback), &vt);
    g_signal_connect(G_OBJECT(tmp), "clicked",
		     G_CALLBACK(delete_widget), dlg);
    gtk_widget_grab_default(tmp);

    gtk_widget_show_all(dlg);
}
Example #20
0
/**
 * show_properties_dialog
 *
 * Description:
 * displays the properties dialog
 **/
void
show_properties_dialog (void)
{
  GtkWidget *notebook;
  GtkWidget *cpage;
  GtkWidget *gpage;
  GtkWidget *kpage;
  GtkWidget *label;
  GtkWidget *hbox;
  GtkWidget *vbox;
  GtkWidget *typemenu;
  GtkWidget *pmapmenu;
  GtkWidget *chkbox;
  GtkWidget *safe_chkbox;
  GtkWidget *grid;
  GtkWidget *dbut;
  GtkWidget *w;
  GtkWidget *controls_list;

  if (propbox)
    return;

  propbox = gtk_dialog_new_with_buttons (_("Preferences"),
					 GTK_WINDOW (window),
					 GTK_DIALOG_USE_HEADER_BAR,
					 NULL);
  gtk_container_set_border_width (GTK_CONTAINER (propbox), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))), 2);
  /* Set up notebook and add it to hbox of the gtk_dialog */
  g_signal_connect (G_OBJECT (propbox), "destroy",
		    G_CALLBACK (gtk_widget_destroyed), &propbox);

  notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))),
              notebook, TRUE, TRUE, 0);

  /* The configuration page */
  cpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
  gtk_container_set_border_width (GTK_CONTAINER (cpage), 12);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_box_pack_start (GTK_BOX (cpage), grid, FALSE, FALSE, 0);

  label = gtk_label_new (_("Game Type"));
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  typemenu = gtk_combo_box_text_new ();
  fill_typemenu (typemenu);
  gtk_grid_attach (GTK_GRID (grid), typemenu, 1, 0, 1, 1);

  g_signal_connect (G_OBJECT (typemenu), "changed",
		    G_CALLBACK (type_selection), NULL);

  chkbox = gtk_check_button_new_with_mnemonic (_("_Use safe moves"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox),
				properties.safe_moves);
  gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 1, 2, 1);
  gtk_widget_set_tooltip_text (chkbox,
                               _("Prevent accidental moves that result in getting killed."));
  safe_chkbox = chkbox;

  chkbox = gtk_check_button_new_with_mnemonic (_("U_se super safe moves"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox),
				properties.super_safe_moves);
  g_signal_connect (G_OBJECT (chkbox), "clicked",
		    (GCallback) super_safe_cb, NULL);
  gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 2, 2, 1);
  gtk_widget_set_tooltip_text (chkbox,
                               _("Prevents all moves that result in getting killed."));
  gtk_widget_set_sensitive (chkbox, properties.safe_moves);

  g_signal_connect (G_OBJECT (safe_chkbox), "clicked",
		    (GCallback) safe_cb, (gpointer) chkbox);

  chkbox = gtk_check_button_new_with_mnemonic (_("_Enable sounds"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.sound);
  g_signal_connect (G_OBJECT (chkbox), "clicked",
		    (GCallback) sound_cb, NULL);
  gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 3, 2, 1);
  gtk_widget_set_tooltip_text (chkbox,
                               _("Play sounds for events like winning a level and dying."));

  label = gtk_label_new_with_mnemonic (_("Game"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), cpage, label);


  /* The graphics page */
  gpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
  gtk_container_set_border_width (GTK_CONTAINER (gpage), 12);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_box_pack_start (GTK_BOX (gpage), grid, FALSE, FALSE, 0);

  label = gtk_label_new_with_mnemonic (_("_Image theme:"));
  gtk_widget_set_hexpand (label, TRUE);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  pmapmenu = make_theme_menu ();
  g_signal_connect (G_OBJECT (pmapmenu), "changed",
		    G_CALLBACK (pmap_selection), NULL);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), pmapmenu);

  gtk_grid_attach (GTK_GRID (grid), pmapmenu, 1, 0, 1, 1);

  label = gtk_label_new_with_mnemonic (_("_Background color:"));
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

  w = gtk_color_button_new ();
  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (w), &properties.bgcolour);
  g_signal_connect (G_OBJECT (w), "color_set",
		    G_CALLBACK (bg_color_callback), NULL);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), w);

  gtk_grid_attach (GTK_GRID (grid), w, 1, 1, 1, 1);

  label = gtk_label_new_with_mnemonic (_("Appearance"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), gpage, label);

  /* The keyboard page */
  kpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
  gtk_container_set_border_width (GTK_CONTAINER (kpage), 12);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_box_pack_start (GTK_BOX (kpage), vbox, TRUE, TRUE, 0);

  controls_list = games_controls_list_new (settings);
  games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list),
				    "key00", _("Key to move NW"), g_settings_get_default_value (settings, "key00"),
				    "key01", _("Key to move N"), g_settings_get_default_value (settings, "key01"),
				    "key02", _("Key to move NE"), g_settings_get_default_value (settings, "key02"),
				    "key03", _("Key to move W"), g_settings_get_default_value (settings, "key03"),
				    "key04", _("Key to hold"), g_settings_get_default_value (settings, "key04"),
				    "key05", _("Key to move E"), g_settings_get_default_value (settings, "key05"),
				    "key06", _("Key to move SW"), g_settings_get_default_value (settings, "key06"),
				    "key07", _("Key to move S"), g_settings_get_default_value (settings, "key07"),
				    "key08", _("Key to move SE"), g_settings_get_default_value (settings, "key08"),
                                    NULL);

  gtk_box_pack_start (GTK_BOX (vbox), controls_list, TRUE, TRUE, 0);

  hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  dbut = gtk_button_new_with_mnemonic (_("_Restore Defaults"));
  g_signal_connect (G_OBJECT (dbut), "clicked",
		    G_CALLBACK (defkey_cb), NULL);
  gtk_box_pack_start (GTK_BOX (hbox), dbut, FALSE, FALSE, 0);

  label = gtk_label_new_with_mnemonic (_("Keyboard"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), kpage, label);


  g_signal_connect (G_OBJECT (propbox), "delete_event",
		    G_CALLBACK (delete_cb), NULL);
  g_signal_connect (G_OBJECT (propbox), "response",
		    G_CALLBACK (apply_cb), NULL);

  gtk_widget_show_all (propbox);
}
Example #21
0
void configure_program_dialog(GtkWidget *widget, gpointer user_data) {

  /** Program configuration dailog window. **/

  #ifdef DEBUG
  DEBUG_FUNC_MARK
  #endif

  GtkWidget *configure_dialog = gtk_dialog_new() ;



  gtk_window_set_icon_from_file(GTK_WINDOW(configure_dialog), PATH_TO_PRG_WIN_ICON, NULL) ;
  gtk_window_set_title(GTK_WINDOW(configure_dialog), "Configure program") ;
  gtk_window_set_position(GTK_WINDOW(configure_dialog), GTK_WIN_POS_CENTER_ALWAYS) ;
  gtk_window_set_resizable(GTK_WINDOW(configure_dialog), FALSE);
  gtk_widget_set_size_request(configure_dialog,-1,-1) ;
  gtk_window_set_modal(GTK_WINDOW(configure_dialog), FALSE) ;
  gtk_window_set_destroy_with_parent(GTK_WINDOW(configure_dialog), TRUE) ;
  gtk_window_set_decorated(GTK_WINDOW(configure_dialog), TRUE) ;

  gtk_window_set_type_hint(GTK_WINDOW(configure_dialog), GDK_WINDOW_TYPE_HINT_NORMAL) ;
  gtk_window_set_transient_for(GTK_WINDOW(configure_dialog), GTK_WINDOW(gui->window)) ;

  gtk_container_set_border_width(GTK_CONTAINER(configure_dialog), 12) ;


  #define DIALOG_DEFAULT_SPACE 12


  /** ***** [START] Icon set choice [START] ***** **/

  GtkWidget *icon_set_choice_frame = gtk_frame_new(" Icon set ") ;


  GtkWidget *icon_set_choice_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(icon_set_choice_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_box_set_spacing(GTK_BOX(icon_set_choice_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_box_set_homogeneous(GTK_BOX(icon_set_choice_hbox), TRUE) ;


  GtkWidget *radiobutton_icons_high_contrast = gtk_radio_button_new_with_label(NULL, " HighContrast") ;

  GtkWidget *image_icons_high_contrast       ;

  GtkWidget *radiobutton_icons_oxygen        = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radiobutton_icons_high_contrast)), " Oxygen") ;

  GtkWidget *image_icons_oxygen              ;


  gtk_widget_set_tooltip_markup(radiobutton_icons_high_contrast, "Set the <b>HighContrast</b> theme icon set.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(radiobutton_icons_oxygen,        "Set the <b>Oxygen</b> theme icon set.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radiobutton_icons_high_contrast), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radiobutton_icons_oxygen),        FALSE) ;


  if (settings.icon_set_oxygen) {

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_icons_oxygen), TRUE) ;

    image_icons_high_contrast = gtk_image_new_from_file( PATH_TO_HIGH_CONTRAST_BUTTON_ICONS  "face-angry.png")     ;

    image_icons_oxygen        = gtk_image_new_from_file( PATH_TO_OXYGEN_BUTTON_ICONS         "face-smile-big.png") ;

  }
  else {

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_icons_high_contrast), TRUE) ;

    image_icons_high_contrast = gtk_image_new_from_file( PATH_TO_HIGH_CONTRAST_BUTTON_ICONS  "face-smile-big.png") ;

    image_icons_oxygen        = gtk_image_new_from_file( PATH_TO_OXYGEN_BUTTON_ICONS         "face-angry.png")     ;

  }


  gtk_button_set_image(GTK_BUTTON(radiobutton_icons_high_contrast), image_icons_high_contrast) ;

  gtk_button_set_always_show_image(GTK_BUTTON(radiobutton_icons_high_contrast), TRUE) ;

  gtk_button_set_image(GTK_BUTTON(radiobutton_icons_oxygen), image_icons_oxygen) ;

  gtk_button_set_always_show_image(GTK_BUTTON(radiobutton_icons_oxygen), TRUE)   ;





  gtk_box_pack_start(GTK_BOX(icon_set_choice_hbox), radiobutton_icons_high_contrast, TRUE,  TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(icon_set_choice_hbox), radiobutton_icons_oxygen,        TRUE,  TRUE, 0) ;

  gtk_container_add(GTK_CONTAINER(icon_set_choice_frame), icon_set_choice_hbox) ;

  /** ***** [END] Icon set choice [END] ***** **/



  /** ***** [START] Playing settings [START] ***** **/

  GtkWidget *playing_settings_frame = gtk_frame_new(" Player settings ") ;


  GtkWidget *playing_settings_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(playing_settings_vbox), DIALOG_DEFAULT_SPACE) ;



  GtkWidget *playing_settings_repeat_all = gtk_check_button_new_with_label(" Repeat all mode. ") ;

  gtk_widget_set_tooltip_markup(playing_settings_repeat_all, "Enable the <b>repeat all</b> feature.\nThis will update the player settings.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playing_settings_repeat_all), is_repeat_all) ;



  GtkWidget *playing_settings_shuffle = gtk_check_button_new_with_label(" Shuffle mode. ") ;

  gtk_widget_set_tooltip_markup(playing_settings_shuffle, "Enable the <b>shuffle</b> feature.\nThis will update the player settings.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playing_settings_shuffle), is_shuffle ) ;

  GtkWidget *playing_settings_volume_hbox  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;



  GtkWidget *playing_settings_volume_label_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  GtkWidget *playing_settings_volume_image      = gtk_image_new_from_file( (settings.path_to_button_icons + "audio-volume-medium.png").c_str() ) ;

  GtkWidget *playing_settings_volume_label      = gtk_label_new(" Default Volume:") ;

  gtk_box_pack_start(GTK_BOX(playing_settings_volume_label_hbox), playing_settings_volume_image, FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(playing_settings_volume_label_hbox), playing_settings_volume_label, FALSE, FALSE, 0) ;


  GtkWidget *playing_settings_volume_scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0) ;



  gtk_widget_set_tooltip_markup(playing_settings_volume_scale, "Set the <b>default player volume</b> at start.\nThis will <b>not</b> update the player settings.\nYou must press the <b>Apply</b> button to store your configuration.") ;

  gtk_range_set_value(GTK_RANGE(playing_settings_volume_scale), settings.volume) ;

  gtk_scale_set_draw_value(GTK_SCALE(playing_settings_volume_scale), TRUE) ;
  gtk_scale_set_has_origin(GTK_SCALE(playing_settings_volume_scale), TRUE) ;

  gtk_scale_set_value_pos(GTK_SCALE(playing_settings_volume_scale), GTK_POS_TOP) ;

  gtk_scale_add_mark(GTK_SCALE(playing_settings_volume_scale), 50.0, GTK_POS_TOP, NULL) ;



  gtk_box_pack_start(GTK_BOX(playing_settings_volume_hbox), playing_settings_volume_label_hbox, FALSE,  FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(playing_settings_volume_hbox), playing_settings_volume_scale,      TRUE,   TRUE,  0) ;



  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_repeat_all,               FALSE, FALSE, 0)   ;
  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_shuffle,                  FALSE, FALSE, 0)   ;
  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_volume_hbox,              FALSE, FALSE, 0)   ;

  gtk_container_add(GTK_CONTAINER(playing_settings_frame), playing_settings_vbox) ;

  /** ***** [END] Playing settings [END] ***** **/



  /** ***** [START] Interface size setting [START] ***** **/

  GtkWidget *interface_size_frame = gtk_frame_new(" Interface size ") ;

  GtkWidget *interface_size_hbox  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(interface_size_hbox), DIALOG_DEFAULT_SPACE) ;

  GtkWidget *interface_size_radiobutton_little = gtk_radio_button_new_with_label(NULL, " Little") ;
  GtkWidget *interface_size_radiobutton_middle = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(interface_size_radiobutton_little)), " Medium") ;
  GtkWidget *interface_size_radiobutton_big    = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(interface_size_radiobutton_little)), "  Big  ") ;

  GtkWidget *interface_size_little_image       = gtk_image_new_from_file((settings.path_to_button_icons + "interface-little.png").c_str() ) ;
  GtkWidget *interface_size_middle_image       = gtk_image_new_from_file((settings.path_to_button_icons + "interface-middle.png").c_str() ) ;
  GtkWidget *interface_size_big_image          = gtk_image_new_from_file((settings.path_to_button_icons + "interface-big.png").c_str()    ) ;

  gtk_widget_set_tooltip_markup(interface_size_radiobutton_little, "Set the <b>interface size</b> on <b>little</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(interface_size_radiobutton_middle, "Set the <b>interface size</b> on <b>middle</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(interface_size_radiobutton_big,    "Set the <b>interface size</b> on <b>big</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.")    ;

  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_little), interface_size_little_image) ;
  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_middle), interface_size_middle_image) ;
  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_big),    interface_size_big_image   ) ;

  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_little), TRUE) ;
  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_middle), TRUE) ;
  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_big),    TRUE) ;

  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_little), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_middle), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_big),    FALSE) ;


  switch (settings.image_resized_size) {

    case IMAGE_RESIZED_SIZE_LITTLE :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_little), TRUE) ;
      break ;

    case IMAGE_RESIZED_SIZE_MIDDLE :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_middle), TRUE) ;
      break ;

    case IMAGE_RESIZED_SIZE_BIG :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_big),    TRUE) ;
      break ;

    default :
      break ;
  }


  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_little, TRUE, TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_middle, TRUE, TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_big,    TRUE, TRUE, 0) ;

  gtk_box_set_homogeneous(GTK_BOX(interface_size_hbox), TRUE) ;

  gtk_box_set_spacing(GTK_BOX(interface_size_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_container_add(GTK_CONTAINER(interface_size_frame), interface_size_hbox) ;

  /** ***** [END] Interface size setting [END] ***** **/



  /** ***** [START] Music folder setting [START] ***** **/

  GtkWidget *folder_selecting_frame = gtk_frame_new(" Music folder ") ;

  GtkWidget *folder_selecting_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(folder_selecting_box), DIALOG_DEFAULT_SPACE) ;


  GtkWidget *folder_selecting_button = gtk_file_chooser_button_new("Set the Music folder to open per default.", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ;

  gtk_widget_set_tooltip_markup(folder_selecting_button, "Set the folder to open per default: your <b>default music folder</b>.\n<i>The default folder from the folder selector</i>.\nSet it simply to your <b>Music folder</b>.\nChanges are immediatly applied.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_file_chooser_button_set_title(GTK_FILE_CHOOSER_BUTTON(folder_selecting_button), "Set the Music folder to open per default.") ;

  const char *user_music_folder = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC) ;

  gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(folder_selecting_button), (g_file_test(settings.path_to_music_folder.c_str(), G_FILE_TEST_IS_DIR)) ? settings.path_to_music_folder.c_str() : (user_music_folder != NULL) ? user_music_folder : g_get_home_dir()  ) ;


  gtk_box_pack_start(GTK_BOX(folder_selecting_box), folder_selecting_button,  TRUE, TRUE, 0)   ;

  gtk_container_add(GTK_CONTAINER(folder_selecting_frame), folder_selecting_box) ;

  /** ***** [END] Music folder setting [END] ***** **/



  /** ***** [START] Dialog main content box [START] ***** **/

  GtkWidget *content_area = gtk_dialog_get_content_area( GTK_DIALOG(configure_dialog) ) ;

  gtk_box_pack_start(GTK_BOX(content_area), icon_set_choice_frame,  FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), playing_settings_frame, FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), interface_size_frame,   FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), folder_selecting_frame, FALSE, FALSE, 0) ;

  gtk_box_set_spacing(GTK_BOX(content_area), DIALOG_DEFAULT_SPACE) ;

  /** ***** [END] Dialog main content box [END] ***** **/



  /** ***** [START] Dialog action buttons [START] ***** **/

  GtkWidget *button_close = gtk_button_new_with_label("Close") ; // gtk_dialog_add_button(GTK_DIALOG(configure_dialog), "Cancel", GTK_RESPONSE_CANCEL) ;

  GtkWidget *image_close  = gtk_image_new_from_file((settings.path_to_button_icons + "dialog-close.png").c_str()) ;

  gtk_widget_set_tooltip_markup(button_close, "<b>Close</b> the configuration window and don't store any setting.") ;

  gtk_button_set_image(GTK_BUTTON(button_close), image_close) ;

  gtk_button_set_always_show_image(GTK_BUTTON(button_close), TRUE) ;


  GtkWidget *button_ok = gtk_button_new_with_label("Apply") ; // gtk_dialog_add_button(GTK_DIALOG(configure_dialog), "Apply", GTK_RESPONSE_APPLY) ;

  GtkWidget *image_ok  = gtk_image_new_from_file((settings.path_to_button_icons + "dialog-ok.png").c_str()) ;

  gtk_widget_set_tooltip_markup(button_ok, "<b>Register</b> all the settings as <i>your default configuration</i> at start.") ;

  gtk_button_set_image(GTK_BUTTON(button_ok), image_ok) ;

  gtk_button_set_always_show_image(GTK_BUTTON(button_ok), TRUE) ;


  gtk_dialog_add_action_widget(GTK_DIALOG(configure_dialog), button_close, GTK_RESPONSE_CLOSE) ;

  gtk_dialog_add_action_widget(GTK_DIALOG(configure_dialog), button_ok,     GTK_RESPONSE_APPLY)  ;

  GtkWidget *action_area = gtk_dialog_get_action_area(GTK_DIALOG(configure_dialog)) ;

  gtk_container_set_border_width(GTK_CONTAINER(action_area), 0) ;

  gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area), GTK_BUTTONBOX_EDGE) ;

  /** ***** [END] Dialog action buttons [END] ***** **/



  Radio_Config high_contrast_radiobutton ;

  high_contrast_radiobutton.button  = radiobutton_icons_high_contrast ;
  high_contrast_radiobutton.image   = image_icons_high_contrast       ;

  high_contrast_radiobutton.volume  = playing_settings_volume_image       ;
  high_contrast_radiobutton.cancel  = image_close    ;
  high_contrast_radiobutton.apply   = image_ok       ;

  high_contrast_radiobutton.little  = interface_size_little_image ;
  high_contrast_radiobutton.middle  = interface_size_middle_image ;
  high_contrast_radiobutton.big     = interface_size_big_image    ;


  Radio_Config oxygen_radiobutton ;

  oxygen_radiobutton.button  = radiobutton_icons_oxygen ;
  oxygen_radiobutton.image   = image_icons_oxygen       ;

  oxygen_radiobutton.volume  = playing_settings_volume_image       ;
  oxygen_radiobutton.cancel  = image_close    ;
  oxygen_radiobutton.apply   = image_ok       ;

  oxygen_radiobutton.little  = interface_size_little_image ;
  oxygen_radiobutton.middle  = interface_size_middle_image ;
  oxygen_radiobutton.big     = interface_size_big_image    ;

  g_signal_connect(G_OBJECT(radiobutton_icons_high_contrast), "clicked", G_CALLBACK(configure_high_contrast_radiobutton), &high_contrast_radiobutton) ;
  g_signal_connect(G_OBJECT(radiobutton_icons_oxygen),        "clicked", G_CALLBACK(configure_oxygen_radiobutton),        &oxygen_radiobutton       ) ;


  int little = -1 ;
  int middle =  0 ;
  int big    =  1 ;

  g_signal_connect(G_OBJECT(interface_size_radiobutton_little), "clicked",       G_CALLBACK(reconfigure_interface_size), &little) ;
  g_signal_connect(G_OBJECT(interface_size_radiobutton_middle), "clicked",       G_CALLBACK(reconfigure_interface_size), &middle) ;
  g_signal_connect(G_OBJECT(interface_size_radiobutton_big),    "clicked",       G_CALLBACK(reconfigure_interface_size), &big)    ;


  g_signal_connect(G_OBJECT(playing_settings_repeat_all),       "toggled",       G_CALLBACK(repeat_all_feature_set),     NULL)    ;
  g_signal_connect(G_OBJECT(playing_settings_shuffle),          "toggled",       G_CALLBACK(shuffle_feature_set),        NULL)    ;
  g_signal_connect(G_OBJECT(playing_settings_volume_scale),     "value-changed", G_CALLBACK(get_volume),                 NULL)    ;
  g_signal_connect(G_OBJECT(folder_selecting_button),           "file-set",      G_CALLBACK(set_default_folder),         NULL)    ;


  gtk_widget_show_all(configure_dialog) ;



  int response = gtk_dialog_run(GTK_DIALOG(configure_dialog))  ;

  switch (response) {

    case GTK_RESPONSE_APPLY :

      {

        GKeyFile *conf_file = g_key_file_new() ;

        GError *error = NULL ;

        settings.is_repeat_all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(playing_settings_repeat_all)) ;

        settings.is_shuffle       = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(playing_settings_shuffle))    ;



        // Set configuration settings to configuration file buffer.
        g_key_file_set_string(conf_file,   "Config",  "Buttons_Icons_Path",   settings.path_to_button_icons.c_str()) ;

        g_key_file_set_string(conf_file,   "Config",  "Menu_Icons_Path",      settings.path_to_menu_icons.c_str())   ;

        g_key_file_set_string(conf_file,   "Config",  "Music_Folder",         settings.path_to_music_folder.c_str())   ;

        g_key_file_set_boolean(conf_file,  "Config",  "Is_Oxygen",            settings.icon_set_oxygen) ;
        g_key_file_set_boolean(conf_file,  "Config",  "Repeat_all",           settings.is_repeat_all)  ;
        g_key_file_set_boolean(conf_file,  "Config",  "Shuffle",              settings.is_shuffle) ;

        g_key_file_set_double(conf_file,   "Config",  "Volume",               settings.volume) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Buttons_space",        settings.space_buttons) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Display_Size",         settings.display_size) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Image_Resizing",       settings.image_resized_size) ;

        g_key_file_set_string(conf_file,   "Config",  "Sized_Default_Image",  settings.path_to_default_image.c_str())   ;

        // Write to configuration file
        g_key_file_save_to_file(conf_file, PATH_TO_CONF_FILE, &error);

        // Setting global variables.
        cover_image    = settings.path_to_default_image ;
        current_folder = settings.path_to_music_folder ;

        if ( error != NULL ) {

          display_message_dialog("Error store configuration !", "Cannot store the configuration.") ;

          #ifdef DEBUG
          fprintf(stdout,"\n%s: Error store configuratiom settings.\n", prgname.c_str() )    ; fflush(stdout) ;
          #endif
        }
        else { // Success
          #ifdef DEBUG
          fprintf(stdout,"\n%s: Success store configuratiom settings.\n", prgname.c_str() )  ;
          #endif
        }

      }

      break ;

    case GTK_RESPONSE_CLOSE :
      // Do nothing.
      break ;
  }

  gtk_widget_destroy(configure_dialog) ;

  return ;

}
Example #22
0
static void
do_simple_message_box(ESD_TYPE_E type, gboolean *notagain,
                      const char *secondary_msg, const char *msg_format,
                      va_list ap)
{
  GtkMessageType  gtk_message_type;
  GString        *message = g_string_new("");
  GtkWidget      *msg_dialog;
  GtkWidget      *checkbox = NULL;

  if (notagain != NULL) {
    if (*notagain) {
      /*
       * The user had checked the "Don't show this message again" checkbox
       * in the past; don't bother showing it.
       */
      return;
    }
  }

  switch (type) {

  case ESD_TYPE_INFO:
    gtk_message_type = GTK_MESSAGE_INFO;
    break;

  case ESD_TYPE_WARN:
    gtk_message_type = GTK_MESSAGE_WARNING;
    break;

  case ESD_TYPE_ERROR:
    gtk_message_type = GTK_MESSAGE_ERROR;
    break;

  default:
    g_assert_not_reached();
    gtk_message_type = GTK_MESSAGE_INFO;
    break;
  }

  /* Format the message. */
  g_string_vprintf(message, msg_format, ap);

  if (g_utf8_strlen(message->str, message->len) > MAX_MESSAGE_LEN) {
    const gchar *end = message->str + MAX_MESSAGE_LEN;
    g_utf8_validate(message->str, MAX_MESSAGE_LEN, &end);
    g_string_truncate(message, end - message->str);
    g_string_append(message, UTF8_HORIZONTAL_ELLIPSIS);
  }

  msg_dialog = gtk_message_dialog_new(GTK_WINDOW(top_level),
                                      (GtkDialogFlags)(GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
                                      gtk_message_type,
                                      GTK_BUTTONS_OK,
                                      "%s", message->str);

  if (secondary_msg != NULL) {
    g_string_overwrite(message, 0, secondary_msg);
    if (g_utf8_strlen(message->str, message->len) > MAX_SECONDARY_MESSAGE_LEN) {
      const gchar *end = message->str + MAX_SECONDARY_MESSAGE_LEN;
      g_utf8_validate(message->str, MAX_SECONDARY_MESSAGE_LEN, &end);
      g_string_truncate(message, end - message->str);
      g_string_append(message, UTF8_HORIZONTAL_ELLIPSIS);
    }
    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog),
                                             "%s", message->str);
  }

  g_string_free(message, TRUE);

  if (notagain != NULL) {
    checkbox = gtk_check_button_new_with_label("Don't show this message again.");
    gtk_container_set_border_width(GTK_CONTAINER(checkbox), 12);
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(msg_dialog))),
                       checkbox, TRUE, TRUE, 0);
    gtk_widget_show(checkbox);
  }

  gtk_dialog_run(GTK_DIALOG(msg_dialog));
  if (notagain != NULL) {
    /*
     * OK, did they check the checkbox?
     */
    *notagain = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox));
  }
  gtk_widget_destroy(msg_dialog);
}
Example #23
0
void pw_col_choose (void)
{
    if (window)
    {
        gtk_window_present ((GtkWindow *) window);
        return;
    }

    chosen = index_new ();
    avail = index_new ();

    gboolean added[PW_COLS];
    memset (added, 0, sizeof added);

    for (gint i = 0; i < pw_num_cols; i ++)
    {
        if (added[pw_cols[i]])
            continue;
        added[pw_cols[i]] = TRUE;
        Column * column = g_slice_new (Column);
        column->column = pw_cols[i];
        column->selected = 0;
        index_append (chosen, column);
    }

    for (gint i = 0; i < PW_COLS; i ++)
    {
        if (added[i])
            continue;
        Column * column = g_slice_new (Column);
        column->column = i;
        column->selected = 0;
        index_append (avail, column);
    }

    window = gtk_dialog_new_with_buttons (_("Choose Columns"), NULL, 0,
     GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
     NULL);
    gtk_window_set_default_size ((GtkWindow *) window, 400, 300);
    gtk_dialog_set_default_response ((GtkDialog *) window, GTK_RESPONSE_ACCEPT);

    g_signal_connect (window, "response", (GCallback) response_cb, NULL);
    g_signal_connect (window, "destroy", (GCallback) destroy_cb, NULL);

    GtkWidget * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start ((GtkBox *) gtk_dialog_get_content_area ((GtkDialog *)
     window), hbox, TRUE, TRUE, 0);

    GtkWidget * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, TRUE, TRUE, 0);

    GtkWidget * label = gtk_label_new (_("Available:"));
    g_object_set ((GObject *) label, "xalign", (gfloat) 0, NULL);
    gtk_box_pack_start ((GtkBox *) vbox, label, FALSE, FALSE, 0);

    GtkWidget * scroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy ((GtkScrolledWindow *) scroll,
     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) scroll,
     GTK_SHADOW_IN);
    gtk_box_pack_start ((GtkBox *) vbox, scroll, TRUE, TRUE, 0);

    avail_list = audgui_list_new (& callbacks, avail, index_count (avail));
    gtk_tree_view_set_headers_visible ((GtkTreeView *) avail_list, FALSE);
    audgui_list_add_column (avail_list, NULL, 0, G_TYPE_STRING, -1);
    gtk_container_add ((GtkContainer *) scroll, avail_list);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, FALSE, FALSE, 0);

    GtkWidget * button = gtk_button_new ();
    gtk_container_add ((GtkContainer *) button, gtk_image_new_from_stock
     (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start ((GtkBox *) vbox, button, TRUE, FALSE, 0);
    g_signal_connect_swapped (button, "clicked", (GCallback) transfer, avail);

    button = gtk_button_new ();
    gtk_container_add ((GtkContainer *) button, gtk_image_new_from_stock
     (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start ((GtkBox *) vbox, button, TRUE, FALSE, 0);
    g_signal_connect_swapped (button, "clicked", (GCallback) transfer, chosen);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, TRUE, TRUE, 0);

    label = gtk_label_new (_("Chosen:"));
    g_object_set ((GObject *) label, "xalign", (gfloat) 0, NULL);
    gtk_box_pack_start ((GtkBox *) vbox, label, FALSE, FALSE, 0);

    scroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy ((GtkScrolledWindow *) scroll,
     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) scroll,
     GTK_SHADOW_IN);
    gtk_box_pack_start ((GtkBox *) vbox, scroll, TRUE, TRUE, 0);

    chosen_list = audgui_list_new (& callbacks, chosen, index_count (chosen));
    gtk_tree_view_set_headers_visible ((GtkTreeView *) chosen_list, FALSE);
    audgui_list_add_column (chosen_list, NULL, 0, G_TYPE_STRING, -1);
    gtk_container_add ((GtkContainer *) scroll, chosen_list);

    gtk_widget_show_all (window);
}
static void _camera_import_dialog_new(_camera_import_dialog_t *data)
{
  data->dialog = gtk_dialog_new_with_buttons(_("import images from camera"), NULL, GTK_DIALOG_MODAL,
                                             _("cancel"), GTK_RESPONSE_NONE, C_("camera import", "import"),
                                             GTK_RESPONSE_ACCEPT, NULL);
  gtk_window_set_default_size(GTK_WINDOW(data->dialog), 100, 600);
  GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(data->dialog));

  // List - setup store
  data->store = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);

  // IMPORT PAGE
  data->import.page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_set_border_width(GTK_CONTAINER(data->import.page), 5);

  // Top info
  data->import.info = gtk_label_new(_("please wait while prefetching thumbnails of images from camera..."));
  gtk_label_set_single_line_mode(GTK_LABEL(data->import.info), FALSE);
  gtk_widget_set_halign(data->import.info, GTK_ALIGN_START);
  gtk_box_pack_start(GTK_BOX(data->import.page), data->import.info, FALSE, FALSE, 0);

  // jobcode
  data->import.jobname
      = _camera_import_gconf_widget(data, _("jobcode"), "plugins/capture/camera/import/jobcode");
  gtk_box_pack_start(GTK_BOX(data->import.page), GTK_WIDGET(data->import.jobname->widget), FALSE, FALSE, 0);


  // Create the treview with list model data store
  data->import.treeview = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(data->import.treeview), GTK_POLICY_NEVER,
                                 GTK_POLICY_ALWAYS);

  gtk_container_add(GTK_CONTAINER(data->import.treeview), gtk_tree_view_new());
  GtkTreeView *treeview = GTK_TREE_VIEW(gtk_bin_get_child(GTK_BIN(data->import.treeview)));

  GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
  GtkTreeViewColumn *column
      = gtk_tree_view_column_new_with_attributes(_("thumbnail"), renderer, "pixbuf", 0, (char *)NULL);
  gtk_tree_view_append_column(treeview, column);

  renderer = gtk_cell_renderer_text_new();
  column = gtk_tree_view_column_new_with_attributes(_("storage file"), renderer, "text", 1, (char *)NULL);
  gtk_tree_view_append_column(treeview, column);
  gtk_tree_view_column_set_expand(column, TRUE);


  GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
  gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

  gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(data->store));
  gtk_tree_view_set_headers_visible(treeview, FALSE);

  gtk_box_pack_start(GTK_BOX(data->import.page), data->import.treeview, TRUE, TRUE, 0);


  // SETTINGS PAGE
  data->settings.page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_set_border_width(GTK_CONTAINER(data->settings.page), 5);

  // general settings
  gtk_box_pack_start(GTK_BOX(data->settings.page), gtk_label_new(_("general")), FALSE, FALSE, 0);

  // ignoring of jpegs. hack while we don't handle raw+jpeg in the same directories.
  data->settings.general.ignore_jpeg = gtk_check_button_new_with_label(_("ignore JPEG files"));
  g_object_set(data->settings.general.ignore_jpeg, "tooltip-text",
               _("do not load files with an extension of .jpg or .jpeg. this can be useful when there are "
                 "raw+JPEG in a directory."),
               NULL);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->settings.general.ignore_jpeg),
                               dt_conf_get_bool("ui_last/import_ignore_jpegs"));
  gtk_box_pack_start(GTK_BOX(data->settings.page), data->settings.general.ignore_jpeg, FALSE, FALSE, 0);
  g_signal_connect(G_OBJECT(data->settings.general.ignore_jpeg), "clicked",
                   G_CALLBACK(_check_button_callback), data);

  GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  data->settings.general.date_override = gtk_check_button_new_with_label(_("override today's date"));
  gtk_box_pack_start(GTK_BOX(hbox), data->settings.general.date_override, FALSE, FALSE, 0);
  g_object_set(data->settings.general.date_override, "tooltip-text",
               _("check this, if you want to override the timestamp used when expanding variables:\n$(YEAR), "
                 "$(MONTH), $(DAY),\n$(HOUR), $(MINUTE), $(SECONDS)"),
               (char *)NULL);

  data->settings.general.date_entry = gtk_entry_new();
  gtk_widget_set_sensitive(data->settings.general.date_entry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
                                                                  data->settings.general.date_override)));
  gtk_box_pack_start(GTK_BOX(hbox), data->settings.general.date_entry, TRUE, TRUE, 0);

  g_signal_connect(G_OBJECT(data->settings.general.date_override), "clicked",
                   G_CALLBACK(_check_button_callback), data);

  gtk_box_pack_start(GTK_BOX(data->settings.page), hbox, FALSE, FALSE, 0);


  // THE NOTEBOOK
  data->notebook = gtk_notebook_new();
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook), data->import.page, gtk_label_new(_("images")));
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook), data->settings.page, gtk_label_new(_("settings")));

  // end
  gtk_box_pack_start(GTK_BOX(content), data->notebook, TRUE, TRUE, 0);
  // gtk_widget_set_size_request(content, DT_PIXEL_APPLY_DPI(400), DT_PIXEL_APPLY_DPI(400));
}
Example #25
0
GtkWidget*
create_converterdlg (void)
{
  GtkWidget *converterdlg;
  GtkWidget *dialog_vbox6;
  GtkWidget *hbox105;
  GtkWidget *vbox26;
  GtkWidget *hbox67;
  GtkWidget *label103;
  GtkWidget *hbox68;
  GtkWidget *output_folder;
  GtkWidget *converter_output_browse;
  GtkWidget *write_to_source_folder;
  GtkWidget *preserve_folders;
  GtkWidget *bypass_same_format;
  GtkWidget *retag_after_copy;
  GtkWidget *hbox100;
  GtkWidget *label122;
  GtkWidget *hbox101;
  GtkWidget *output_file;
  GtkWidget *custom6;
  GtkWidget *hbox69;
  GtkWidget *label104;
  GtkWidget *hbox90;
  GtkWidget *encoder;
  GtkWidget *edit_encoder_presets;
  GtkWidget *image469;
  GtkWidget *hbox86;
  GtkWidget *label114;
  GtkWidget *hbox91;
  GtkWidget *dsp_preset;
  GtkWidget *edit_dsp_presets;
  GtkWidget *image470;
  GtkWidget *hbox88;
  GtkWidget *label116;
  GObject *numthreads_adj;
  GtkWidget *numthreads;
  GtkWidget *hbox89;
  GtkWidget *label117;
  GtkWidget *output_format;
  GtkWidget *hbox99;
  GtkWidget *label121;
  GtkWidget *overwrite_action;
  GtkWidget *scrolledwindow9;
  GtkWidget *preview_tree;
  GtkWidget *dialog_action_area5;
  GtkWidget *converter_cancel;
  GtkWidget *converter_ok;

  converterdlg = gtk_dialog_new ();
  gtk_widget_set_size_request (converterdlg, 720, -1);
  gtk_window_set_title (GTK_WINDOW (converterdlg), "Converter");
  gtk_window_set_position (GTK_WINDOW (converterdlg), GTK_WIN_POS_MOUSE);
  gtk_window_set_modal (GTK_WINDOW (converterdlg), TRUE);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (converterdlg), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (converterdlg), GDK_WINDOW_TYPE_HINT_DIALOG);
  gtk_dialog_set_has_separator (GTK_DIALOG (converterdlg), FALSE);

  dialog_vbox6 = gtk_dialog_get_content_area (GTK_DIALOG (converterdlg));
  gtk_widget_show (dialog_vbox6);

  hbox105 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox105);
  gtk_box_pack_start (GTK_BOX (dialog_vbox6), hbox105, TRUE, TRUE, 0);

  vbox26 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox26);
  gtk_box_pack_start (GTK_BOX (hbox105), vbox26, FALSE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox26), 12);

  hbox67 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox67);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox67, FALSE, TRUE, 0);

  label103 = gtk_label_new (_("Output folder:"));
  gtk_widget_show (label103);
  gtk_box_pack_start (GTK_BOX (hbox67), label103, FALSE, FALSE, 0);

  hbox68 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox68);
  gtk_box_pack_start (GTK_BOX (hbox67), hbox68, TRUE, TRUE, 0);

  output_folder = gtk_entry_new ();
  gtk_widget_show (output_folder);
  gtk_box_pack_start (GTK_BOX (hbox68), output_folder, TRUE, TRUE, 0);
  gtk_entry_set_invisible_char (GTK_ENTRY (output_folder), 9679);

  converter_output_browse = gtk_button_new_with_mnemonic ("...");
  gtk_widget_show (converter_output_browse);
  gtk_box_pack_start (GTK_BOX (hbox68), converter_output_browse, FALSE, FALSE, 0);

  write_to_source_folder = gtk_check_button_new_with_mnemonic (_("Write to source track folder"));
  gtk_widget_show (write_to_source_folder);
  gtk_box_pack_start (GTK_BOX (vbox26), write_to_source_folder, FALSE, FALSE, 0);

  preserve_folders = gtk_check_button_new_with_mnemonic (_("Preserve folder structure"));
  gtk_widget_show (preserve_folders);
  gtk_box_pack_start (GTK_BOX (vbox26), preserve_folders, FALSE, FALSE, 0);

  bypass_same_format = gtk_check_button_new_with_mnemonic (_("Copy if the format is not changing"));
  gtk_widget_show (bypass_same_format);
  gtk_box_pack_start (GTK_BOX (vbox26), bypass_same_format, FALSE, FALSE, 0);

  retag_after_copy = gtk_check_button_new_with_mnemonic (_("Re-tag after copy"));
  gtk_widget_show (retag_after_copy);
  gtk_box_pack_start (GTK_BOX (vbox26), retag_after_copy, FALSE, FALSE, 0);

  hbox100 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox100);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox100, FALSE, TRUE, 0);

  label122 = gtk_label_new (_("Output file name:"));
  gtk_widget_show (label122);
  gtk_box_pack_start (GTK_BOX (hbox100), label122, FALSE, FALSE, 0);

  hbox101 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox101);
  gtk_box_pack_start (GTK_BOX (hbox100), hbox101, TRUE, TRUE, 0);

  output_file = gtk_entry_new ();
  gtk_widget_show (output_file);
  gtk_box_pack_start (GTK_BOX (hbox101), output_file, TRUE, TRUE, 0);
  gtk_widget_set_tooltip_text (output_file, _("Extension (e.g. .mp3) will be appended automatically.\nLeave the field empty for default (%artist% - %title%)."));
  gtk_entry_set_invisible_char (GTK_ENTRY (output_file), 8226);

  custom6 = title_formatting_help_link_create ("custom6", "", "", 0, 0);
  gtk_widget_show (custom6);
  gtk_box_pack_start (GTK_BOX (hbox101), custom6, TRUE, TRUE, 0);
  gtk_widget_set_can_focus(custom6, FALSE);
  gtk_widget_set_can_default(custom6, FALSE);

  hbox69 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox69);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox69, FALSE, TRUE, 0);

  label104 = gtk_label_new (_("Encoder:"));
  gtk_widget_show (label104);
  gtk_box_pack_start (GTK_BOX (hbox69), label104, FALSE, FALSE, 0);

  hbox90 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox90);
  gtk_box_pack_start (GTK_BOX (hbox69), hbox90, TRUE, TRUE, 0);

  encoder = gtk_combo_box_text_new ();
  gtk_widget_show (encoder);
  gtk_box_pack_start (GTK_BOX (hbox90), encoder, TRUE, TRUE, 0);

  edit_encoder_presets = gtk_button_new ();
  gtk_widget_show (edit_encoder_presets);
  gtk_box_pack_start (GTK_BOX (hbox90), edit_encoder_presets, FALSE, FALSE, 0);

  image469 = gtk_image_new_from_stock ("gtk-edit", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image469);
  gtk_container_add (GTK_CONTAINER (edit_encoder_presets), image469);

  hbox86 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox86);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox86, FALSE, TRUE, 0);

  label114 = gtk_label_new (_("DSP preset:"));
  gtk_widget_show (label114);
  gtk_box_pack_start (GTK_BOX (hbox86), label114, FALSE, FALSE, 0);

  hbox91 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox91);
  gtk_box_pack_start (GTK_BOX (hbox86), hbox91, TRUE, TRUE, 0);

  dsp_preset = gtk_combo_box_text_new ();
  gtk_widget_show (dsp_preset);
  gtk_box_pack_start (GTK_BOX (hbox91), dsp_preset, TRUE, TRUE, 0);

  edit_dsp_presets = gtk_button_new ();
  gtk_widget_show (edit_dsp_presets);
  gtk_box_pack_start (GTK_BOX (hbox91), edit_dsp_presets, FALSE, FALSE, 0);

  image470 = gtk_image_new_from_stock ("gtk-edit", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image470);
  gtk_container_add (GTK_CONTAINER (edit_dsp_presets), image470);

  hbox88 = gtk_hbox_new (FALSE, 8);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox88, FALSE, TRUE, 0);

  label116 = gtk_label_new (_("Number of threads:"));
  gtk_widget_show (label116);
  gtk_box_pack_start (GTK_BOX (hbox88), label116, FALSE, FALSE, 0);

  numthreads_adj = G_OBJECT(gtk_adjustment_new (1, 0, 100, 1, 10, 0));
  numthreads = gtk_spin_button_new (GTK_ADJUSTMENT (numthreads_adj), 1, 0);
  gtk_widget_show (numthreads);
  gtk_box_pack_start (GTK_BOX (hbox88), numthreads, TRUE, TRUE, 0);

  hbox89 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox89);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox89, FALSE, TRUE, 0);

  label117 = gtk_label_new (_("Output sample format:"));
  gtk_widget_show (label117);
  gtk_box_pack_start (GTK_BOX (hbox89), label117, FALSE, FALSE, 0);

  output_format = gtk_combo_box_text_new ();
  gtk_widget_show (output_format);
  gtk_box_pack_start (GTK_BOX (hbox89), output_format, TRUE, TRUE, 0);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (output_format), _("Keep source format"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (output_format), _("8 bit signed int"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (output_format), _("16 bit signed int"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (output_format), _("24 bit signed int"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (output_format), _("32 bit signed int"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (output_format), _("32 bit float"));

  hbox99 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox99);
  gtk_box_pack_start (GTK_BOX (vbox26), hbox99, FALSE, TRUE, 0);

  label121 = gtk_label_new (_("When file exists:"));
  gtk_widget_show (label121);
  gtk_box_pack_start (GTK_BOX (hbox99), label121, FALSE, FALSE, 0);

  overwrite_action = gtk_combo_box_text_new ();
  gtk_widget_show (overwrite_action);
  gtk_box_pack_start (GTK_BOX (hbox99), overwrite_action, TRUE, TRUE, 0);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (overwrite_action), _("Skip"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (overwrite_action), _("Prompt"));
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (overwrite_action), _("Overwrite"));

  scrolledwindow9 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow9);
  gtk_box_pack_start (GTK_BOX (hbox105), scrolledwindow9, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow9), 12);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_SHADOW_IN);

  preview_tree = gtk_tree_view_new ();
  gtk_widget_show (preview_tree);
  gtk_container_add (GTK_CONTAINER (scrolledwindow9), preview_tree);
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (preview_tree), TRUE);

  dialog_action_area5 = gtk_dialog_get_action_area (GTK_DIALOG (converterdlg));
  gtk_widget_show (dialog_action_area5);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area5), GTK_BUTTONBOX_END);

  converter_cancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (converter_cancel);
  gtk_dialog_add_action_widget (GTK_DIALOG (converterdlg), converter_cancel, GTK_RESPONSE_CANCEL);
  gtk_widget_set_can_default(converter_cancel, TRUE);

  converter_ok = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (converter_ok);
  gtk_dialog_add_action_widget (GTK_DIALOG (converterdlg), converter_ok, GTK_RESPONSE_OK);
  gtk_widget_set_can_default(converter_ok, TRUE);

  g_signal_connect ((gpointer) output_folder, "changed",
                    G_CALLBACK (on_output_folder_changed),
                    NULL);
  g_signal_connect ((gpointer) converter_output_browse, "clicked",
                    G_CALLBACK (on_converter_output_browse_clicked),
                    NULL);
  g_signal_connect ((gpointer) preserve_folders, "toggled",
                    G_CALLBACK (on_preserve_folders_toggled),
                    NULL);
  g_signal_connect ((gpointer) bypass_same_format, "toggled",
                    G_CALLBACK (on_bypass_same_format_toggled),
                    NULL);
  g_signal_connect ((gpointer) retag_after_copy, "toggled",
                    G_CALLBACK (on_retag_after_copy_toggled),
                    NULL);
  g_signal_connect ((gpointer) encoder, "changed",
                    G_CALLBACK (on_converter_encoder_changed),
                    NULL);
  g_signal_connect ((gpointer) edit_encoder_presets, "clicked",
                    G_CALLBACK (on_edit_encoder_presets_clicked),
                    NULL);
  g_signal_connect ((gpointer) dsp_preset, "changed",
                    G_CALLBACK (on_converter_dsp_preset_changed),
                    NULL);
  g_signal_connect ((gpointer) edit_dsp_presets, "clicked",
                    G_CALLBACK (on_edit_dsp_presets_clicked),
                    NULL);
  g_signal_connect ((gpointer) numthreads, "changed",
                    G_CALLBACK (on_numthreads_changed),
                    NULL);
  g_signal_connect ((gpointer) output_format, "changed",
                    G_CALLBACK (on_converter_output_format_changed),
                    NULL);
  g_signal_connect ((gpointer) overwrite_action, "changed",
                    G_CALLBACK (on_overwrite_action_changed),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (converterdlg, converterdlg, "converterdlg");
  GLADE_HOOKUP_OBJECT_NO_REF (converterdlg, dialog_vbox6, "dialog_vbox6");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox105, "hbox105");
  GLADE_HOOKUP_OBJECT (converterdlg, vbox26, "vbox26");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox67, "hbox67");
  GLADE_HOOKUP_OBJECT (converterdlg, label103, "label103");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox68, "hbox68");
  GLADE_HOOKUP_OBJECT (converterdlg, output_folder, "output_folder");
  GLADE_HOOKUP_OBJECT (converterdlg, converter_output_browse, "converter_output_browse");
  GLADE_HOOKUP_OBJECT (converterdlg, write_to_source_folder, "write_to_source_folder");
  GLADE_HOOKUP_OBJECT (converterdlg, preserve_folders, "preserve_folders");
  GLADE_HOOKUP_OBJECT (converterdlg, bypass_same_format, "bypass_same_format");
  GLADE_HOOKUP_OBJECT (converterdlg, retag_after_copy, "retag_after_copy");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox100, "hbox100");
  GLADE_HOOKUP_OBJECT (converterdlg, label122, "label122");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox101, "hbox101");
  GLADE_HOOKUP_OBJECT (converterdlg, output_file, "output_file");
  GLADE_HOOKUP_OBJECT (converterdlg, custom6, "custom6");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox69, "hbox69");
  GLADE_HOOKUP_OBJECT (converterdlg, label104, "label104");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox90, "hbox90");
  GLADE_HOOKUP_OBJECT (converterdlg, encoder, "encoder");
  GLADE_HOOKUP_OBJECT (converterdlg, edit_encoder_presets, "edit_encoder_presets");
  GLADE_HOOKUP_OBJECT (converterdlg, image469, "image469");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox86, "hbox86");
  GLADE_HOOKUP_OBJECT (converterdlg, label114, "label114");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox91, "hbox91");
  GLADE_HOOKUP_OBJECT (converterdlg, dsp_preset, "dsp_preset");
  GLADE_HOOKUP_OBJECT (converterdlg, edit_dsp_presets, "edit_dsp_presets");
  GLADE_HOOKUP_OBJECT (converterdlg, image470, "image470");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox88, "hbox88");
  GLADE_HOOKUP_OBJECT (converterdlg, label116, "label116");
  GLADE_HOOKUP_OBJECT (converterdlg, numthreads, "numthreads");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox89, "hbox89");
  GLADE_HOOKUP_OBJECT (converterdlg, label117, "label117");
  GLADE_HOOKUP_OBJECT (converterdlg, output_format, "output_format");
  GLADE_HOOKUP_OBJECT (converterdlg, hbox99, "hbox99");
  GLADE_HOOKUP_OBJECT (converterdlg, label121, "label121");
  GLADE_HOOKUP_OBJECT (converterdlg, overwrite_action, "overwrite_action");
  GLADE_HOOKUP_OBJECT (converterdlg, scrolledwindow9, "scrolledwindow9");
  GLADE_HOOKUP_OBJECT (converterdlg, preview_tree, "preview_tree");
  GLADE_HOOKUP_OBJECT_NO_REF (converterdlg, dialog_action_area5, "dialog_action_area5");
  GLADE_HOOKUP_OBJECT (converterdlg, converter_cancel, "converter_cancel");
  GLADE_HOOKUP_OBJECT (converterdlg, converter_ok, "converter_ok");

  return converterdlg;
}
Example #26
0
void
dialog_open_system_new (DialogOpenSystem * dlg)
{
  int i;
  char *name;
  GtkFileFilter *filter;
  System s[1];

  filter = gtk_file_filter_new ();
  gtk_file_filter_add_pattern (filter, "*.xml");
  gtk_file_filter_add_pattern (filter, "*.XML");
  gtk_file_filter_set_name (filter, gettext ("XML system file (*.xml, *.XML)"));
  dlg->button_open = (GtkFileChooserButton *) gtk_file_chooser_button_new
    (gettext ("Open system"), GTK_FILE_CHOOSER_ACTION_OPEN);
  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dlg->button_open), filter);
  gtk_file_chooser_set_filename
    (GTK_FILE_CHOOSER (dlg->button_open), string_system);

  dlg->window =
    (GtkDialog *) gtk_dialog_new_with_buttons (gettext ("Open system"),
                                               dialog_simulator->window,
                                               GTK_DIALOG_MODAL,
                                               gettext ("_OK"), GTK_RESPONSE_OK,
                                               gettext ("_Cancel"),
                                               GTK_RESPONSE_CANCEL, NULL);
  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dlg->window)),
                     GTK_WIDGET (dlg->button_open));
  gtk_widget_show (GTK_WIDGET (dlg->button_open));

  window_parent = (GtkWindow *) dlg->window;

  do
    {
      i = gtk_dialog_run (dlg->window);
      if (i == GTK_RESPONSE_OK)
        {
          name = gtk_file_chooser_get_filename
            (GTK_FILE_CHOOSER (dlg->button_open));
          if (name)
            {
              i = system_open_xml (s, g_path_get_basename (name),
                                   g_path_get_dirname (name));
            }
          else
            {
              i = 0;
              jbw_show_error2 (gettext ("Open system"),
                               gettext ("Unable to open the file"));
            }
          if (i)
            {
              g_free (string_system);
              string_system = jb_strdup (name);
              g_free (name);
              system_delete (sys);
              if (!system_copy (sys, s))
                {
                  jbw_show_error (message);
                  exit (0);
                }
              system_delete (s);
              if (!simulate_start ())
                continue;
              dialog_simulator_actualize_bar (dialog_simulator);
              dialog_simulator_actualize (dialog_simulator);
              break;
            }
          else
            g_free (name);
        }
      else
        break;
    }
  while (1);
  gtk_widget_destroy (GTK_WIDGET (dlg->window));

  window_parent = dialog_simulator->window;
}
Example #27
0
GtkWidget*
create_dsppreset_editor (void)
{
  GtkWidget *dsppreset_editor;
  GtkWidget *dialog_vbox9;
  GtkWidget *vbox30;
  GtkWidget *hbox81;
  GtkWidget *label111;
  GtkWidget *title;
  GtkWidget *vbox29;
  GtkWidget *hbox82;
  GtkWidget *add;
  GtkWidget *remove;
  GtkWidget *configure;
  GtkWidget *hbox98;
  GtkWidget *scrolledwindow7;
  GtkWidget *plugins;
  GtkWidget *vbox34;
  GtkWidget *up;
  GtkWidget *down;
  GtkWidget *dialog_action_area8;
  GtkWidget *cancelbutton6;
  GtkWidget *okbutton6;

  dsppreset_editor = gtk_dialog_new ();
  gtk_widget_set_size_request (dsppreset_editor, 468, 254);
  gtk_window_set_title (GTK_WINDOW (dsppreset_editor), _("DSP Preset Editor"));
  gtk_window_set_modal (GTK_WINDOW (dsppreset_editor), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (dsppreset_editor), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox9 = gtk_dialog_get_content_area (GTK_DIALOG (dsppreset_editor));
  gtk_widget_show (dialog_vbox9);

  vbox30 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox30);
  gtk_box_pack_start (GTK_BOX (dialog_vbox9), vbox30, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox30), 12);

  hbox81 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox81);
  gtk_box_pack_start (GTK_BOX (vbox30), hbox81, FALSE, TRUE, 0);

  label111 = gtk_label_new (_("Title"));
  gtk_widget_show (label111);
  gtk_box_pack_start (GTK_BOX (hbox81), label111, FALSE, FALSE, 0);

  title = gtk_entry_new ();
  gtk_widget_show (title);
  gtk_box_pack_start (GTK_BOX (hbox81), title, TRUE, TRUE, 0);
  gtk_entry_set_text (GTK_ENTRY (title), _("Untitled DSP Preset"));
  gtk_entry_set_invisible_char (GTK_ENTRY (title), 9679);
  gtk_entry_set_activates_default (GTK_ENTRY (title), TRUE);

  vbox29 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox29);
  gtk_box_pack_start (GTK_BOX (vbox30), vbox29, TRUE, TRUE, 0);

  hbox82 = gtk_hbox_new (TRUE, 8);
  gtk_widget_show (hbox82);
  gtk_box_pack_start (GTK_BOX (vbox29), hbox82, FALSE, TRUE, 0);

  add = gtk_button_new_with_mnemonic (_("Add"));
  gtk_widget_show (add);
  gtk_box_pack_start (GTK_BOX (hbox82), add, TRUE, TRUE, 0);

  remove = gtk_button_new_with_mnemonic (_("Remove"));
  gtk_widget_show (remove);
  gtk_box_pack_start (GTK_BOX (hbox82), remove, TRUE, TRUE, 0);

  configure = gtk_button_new_with_mnemonic (_("Configure"));
  gtk_widget_show (configure);
  gtk_box_pack_start (GTK_BOX (hbox82), configure, TRUE, TRUE, 0);

  hbox98 = gtk_hbox_new (FALSE, 8);
  gtk_widget_show (hbox98);
  gtk_box_pack_start (GTK_BOX (vbox29), hbox98, TRUE, TRUE, 0);

  scrolledwindow7 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow7);
  gtk_box_pack_start (GTK_BOX (hbox98), scrolledwindow7, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow7), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow7), GTK_SHADOW_IN);

  plugins = gtk_tree_view_new ();
  gtk_widget_show (plugins);
  gtk_container_add (GTK_CONTAINER (scrolledwindow7), plugins);
  gtk_widget_set_size_request (plugins, 196, -1);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (plugins), FALSE);

  vbox34 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox34);
  gtk_box_pack_start (GTK_BOX (hbox98), vbox34, FALSE, FALSE, 0);

  up = gtk_button_new_from_stock ("gtk-go-up");
  gtk_widget_show (up);
  gtk_box_pack_start (GTK_BOX (vbox34), up, FALSE, FALSE, 0);

  down = gtk_button_new_from_stock ("gtk-go-down");
  gtk_widget_show (down);
  gtk_box_pack_start (GTK_BOX (vbox34), down, FALSE, FALSE, 0);

  dialog_action_area8 = gtk_dialog_get_action_area (GTK_DIALOG (dsppreset_editor));
  gtk_widget_show (dialog_action_area8);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area8), GTK_BUTTONBOX_END);

  cancelbutton6 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (cancelbutton6);
  gtk_dialog_add_action_widget (GTK_DIALOG (dsppreset_editor), cancelbutton6, GTK_RESPONSE_CANCEL);
  gtk_widget_set_can_default(cancelbutton6, TRUE);

  okbutton6 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton6);
  gtk_dialog_add_action_widget (GTK_DIALOG (dsppreset_editor), okbutton6, GTK_RESPONSE_OK);
  gtk_widget_set_can_default(okbutton6, TRUE);

  g_signal_connect ((gpointer) add, "clicked",
                    G_CALLBACK (on_dsp_preset_add_plugin_clicked),
                    NULL);
  g_signal_connect ((gpointer) remove, "clicked",
                    G_CALLBACK (on_dsp_preset_remove_plugin_clicked),
                    NULL);
  g_signal_connect ((gpointer) configure, "clicked",
                    G_CALLBACK (on_dsp_preset_plugin_configure_clicked),
                    NULL);
  g_signal_connect ((gpointer) up, "clicked",
                    G_CALLBACK (on_dsp_preset_plugin_up_clicked),
                    NULL);
  g_signal_connect ((gpointer) down, "clicked",
                    G_CALLBACK (on_dsp_preset_plugin_down_clicked),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (dsppreset_editor, dsppreset_editor, "dsppreset_editor");
  GLADE_HOOKUP_OBJECT_NO_REF (dsppreset_editor, dialog_vbox9, "dialog_vbox9");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, vbox30, "vbox30");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, hbox81, "hbox81");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, label111, "label111");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, title, "title");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, vbox29, "vbox29");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, hbox82, "hbox82");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, add, "add");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, remove, "remove");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, configure, "configure");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, hbox98, "hbox98");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, scrolledwindow7, "scrolledwindow7");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, plugins, "plugins");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, vbox34, "vbox34");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, up, "up");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, down, "down");
  GLADE_HOOKUP_OBJECT_NO_REF (dsppreset_editor, dialog_action_area8, "dialog_action_area8");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, cancelbutton6, "cancelbutton6");
  GLADE_HOOKUP_OBJECT (dsppreset_editor, okbutton6, "okbutton6");

  return dsppreset_editor;
}
Example #28
0
/* Shows the preferences dialog on the given tab */
void show_preferences(gint tab) {
  if(gtk_grab_get_current()) {
    /* A window is already open, so we present it to the user */
    GtkWidget *toplevel = gtk_widget_get_toplevel(gtk_grab_get_current());
    gtk_window_present((GtkWindow*)toplevel);
    return;
  }
  /* Declare some variables */
  GtkWidget *frame,     *label,
            *alignment, *hbox,
            *vbox;

  GtkWidget *adjustment, *adjustment_small, *adjustment_statics;
  GtkTreeViewColumn *tree_column;

  /* Create the dialog */
  GtkWidget* dialog = gtk_dialog_new_with_buttons(_("Preferences"),     NULL,
                                                   (GTK_DIALOG_MODAL  + GTK_DIALOG_NO_SEPARATOR),
                                                    GTK_STOCK_CANCEL,   GTK_RESPONSE_REJECT,
                                                    GTK_STOCK_OK,       GTK_RESPONSE_ACCEPT, NULL);

  gtk_window_set_icon((GtkWindow*)dialog, gtk_widget_render_icon(dialog, GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU, NULL));
  gtk_window_set_resizable((GtkWindow*)dialog, FALSE);

  /* Create notebook */
  GtkWidget* notebook = gtk_notebook_new();
#if GTK_CHECK_VERSION (2,14,0)
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG(dialog))), notebook, TRUE, TRUE, 2);
#else
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, TRUE, TRUE, 2);
#endif

  /* Build the settings page */
  GtkWidget* page_settings = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_settings, 12, 6, 12, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_settings, gtk_label_new(_("Settings")));
  GtkWidget* vbox_settings = gtk_vbox_new(FALSE, 12);
  gtk_container_add((GtkContainer*)page_settings, vbox_settings);

  /* Build the clipboards frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Clipboards</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  copy_check = gtk_check_button_new_with_mnemonic(_("Use _Copy (Ctrl-C)"));
  g_signal_connect((GObject*)copy_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, copy_check, FALSE, FALSE, 0);
  primary_check = gtk_check_button_new_with_mnemonic(_("Use _Primary (Selection)"));
  g_signal_connect((GObject*)primary_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, primary_check, FALSE, FALSE, 0);
  synchronize_check = gtk_check_button_new_with_mnemonic(_("S_ynchronize clipboards"));
  gtk_box_pack_start((GtkBox*)vbox, synchronize_check, FALSE, FALSE, 0);
  paste_check = gtk_check_button_new_with_mnemonic(_("_Automatically paste selected item"));
  g_signal_connect((GObject*)paste_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, paste_check, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_settings, frame, FALSE, FALSE, 0);

  /* Build the miscellaneous frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Miscellaneous</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  show_indexes_check = gtk_check_button_new_with_mnemonic(_("Show _indexes in history menu"));
  gtk_box_pack_start((GtkBox*)vbox, show_indexes_check, FALSE, FALSE, 0);
  save_uris_check = gtk_check_button_new_with_mnemonic(_("S_ave URIs"));
  gtk_box_pack_start((GtkBox*)vbox, save_uris_check, FALSE, FALSE, 0);
  hyperlinks_check = gtk_check_button_new_with_mnemonic(_("Capture _hyperlinks only"));
  gtk_box_pack_start((GtkBox*)vbox, hyperlinks_check, FALSE, FALSE, 0);
  confirm_check = gtk_check_button_new_with_mnemonic(_("C_onfirm before clearing history"));
  gtk_box_pack_start((GtkBox*)vbox, confirm_check, FALSE, FALSE, 0);
  use_rmb_menu_check = gtk_check_button_new_with_mnemonic(_("_Use right-click menu"));
  gtk_box_pack_start((GtkBox*)vbox, use_rmb_menu_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_settings, frame, FALSE, FALSE, 0);

  /* Build the history page */
  GtkWidget* page_history = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_history, 12, 6, 12, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_history, gtk_label_new(_("History")));
  GtkWidget* vbox_history = gtk_vbox_new(FALSE, 12);
  gtk_container_add((GtkContainer*)page_history, vbox_history);

  /* Build the history frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>History</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  save_check = gtk_check_button_new_with_mnemonic(_("Save _history"));
  gtk_widget_set_tooltip_text(save_check, _("Save and restore history between sessions"));
  gtk_box_pack_start((GtkBox*)vbox, save_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Items in history:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment = gtk_adjustment_new(25, 5, 1000, 1, 10, 0);
  history_spin = gtk_spin_button_new((GtkAdjustment*)adjustment, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)history_spin, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, history_spin, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Items in menu:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment_small = gtk_adjustment_new(25, 5, 100, 1, 10, 0);
  items_menu = gtk_spin_button_new((GtkAdjustment*)adjustment_small, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)items_menu, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, items_menu, FALSE, FALSE, 0);
  statics_show_check = gtk_check_button_new_with_mnemonic(_("Show _static items in menu"));
  g_signal_connect((GObject*)statics_show_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, statics_show_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Static items in menu:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment_statics = gtk_adjustment_new(10, 1, 100, 1, 10, 0);
  statics_items_spin = gtk_spin_button_new((GtkAdjustment*)adjustment_statics, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)statics_items_spin, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, statics_items_spin, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_history, frame, FALSE, FALSE, 0);

  /* Build the items frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Items</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  linemode_check = gtk_check_button_new_with_mnemonic(_("Show in a single _line"));
  gtk_box_pack_start((GtkBox*)vbox, linemode_check, FALSE, FALSE, 0);
  reverse_check = gtk_check_button_new_with_mnemonic(_("Show in _reverse order"));
  gtk_box_pack_start((GtkBox*)vbox, reverse_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Character length of items:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment = gtk_adjustment_new(50, 25, 75, 1, 5, 0);
  charlength_spin = gtk_spin_button_new((GtkAdjustment*)adjustment, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)charlength_spin, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, charlength_spin, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Omit items in the:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  ellipsize_combo = gtk_combo_box_text_new();
  gtk_combo_box_text_append_text((GtkComboBox*)ellipsize_combo, _("Beginning"));
  gtk_combo_box_text_append_text((GtkComboBox*)ellipsize_combo, _("Middle"));
  gtk_combo_box_text_append_text((GtkComboBox*)ellipsize_combo, _("End"));
  gtk_box_pack_start((GtkBox*)hbox, ellipsize_combo, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_history, frame, FALSE, FALSE, 0);

  /* Build the omitting frame
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Omitting</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Omit items in the:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  ellipsize_combo = gtk_combo_box_new_text();
  gtk_combo_box_text_append_text((GtkComboBox*)ellipsize_combo, _("Beginning"));
  gtk_combo_box_text_append_text((GtkComboBox*)ellipsize_combo, _("Middle"));
  gtk_combo_box_text_append_text((GtkComboBox*)ellipsize_combo, _("End"));
  gtk_box_pack_start((GtkBox*)hbox, ellipsize_combo, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_history, frame, FALSE, FALSE, 0); */

  /* Build the actions page */
  GtkWidget* page_actions = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_actions, 6, 6, 6, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_actions, gtk_label_new(_("Actions")));
  GtkWidget* vbox_actions = gtk_vbox_new(FALSE, 6);
  gtk_container_add((GtkContainer*)page_actions, vbox_actions);

  /* Build the actions label */
  label = gtk_label_new(_("Control-click ClipIt\'s tray icon to use actions"));
  gtk_label_set_line_wrap((GtkLabel*)label, TRUE);
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)vbox_actions, label, FALSE, FALSE, 0);

  /* Build the actions treeview */
  GtkWidget* scrolled_window = gtk_scrolled_window_new(
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0),
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0));

  gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type((GtkScrolledWindow*)scrolled_window, GTK_SHADOW_ETCHED_OUT);
  GtkWidget* treeview = gtk_tree_view_new();
  gtk_tree_view_set_reorderable((GtkTreeView*)treeview, TRUE);
  gtk_tree_view_set_rules_hint((GtkTreeView*)treeview, TRUE);
  actions_list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING, -1);
  gtk_tree_view_set_model((GtkTreeView*)treeview, (GtkTreeModel*)actions_list);
  GtkCellRenderer* name_renderer = gtk_cell_renderer_text_new();
  g_object_set(name_renderer, "editable", TRUE, NULL);
  g_signal_connect((GObject*)name_renderer, "edited", (GCallback)edit_action, (gpointer)0);
  tree_column = gtk_tree_view_column_new_with_attributes(_("Action"), name_renderer, "text", 0, NULL);
  gtk_tree_view_column_set_resizable(tree_column, TRUE);
  gtk_tree_view_append_column((GtkTreeView*)treeview, tree_column);
  GtkCellRenderer* command_renderer = gtk_cell_renderer_text_new();
  g_object_set(command_renderer, "editable", TRUE, NULL);
  g_object_set(command_renderer, "ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  g_signal_connect((GObject*)command_renderer, "edited", (GCallback)edit_action, (gpointer)1);
  tree_column = gtk_tree_view_column_new_with_attributes(_("Command"), command_renderer, "text", 1, NULL);
  gtk_tree_view_column_set_expand(tree_column, TRUE);
  gtk_tree_view_append_column((GtkTreeView*)treeview, tree_column);
  gtk_container_add((GtkContainer*)scrolled_window, treeview);
  gtk_box_pack_start((GtkBox*)vbox_actions, scrolled_window, TRUE, TRUE, 0);

  /* Edit selection and connect treeview related signals */
  actions_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview);
  gtk_tree_selection_set_mode(actions_selection, GTK_SELECTION_BROWSE);
  g_signal_connect((GObject*)treeview, "key-press-event", (GCallback)delete_key_pressed, NULL);

  /* Build the buttons */
  GtkWidget* hbbox = gtk_hbutton_box_new();
  gtk_box_set_spacing((GtkBox*)hbbox, 6);
  gtk_button_box_set_layout((GtkButtonBox*)hbbox, GTK_BUTTONBOX_START);
  GtkWidget* add_button = gtk_button_new_with_label(_("Add..."));
  gtk_button_set_image((GtkButton*)add_button, gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)add_button, "clicked", (GCallback)add_action, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, add_button, FALSE, TRUE, 0);
  GtkWidget* remove_button = gtk_button_new_with_label(_("Remove"));
  gtk_button_set_image((GtkButton*)remove_button, gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)remove_button, "clicked", (GCallback)remove_action, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, remove_button, FALSE, TRUE, 0);
  GtkWidget* up_button = gtk_button_new();
  gtk_button_set_image((GtkButton*)up_button, gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)up_button, "clicked", (GCallback)move_action_up, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, up_button, FALSE, TRUE, 0);
  GtkWidget* down_button = gtk_button_new();
  gtk_button_set_image((GtkButton*)down_button, gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)down_button, "clicked", (GCallback)move_action_down, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, down_button, FALSE, TRUE, 0);
  gtk_box_pack_start((GtkBox*)vbox_actions, hbbox, FALSE, FALSE, 0);

  /* Build the exclude page */
  GtkWidget* page_exclude = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_exclude, 6, 6, 6, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_exclude, gtk_label_new(_("Exclude")));
  GtkWidget* vbox_exclude = gtk_vbox_new(FALSE, 6);
  gtk_container_add((GtkContainer*)page_exclude, vbox_exclude);

  /* Build the exclude label */
  label = gtk_label_new(_("Regex list of items that should not be inserted into the history (passwords/sites that you don't need in history, etc)."));
  gtk_label_set_line_wrap((GtkLabel*)label, TRUE);
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)vbox_exclude, label, FALSE, FALSE, 0);

  /* Build the exclude treeview */
  GtkWidget* scrolled_window_exclude = gtk_scrolled_window_new(
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0),
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0));

  gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window_exclude, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type((GtkScrolledWindow*)scrolled_window_exclude, GTK_SHADOW_ETCHED_OUT);
  GtkWidget* treeview_exclude = gtk_tree_view_new();
  gtk_tree_view_set_reorderable((GtkTreeView*)treeview_exclude, TRUE);
  gtk_tree_view_set_rules_hint((GtkTreeView*)treeview_exclude, TRUE);
  exclude_list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING, -1);
  gtk_tree_view_set_model((GtkTreeView*)treeview_exclude, (GtkTreeModel*)exclude_list);
  GtkCellRenderer* name_renderer_exclude = gtk_cell_renderer_text_new();
  g_object_set(name_renderer_exclude, "editable", TRUE, NULL);
  g_signal_connect((GObject*)name_renderer_exclude, "edited", (GCallback)edit_exclude, (gpointer)0);
  tree_column = gtk_tree_view_column_new_with_attributes(_("Regex"), name_renderer_exclude, "text", 0, NULL);
  gtk_tree_view_column_set_resizable(tree_column, TRUE);
  gtk_tree_view_append_column((GtkTreeView*)treeview_exclude, tree_column);
  gtk_container_add((GtkContainer*)scrolled_window_exclude, treeview_exclude);
  gtk_box_pack_start((GtkBox*)vbox_exclude, scrolled_window_exclude, TRUE, TRUE, 0);

  /* Edit selection and connect treeview related signals */
  exclude_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview_exclude);
  gtk_tree_selection_set_mode(exclude_selection, GTK_SELECTION_BROWSE);
  g_signal_connect((GObject*)treeview_exclude, "key-press-event", (GCallback)delete_key_pressed, NULL);

  /* Build the buttons */
  GtkWidget* hbbox_exclude = gtk_hbutton_box_new();
  gtk_box_set_spacing((GtkBox*)hbbox_exclude, 6);
  gtk_button_box_set_layout((GtkButtonBox*)hbbox_exclude, GTK_BUTTONBOX_START);
  GtkWidget* add_button_exclude = gtk_button_new_with_label(_("Add..."));
  gtk_button_set_image((GtkButton*)add_button_exclude, gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)add_button_exclude, "clicked", (GCallback)add_exclude, NULL);
  gtk_box_pack_start((GtkBox*)hbbox_exclude, add_button_exclude, FALSE, TRUE, 0);
  GtkWidget* remove_button_exclude = gtk_button_new_with_label(_("Remove"));
  gtk_button_set_image((GtkButton*)remove_button_exclude, gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)remove_button_exclude, "clicked", (GCallback)remove_exclude, NULL);
  gtk_box_pack_start((GtkBox*)hbbox_exclude, remove_button_exclude, FALSE, TRUE, 0);
  gtk_box_pack_start((GtkBox*)vbox_exclude, hbbox_exclude, FALSE, FALSE, 0);

  /* Build the hotkeys page */
  GtkWidget* page_extras = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_extras, 12, 6, 12, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_extras, gtk_label_new(_("Hotkeys")));
  GtkWidget* vbox_extras = gtk_vbox_new(FALSE, 12);
  gtk_container_add((GtkContainer*)page_extras, vbox_extras);

  /* Build the hotkeys frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Hotkeys</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  /* History key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("History hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  history_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)history_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, history_key_entry, TRUE, TRUE, 0);
  /* Actions key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Actions hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  actions_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)actions_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, actions_key_entry, TRUE, TRUE, 0);
  /* Menu key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Menu hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  menu_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)menu_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, menu_key_entry, TRUE, TRUE, 0);
  /* Search key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Manage hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  search_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)search_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, search_key_entry, TRUE, TRUE, 0);
  /* Offline mode key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Offline mode hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  offline_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)offline_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, offline_key_entry, TRUE, TRUE, 0);
  gtk_box_pack_start((GtkBox*)vbox_extras, frame, FALSE, FALSE, 0);

  /* Make widgets reflect current preferences */
  gtk_toggle_button_set_active((GtkToggleButton*)copy_check, prefs.use_copy);
  gtk_toggle_button_set_active((GtkToggleButton*)primary_check, prefs.use_primary);
  gtk_toggle_button_set_active((GtkToggleButton*)synchronize_check, prefs.synchronize);
  gtk_toggle_button_set_active((GtkToggleButton*)paste_check, prefs.automatic_paste);
  gtk_toggle_button_set_active((GtkToggleButton*)show_indexes_check, prefs.show_indexes);
  gtk_toggle_button_set_active((GtkToggleButton*)save_uris_check, prefs.save_uris);
  gtk_toggle_button_set_active((GtkToggleButton*)use_rmb_menu_check, prefs.use_rmb_menu);
  gtk_toggle_button_set_active((GtkToggleButton*)save_check, prefs.save_history);
  gtk_spin_button_set_value((GtkSpinButton*)history_spin, (gdouble)prefs.history_limit);
  gtk_spin_button_set_value((GtkSpinButton*)items_menu, (gdouble)prefs.items_menu);
  gtk_toggle_button_set_active((GtkToggleButton*)statics_show_check, prefs.statics_show);
  gtk_spin_button_set_value((GtkSpinButton*)statics_items_spin, (gdouble)prefs.statics_items);
  gtk_toggle_button_set_active((GtkToggleButton*)hyperlinks_check, prefs.hyperlinks_only);
  gtk_toggle_button_set_active((GtkToggleButton*)confirm_check, prefs.confirm_clear);
  gtk_toggle_button_set_active((GtkToggleButton*)linemode_check, prefs.single_line);
  gtk_toggle_button_set_active((GtkToggleButton*)reverse_check, prefs.reverse_history);
  gtk_spin_button_set_value((GtkSpinButton*)charlength_spin, (gdouble)prefs.item_length);
  gtk_combo_box_set_active((GtkComboBox*)ellipsize_combo, prefs.ellipsize - 1);
  gtk_entry_set_text((GtkEntry*)history_key_entry, prefs.history_key);
  gtk_entry_set_text((GtkEntry*)actions_key_entry, prefs.actions_key);
  gtk_entry_set_text((GtkEntry*)menu_key_entry, prefs.menu_key);
  gtk_entry_set_text((GtkEntry*)search_key_entry, prefs.search_key);
  gtk_entry_set_text((GtkEntry*)offline_key_entry, prefs.offline_key);

  /* Read actions */
  read_actions();
  read_excludes();

  /* Run the dialog */
  gtk_widget_show_all(dialog);
#ifdef HAVE_APPINDICATOR
  gtk_widget_hide(use_rmb_menu_check);
#endif
  gtk_notebook_set_current_page((GtkNotebook*)notebook, tab);
  if (gtk_dialog_run((GtkDialog*)dialog) == GTK_RESPONSE_ACCEPT)
  {
    /* If the user disabled history saving, we ask him if he wants to delete the history file */
    if(prefs.save_history && !gtk_toggle_button_get_active((GtkToggleButton*)save_check))
      check_saved_hist_file();
    /* Apply and save preferences */
    apply_preferences();
    save_preferences();
    save_actions();
    save_excludes();
  }
  gtk_widget_destroy(dialog);
}
Example #29
0
GtkWidget*
create_preset_list (void)
{
  GtkWidget *preset_list;
  GtkWidget *dialog_vbox11;
  GtkWidget *vbox33;
  GtkWidget *hbox94;
  GtkWidget *add;
  GtkWidget *copy;
  GtkWidget *remove;
  GtkWidget *edit;
  GtkWidget *scrolledwindow8;
  GtkWidget *presets;
  GtkWidget *dialog_action_area10;
  GtkWidget *okbutton8;

  preset_list = gtk_dialog_new ();
  gtk_widget_set_size_request (preset_list, 450, 254);
  gtk_window_set_title (GTK_WINDOW (preset_list), _("Presets"));
  gtk_window_set_modal (GTK_WINDOW (preset_list), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (preset_list), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox11 = gtk_dialog_get_content_area (GTK_DIALOG (preset_list));
  gtk_widget_show (dialog_vbox11);

  vbox33 = gtk_vbox_new (FALSE, 8);
  gtk_widget_show (vbox33);
  gtk_box_pack_start (GTK_BOX (dialog_vbox11), vbox33, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox33), 12);

  hbox94 = gtk_hbox_new (TRUE, 8);
  gtk_widget_show (hbox94);
  gtk_box_pack_start (GTK_BOX (vbox33), hbox94, FALSE, TRUE, 0);

  add = gtk_button_new_from_stock ("gtk-add");
  gtk_widget_show (add);
  gtk_box_pack_start (GTK_BOX (hbox94), add, FALSE, TRUE, 0);

  copy = gtk_button_new_from_stock ("gtk-copy");
  gtk_widget_show (copy);
  gtk_box_pack_start (GTK_BOX (hbox94), copy, FALSE, TRUE, 0);

  remove = gtk_button_new_from_stock ("gtk-remove");
  gtk_widget_show (remove);
  gtk_box_pack_start (GTK_BOX (hbox94), remove, FALSE, TRUE, 0);

  edit = gtk_button_new_from_stock ("gtk-edit");
  gtk_widget_show (edit);
  gtk_box_pack_start (GTK_BOX (hbox94), edit, FALSE, TRUE, 0);

  scrolledwindow8 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow8);
  gtk_box_pack_start (GTK_BOX (vbox33), scrolledwindow8, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_SHADOW_IN);

  presets = gtk_tree_view_new ();
  gtk_widget_show (presets);
  gtk_container_add (GTK_CONTAINER (scrolledwindow8), presets);
  gtk_widget_set_size_request (presets, 400, 160);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (presets), FALSE);

  dialog_action_area10 = gtk_dialog_get_action_area (GTK_DIALOG (preset_list));
  gtk_widget_show (dialog_action_area10);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area10), GTK_BUTTONBOX_END);

  okbutton8 = gtk_button_new_from_stock ("gtk-close");
  gtk_widget_show (okbutton8);
  gtk_dialog_add_action_widget (GTK_DIALOG (preset_list), okbutton8, GTK_RESPONSE_CLOSE);
  gtk_widget_set_can_default(okbutton8, TRUE);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (preset_list, preset_list, "preset_list");
  GLADE_HOOKUP_OBJECT_NO_REF (preset_list, dialog_vbox11, "dialog_vbox11");
  GLADE_HOOKUP_OBJECT (preset_list, vbox33, "vbox33");
  GLADE_HOOKUP_OBJECT (preset_list, hbox94, "hbox94");
  GLADE_HOOKUP_OBJECT (preset_list, add, "add");
  GLADE_HOOKUP_OBJECT (preset_list, copy, "copy");
  GLADE_HOOKUP_OBJECT (preset_list, remove, "remove");
  GLADE_HOOKUP_OBJECT (preset_list, edit, "edit");
  GLADE_HOOKUP_OBJECT (preset_list, scrolledwindow8, "scrolledwindow8");
  GLADE_HOOKUP_OBJECT (preset_list, presets, "presets");
  GLADE_HOOKUP_OBJECT_NO_REF (preset_list, dialog_action_area10, "dialog_action_area10");
  GLADE_HOOKUP_OBJECT (preset_list, okbutton8, "okbutton8");

  return preset_list;
}
Example #30
0
GtkWidget *
do_form_data_layout (GtkWidget *do_widget)
{  
	if (!window) {
		GdaStatement *stmt;
		GtkWidget *vbox;
		GtkWidget *label;
		GdaDataModel *model;
		GtkWidget *form;
		GdauiRawForm *raw_form;
		
		window = gtk_dialog_new_with_buttons ("Form with custom data layout",
						      GTK_WINDOW (do_widget),
						      0,
						      "Close", GTK_RESPONSE_NONE,
						      NULL);
		
		g_signal_connect (window, "response",
				  G_CALLBACK (gtk_widget_destroy), NULL);
		g_signal_connect (window, "destroy",
				  G_CALLBACK (gtk_widget_destroyed), &window);
		
		vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
		gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))),
				    vbox, TRUE, TRUE, 0);
		gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
		
		label = gtk_label_new ("The following GdauiForm widget displays information about customers,\n"
				       "using a paned container where the right part is used to display\n"
				       "a picture of the customer.\n");
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
		
		/* Create the demo widget: select all the customers and computes the total
		 * amount of orders they have spent */
		stmt = gda_sql_parser_parse_string (demo_parser, 
						    "select c.id, c.name, c.country, c.city, c.photo, c.comments, sum (od.quantity * (1 - od.discount/100) * p.price) as total_orders from customers c left join orders o on (c.id=o.customer) left join order_contents od on (od.order_id=o.id) left join products p on (p.ref = od.product_ref) group by c.id order by total_orders desc",
						    NULL, NULL);
		model = gda_connection_statement_execute_select (demo_cnc, stmt, NULL, NULL);
		g_object_unref (stmt);
		form = gdaui_form_new (model);
		g_object_unref (model);

		/* hide the ID data entry */
		g_object_get (G_OBJECT (form), "raw-form", &raw_form, NULL);
		gdaui_basic_form_entry_set_visible (GDAUI_BASIC_FORM (raw_form),
						    gda_set_get_holder (gdaui_basic_form_get_data_set (GDAUI_BASIC_FORM (raw_form)),
									"id"), FALSE);

		/* request custom layout:
		   <gdaui_form name="customers" container="hpaned">
		     <gdaui_section title="Summary">
		       <gdaui_column>
		         <gdaui_entry name="id"/>
			 <gdaui_entry name="name" label="Customer name"/>
			 <gdaui_entry name="comments" label="Comments" plugin="text"/>
			 <gdaui_entry name="total_orders" label="Total ordered" plugin="number:NB_DECIMALS=2;CURRENCY=€"/>
		       </gdaui_column>
		     </gdaui_section>
		     <gdaui_section title="Photo">
		       <gdaui_column>
		         <gdaui_entry name="photo" plugin="picture"/>
		       </gdaui_column>
		     </gdaui_section>
		   </gdaui_form>
		 */
		gchar *filename;
		filename = demo_find_file ("custom_layout.xml", NULL);
		gdaui_basic_form_set_layout_from_file (GDAUI_BASIC_FORM (raw_form), filename, "customers");
		g_free (filename);

		/* we don't need the raw_form's reference anymore */
		g_object_unref (G_OBJECT (raw_form));

		gtk_box_pack_start (GTK_BOX (vbox), form, TRUE, TRUE, 0);
	}

	gboolean visible;
	g_object_get (G_OBJECT (window), "visible", &visible, NULL);
	if (!visible)
		gtk_widget_show_all (window);
	else {
		gtk_widget_destroy (window);
		window = NULL;
	}

	return window;
}