Exemplo n.º 1
0
static void activate (GtkApplication *app, gpointer user_data)
{
    GtkWidget *window;
    GtkWidget *grid;

    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "Minesweeper GTK");
    gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

    // Create grid
    grid = gtk_grid_new();
    gtk_grid_set_row_homogeneous((GtkGrid*)grid, TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)grid, TRUE);
    
    // and buttons for mines
    for (int x = 0; x < board->_width; x++) {
        for (int y = 0; y < board->_height; y++) {
            GtkWidget *button = gtk_button_new_with_label ("#");
            struct board_pos pos;
            pos.x = x;
            pos.y = y;

            g_signal_connect (button, "clicked", G_CALLBACK (button_callback), &pos);
            gtk_grid_attach (grid, button, x, y, 1, 1);
        }
    }

    gtk_container_add (GTK_CONTAINER (window), grid);
    gtk_widget_show_all (window);
}
Exemplo n.º 2
0
GtkGrid *not_supported_grid(char *protocol) {
  GtkGrid *grid;	/* the grid itself */
  char *label;		/* label of buttons to set */

  /* init a new empty grid */
  grid = GTK_GRID(gtk_grid_new());

  /* set columns to be uniform sized (for better bit size representation) */
  gtk_grid_set_column_homogeneous(grid, TRUE);

  /* allocate memory for button label */
  label = malloc(255);

  /* Upper Layer Protocol */
  sprintf(label, "\n%s is not supported yet.\n\nPlease send an email to [email protected] if you want it to be supported in future releases.", protocol);
  gtk_grid_attach(grid, gtk_label_new(label), 0, 0, 32, 5);

  /* free memory of label */
  free(label);

  /* show ethernet grid (tab) */
  gtk_widget_show_all(GTK_WIDGET(grid));

  /* return grid to tab builder */
  return(grid);
}
Exemplo n.º 3
0
/**
 * uber_window_init:
 * @window: A #UberWindow.
 *
 * Initializes the newly created #UberWindow instance.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
uber_window_init (UberWindow *window) /* IN */
{
	UberWindowPrivate *priv;

	window->priv = G_TYPE_INSTANCE_GET_PRIVATE(window,
	                                           UBER_TYPE_WINDOW,
	                                           UberWindowPrivate);

	/*
	 * Initialize defaults.
	 */
	priv = window->priv;
	gtk_window_set_title(GTK_WINDOW(window), "Uber Graph");
	gtk_window_set_default_size(GTK_WINDOW(window), 750, 550);
	gtk_container_set_border_width(GTK_CONTAINER(window), 12);
	/*
	 * Create notebook container for pages.
	 */
	priv->notebook = gtk_notebook_new();
	gtk_notebook_set_show_border(GTK_NOTEBOOK(priv->notebook), FALSE);
	gtk_notebook_set_show_tabs(GTK_NOTEBOOK(priv->notebook), FALSE);
	gtk_container_add(GTK_CONTAINER(window), priv->notebook);
	gtk_widget_show(priv->notebook);
	/*
	 * Create table for graphs.
	 */
	priv->table = gtk_grid_new();
    gtk_grid_set_row_homogeneous(GTK_GRID(priv->table), TRUE);
    gtk_grid_set_column_homogeneous(GTK_GRID(priv->table), TRUE);
	gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook), priv->table, NULL);
	gtk_widget_show(priv->table);
}
Exemplo n.º 4
0
Arquivo: chrome.c Projeto: napsy/gsfm
void init_main_window()
{
    struct _view *left_view,
                 *right_view;

    chrome = g_malloc(sizeof(*chrome));
    chrome->views = NULL;
    chrome->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    left_view = create_view();
    right_view = create_view();
    chrome->views = g_list_append(chrome->views, left_view);
    chrome->views = g_list_append(chrome->views, right_view);

    chrome->grid = gtk_grid_new();
    gtk_grid_set_row_homogeneous(GTK_GRID(chrome->grid), TRUE);
    gtk_grid_set_column_homogeneous(GTK_GRID(chrome->grid), TRUE);
    gtk_grid_attach(GTK_GRID(chrome->grid), left_view->view, 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(chrome->grid), right_view->view, 1, 0, 1, 1);


    chrome->selected_view = left_view;
    gtk_window_set_title(GTK_WINDOW(chrome->window), "Gtk+ Simple File Manager [gsfm]");
    gtk_window_set_default_size(GTK_WINDOW(chrome->window), 1000, 700);
    gtk_container_add(GTK_CONTAINER(chrome->window), chrome->grid);
    gtk_container_set_border_width(GTK_CONTAINER(chrome->window), 4);

    g_signal_connect(chrome->grid, "button-press-event", G_CALLBACK(window_select_view), NULL);

    install_keyboard_bindings();


    gtk_widget_show_all(chrome->window);
}
Exemplo n.º 5
0
Arquivo: dialpad.c Projeto: Klom/ekiga
static void
ekiga_dialpad_init (EkigaDialpad *dialpad)
{
  unsigned i;

  dialpad->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialpad,
                                               EKIGA_TYPE_DIALPAD,
                                               EkigaDialpadPrivate);

  gtk_grid_set_column_spacing (GTK_GRID (dialpad), 2);
  gtk_grid_set_row_spacing (GTK_GRID (dialpad), 2);
  gtk_grid_set_column_homogeneous (GTK_GRID (dialpad), TRUE);
  gtk_grid_set_row_homogeneous (GTK_GRID (dialpad), TRUE);

  // the dialpad is LTR even for RTL languages
  gtk_widget_set_direction (GTK_WIDGET (dialpad), GTK_TEXT_DIR_LTR);

  /* Create the buttons */
  for (i = 0; i < G_N_ELEMENTS (keys_info); i++) {
    GtkWidget *box;
    GtkWidget *label;
    GtkWidget *button;
    gchar *text;
    GtkWidget *alignment;

    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

    label = gtk_label_new (keys_info[i].number);
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
    gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);

    label = gtk_label_new (NULL);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);

    if (strlen (keys_info [i].letters) > 0) {
      text = g_strdup_printf ("<sub><span size=\"small\">%s</span></sub>",
                              _(keys_info [i].letters));
      gtk_label_set_markup (GTK_LABEL (label), text);
      g_free (text);
    }
    gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);

    alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
    gtk_container_add (GTK_CONTAINER (alignment), box);

    button = gtk_button_new ();
    gtk_container_set_border_width (GTK_CONTAINER (button), 0);
    gtk_container_add (GTK_CONTAINER (button), alignment);

    dialpad->priv->buttons[i] = button;

    gtk_grid_attach (GTK_GRID (dialpad),  button,
		     i % 3, i / 3,
		     1, 1 );

    g_signal_connect (button, "clicked",
                      G_CALLBACK (on_dialpad_button_clicked), dialpad);
  }
}
Exemplo n.º 6
0
void search_box(CSIde_app *app){
	SearchBox *search =(SearchBox*) g_slice_new(SearchBox);
	GtkWidget *search_dialog,
			  *area,
			  *grid,
			  *btn_find,
			  *btn_replace,
			  *btn_replace_all;
	search_dialog = gtk_dialog_new_with_buttons ("search box",
                             GTK_WINDOW(app->main_window),
                             GTK_DIALOG_DESTROY_WITH_PARENT,
                             "Close",
                             GTK_RESPONSE_CANCEL,
                             NULL);

	search->find_entry = gtk_search_entry_new();
	search->replace_entry = gtk_entry_new();
	search->app = app;

	btn_find = gtk_button_new_with_label("Find");
	g_signal_connect(btn_find,"clicked",G_CALLBACK(search_btn_clicked),(gpointer) search);
	btn_replace = gtk_button_new_with_label("Replace");
	g_signal_connect(btn_replace,"clicked",G_CALLBACK(replace_btn_clicked),(gpointer) search);
	btn_replace_all = gtk_button_new_with_label("Replace all");
	g_signal_connect(btn_replace_all,"clicked",G_CALLBACK(replace_all_btn_clicked),(gpointer) search);


	area = gtk_dialog_get_content_area(GTK_DIALOG(search_dialog));
	gtk_container_set_border_width(GTK_CONTAINER(area),10);
	grid = gtk_grid_new();
	gtk_container_set_focus_child (GTK_CONTAINER(grid),search->find_entry);
	//gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
	gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
	gtk_grid_set_row_spacing (GTK_GRID(grid),10);
	gtk_grid_set_column_spacing (GTK_GRID(grid),10);

	gtk_box_pack_start (GTK_BOX(area),grid,TRUE,TRUE,0);
	gtk_grid_attach (GTK_GRID(grid),btn_find,1,1,5,1);
	gtk_grid_attach (GTK_GRID(grid),search->find_entry,6,1,6,1);
	gtk_grid_attach (GTK_GRID(grid),btn_replace,1,3,5,1);
	gtk_grid_attach (GTK_GRID(grid),search->replace_entry,6,3,6,1);
	gtk_grid_attach (GTK_GRID(grid),btn_replace_all,1,5,5,1);
	gtk_widget_show_all(grid);

	gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(search->app->editor->buffer),&iStart);


	switch(gtk_dialog_run(GTK_DIALOG(search_dialog))){
		case GTK_RESPONSE_CANCEL :
			gtk_widget_destroy(search_dialog);
			g_slice_free(SearchBox,search);
			break;

	}

}
Exemplo n.º 7
0
int main (int argc, char *argv[]) {
    GtkWidget *window;
    GtkWidget *table;

    /* --- GTK initialization --- */
    gtk_init (&argc, &argv);

    /* --- Create the calculator window --- */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    /* --- Give the window a title. --- */
    gtk_window_set_title (GTK_WINDOW (window), "Calculator");

    /* --- Set the window size. --- */
    gtk_widget_set_size_request (window, 200, 200);

    /* --- We care if a key is pressed --- */
    g_signal_connect (G_OBJECT (window), "key-press-event",
                        G_CALLBACK (key_press), NULL);

    /* --- You should always remember to connect the delete event
     *     to the main window. --- */
    g_signal_connect (G_OBJECT (window), "destroy",
                        G_CALLBACK (gtk_main_quit), NULL);

    /* --- Create a 5x5 table for the items in the calculator. --- */
    table = gtk_grid_new (); 
    gtk_grid_set_column_homogeneous(GTK_GRID (table), TRUE);
    gtk_grid_set_row_homogeneous(GTK_GRID (table), TRUE);

    /* --- Create the calculator buttons. --- */
    createCalculatorButtons (table);

    /* --- Create the calculator LED --- */
    label = gtk_label_new ("0");
    gtk_widget_set_halign(GTK_WIDGET (label), GTK_ALIGN_END);
    gtk_widget_set_valign(GTK_WIDGET (label), GTK_ALIGN_CENTER);

    /* --- Add label to the table --- */
    gtk_grid_attach (GTK_GRID (table), label, 
                              0, 0, 5, 1);
    gtk_widget_show (label);
  
    /* --- Make them visible --- */
    gtk_container_add (GTK_CONTAINER (window), table);
    gtk_widget_show (table);
    gtk_widget_show (window);

    /* --- Grab focus for the keystrokes --- */
    //gtk_widget_grab_focus (buttonList[0].widget);

    gtk_main ();
    return (0);
}
Exemplo n.º 8
0
static void
gnucash_register_init (GnucashRegister *g_reg)
{
    GtkGrid *table = GTK_GRID(g_reg);

    gtk_widget_set_can_focus (GTK_WIDGET(table), FALSE);
    gtk_widget_set_can_default (GTK_WIDGET(table), FALSE);

    // This sets a style class for when Gtk+ version is less than 3.20
    gnc_widget_set_css_name (GTK_WIDGET(g_reg), "register");

    gtk_grid_set_row_homogeneous (GTK_GRID(table), FALSE);
    gtk_grid_set_column_homogeneous (GTK_GRID(table), FALSE);
}
Exemplo n.º 9
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  /* Declare variables */
  GtkWidget *window;
  GtkWidget *label;
  GtkWidget *grid;
  GtkWidget *spin_button;
  GtkAdjustment *adjustment;


  /* Create a window with a title, a border width, and a default size */
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "SpinButton Example");
  gtk_window_set_default_size (GTK_WINDOW (window), 210, 70);
  gtk_container_set_border_width (GTK_CONTAINER (window), 5);

  /* Create a label to be shown in the window */
  label = gtk_label_new ("Choose a number");

  /* Create an adjustment representing an adjustable bounded value */
  adjustment = gtk_adjustment_new (0, 0, 100, 1, 0, 0);


  /* Create a spin button that is to be as wide as possible */
  spin_button = gtk_spin_button_new (adjustment, 1, 0);
  gtk_widget_set_hexpand (spin_button, TRUE);
  
  /* Connecting the "value-changed" signal for the spinbutton 
   * to the appropriate callback function. 
   */
  g_signal_connect (spin_button, 
                    "value-changed", 
                    G_CALLBACK (spin_clicked), 
                    label);


  /* Create a grid and arrange everything accordingly */
  grid = gtk_grid_new ();
  gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
  gtk_grid_attach (GTK_GRID (grid), spin_button, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
  

  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_widget_show_all (window);
}
Exemplo n.º 10
0
void gui_init(dt_lib_module_t *self)
{
  dt_lib_select_t *d = (dt_lib_select_t *)malloc(sizeof(dt_lib_select_t));
  self->data = d;
  self->widget = gtk_grid_new();
  GtkGrid *grid = GTK_GRID(self->widget);
  gtk_grid_set_row_spacing(grid, DT_PIXEL_APPLY_DPI(5));
  gtk_grid_set_column_spacing(grid, DT_PIXEL_APPLY_DPI(5));
  gtk_grid_set_column_homogeneous(grid, TRUE);
  int line = 0;
  GtkWidget *button;

  button = gtk_button_new_with_label(_("select all"));
  ellipsize_button(button);
  d->select_all_button = button;
  gtk_widget_set_tooltip_text(button, _("select all images in current collection"));
  gtk_grid_attach(grid, button, 0, line, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(0));

  button = gtk_button_new_with_label(_("select none"));
  ellipsize_button(button);
  d->select_none_button = button;
  gtk_widget_set_tooltip_text(button, _("clear selection"));
  gtk_grid_attach(grid, button, 1, line++, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(1));


  button = gtk_button_new_with_label(_("invert selection"));
  ellipsize_button(button);
  gtk_widget_set_tooltip_text(button, _("select unselected images\nin current collection"));
  d->select_invert_button = button;
  gtk_grid_attach(grid, button, 0, line, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(2));

  button = gtk_button_new_with_label(_("select film roll"));
  ellipsize_button(button);
  d->select_film_roll_button = button;
  gtk_widget_set_tooltip_text(button, _("select all images which are in the same\nfilm roll as the selected images"));
  gtk_grid_attach(grid, button, 1, line++, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(3));


  button = gtk_button_new_with_label(_("select untouched"));
  ellipsize_button(button);
  d->select_untouched_button = button;
  gtk_widget_set_tooltip_text(button, _("select untouched images in\ncurrent collection"));
  gtk_grid_attach(grid, button, 0, line, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(4));
}
static GtkGrid*
kolab_backend_sync_conflict_ui_grid_new (void)
{
	GtkGrid *grid = NULL;

	grid = GTK_GRID (gtk_grid_new ());
	gtk_grid_set_row_homogeneous (grid, FALSE);
	gtk_grid_set_row_spacing (grid, 6);
	gtk_grid_set_column_homogeneous (grid, FALSE);
	gtk_grid_set_column_spacing (grid, 16);
	gtk_container_set_border_width (GTK_CONTAINER (grid), KOLAB_SYNC_CONFLICT_WIDGET_BORDER_WIDTH);
	/* gtk_container_set_resize_mode (GTK_CONTAINER (grid), GTK_RESIZE_QUEUE); */

	return grid;
}
Exemplo n.º 12
0
Arquivo: vfo.c Projeto: g0orx/pihpsdr
static gboolean
vfo_press_event_cb (GtkWidget *widget,
               GdkEventButton *event,
               gpointer        data)
{

  if((int)event->x < (my_width/2)) {
    lock_cb(NULL,NULL);
  } else {
    GtkWidget *dialog=gtk_dialog_new_with_buttons("Step",GTK_WINDOW(parent_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);

    GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    GtkWidget *grid=gtk_grid_new();

    gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
    gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);

    GtkWidget *step_rb=NULL;
    int i=0;
    while(steps[i]!=0) {
      if(i==0) {
          step_rb=gtk_radio_button_new_with_label(NULL,step_labels[i]);
      } else {
          step_rb=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(step_rb),step_labels[i]);
      }
      gtk_widget_override_font(step_rb, pango_font_description_from_string("FreeMono 18"));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (step_rb), steps[i]==step);
      gtk_widget_show(step_rb);
      gtk_grid_attach(GTK_GRID(grid),step_rb,i%5,i/5,1,1);
      g_signal_connect(step_rb,"pressed",G_CALLBACK(vfo_step_select_cb),(gpointer *)i);
      i++;
    }
  
    gtk_container_add(GTK_CONTAINER(content),grid);
  
    GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Close",GTK_RESPONSE_OK);
    gtk_widget_override_font(close_button, pango_font_description_from_string("FreeMono 18"));
    gtk_widget_show_all(dialog);

    g_signal_connect_swapped (dialog,
                             "response",
                             G_CALLBACK (gtk_widget_destroy),
                             dialog);
  
    int result=gtk_dialog_run(GTK_DIALOG(dialog));
  }
  return TRUE;
}
Exemplo n.º 13
0
static GtkWidget* remmina_init_dialog_container_new(guint table_rows, guint table_columns, gboolean homogeneous)
{
	GtkWidget *table;
#if GTK_VERSION == 3
	table = gtk_grid_new();
	gtk_widget_show(table);
	gtk_grid_set_row_spacing(GTK_GRID(table), 8);
	gtk_grid_set_column_spacing(GTK_GRID(table), 8);
	gtk_grid_set_column_homogeneous (GTK_GRID(table), homogeneous);
#elif GTK_VERSION == 2
	table = gtk_table_new(table_rows, table_columns, homogeneous);
	gtk_widget_show(table);
	gtk_table_set_row_spacings(GTK_TABLE(table), 8);
	gtk_table_set_col_spacings(GTK_TABLE(table), 8);
#endif
	return table;
}
Exemplo n.º 14
0
void exit_menu(GtkWidget *parent) {
  parent_window=parent;

  dialog=gtk_dialog_new();
  gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window));
  gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE);

  GdkRGBA color;
  color.red = 1.0;
  color.green = 1.0;
  color.blue = 1.0;
  color.alpha = 1.0;
  gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color);

  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));

  GtkWidget *grid=gtk_grid_new();
  gtk_grid_set_column_spacing (GTK_GRID(grid),10);
  gtk_grid_set_row_spacing (GTK_GRID(grid),10);
  gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
  gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);

  GtkWidget *close_b=gtk_button_new_with_label("Close");
  g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
  gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);

  GtkWidget *exit_b=gtk_button_new_with_label("Exit");
  g_signal_connect (exit_b, "pressed", G_CALLBACK(exit_cb), NULL);
  gtk_grid_attach(GTK_GRID(grid),exit_b,0,1,1,1);

  GtkWidget *reboot_b=gtk_button_new_with_label("Reboot");
  g_signal_connect (reboot_b, "pressed", G_CALLBACK(reboot_cb), NULL);
  gtk_grid_attach(GTK_GRID(grid),reboot_b,1,1,1,1);

  GtkWidget *shutdown_b=gtk_button_new_with_label("Shutdown");
  g_signal_connect (shutdown_b, "pressed", G_CALLBACK(shutdown_cb), NULL);
  gtk_grid_attach(GTK_GRID(grid),shutdown_b,2,1,1,1);

  gtk_container_add(GTK_CONTAINER(content),grid);

  sub_menu=dialog;

  gtk_widget_show_all(dialog);

}
Exemplo n.º 15
0
void table_new(gint width, gboolean same, gboolean labels)
{
    /* WARNING: clobbers all the current_table_ vars. */
#if GTK_CHECK_VERSION(3, 0, 0)
    current_table = GTK_GRID(gtk_grid_new());
    gtk_grid_set_row_spacing(current_table,8);
    gtk_grid_set_column_spacing(current_table,8);
    gtk_grid_set_row_homogeneous(current_table,same);
    gtk_grid_set_column_homogeneous(current_table,same);
#else
    current_table = GTK_TABLE(gtk_table_new(width,1,same));
    gtk_table_set_row_spacings(current_table,8);
    gtk_table_set_col_spacings(current_table,8);
#endif
    current_table_col = labels?1:0;
    current_table_row = 0;
    current_table_width = width;
}
Exemplo n.º 16
0
void splash_show(char* image_name,int width,int height,int full_screen)
{
  GtkWidget  *image;
  splash_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  if(full_screen) {
    gtk_window_fullscreen(GTK_WINDOW(splash_window));
  }
  gtk_widget_set_size_request(splash_window, width, height);
  gtk_window_set_position(GTK_WINDOW(splash_window),GTK_WIN_POS_CENTER_ALWAYS);
  gtk_window_set_resizable(GTK_WINDOW(splash_window), FALSE);


  GtkWidget *grid = gtk_grid_new();
  gtk_grid_set_row_homogeneous(GTK_GRID(grid),FALSE);
  gtk_grid_set_column_homogeneous(GTK_GRID(grid),FALSE);

  image=gtk_image_new_from_file(image_name);
  //gtk_container_add(GTK_CONTAINER(splash_window), image);
  gtk_grid_attach(GTK_GRID(grid), image, 0, 0, 1, 4);
  g_signal_connect (splash_window,"configure-event",
            G_CALLBACK (splash_configure_event_cb), NULL);

  char build[64];
  sprintf(build,"build: %s %s",build_date, build_version);

  GtkWidget *pi_label=gtk_label_new("pihpsdr by John Melton g0orx/n6lyt");
  gtk_label_set_justify(GTK_LABEL(pi_label),GTK_JUSTIFY_LEFT);
  gtk_widget_show(pi_label);
  gtk_grid_attach(GTK_GRID(grid),pi_label,1,0,1,1);
  GtkWidget *build_date_label=gtk_label_new(build);
  gtk_label_set_justify(GTK_LABEL(build_date_label),GTK_JUSTIFY_LEFT);
  gtk_widget_show(build_date_label);
  gtk_grid_attach(GTK_GRID(grid),build_date_label,1,1,1,1);

  status=gtk_label_new("");
  gtk_label_set_justify(GTK_LABEL(status),GTK_JUSTIFY_LEFT);
  gtk_widget_override_font(status, pango_font_description_from_string("FreeMono 18"));
  gtk_widget_show(status);
  //gtk_container_add(GTK_CONTAINER(splash_window), status);
  gtk_grid_attach(GTK_GRID(grid), status, 1, 3, 1, 1);

  gtk_container_add(GTK_CONTAINER(splash_window), grid);
  gtk_widget_show_all (splash_window);
}
Exemplo n.º 17
0
static void band_cb(GtkWidget *widget, gpointer data) {
  GtkWidget *dialog=gtk_dialog_new_with_buttons("Band",GTK_WINDOW(parent_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  GtkWidget *grid=gtk_grid_new();
  gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
  gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
  GtkWidget *b;
  int i;
  for(i=0;i<BANDS;i++) {
#ifdef LIMESDR
    if(protocol!=LIMESDR_PROTOCOL) {
      if(i>=band70 && i<=band3400) {
        continue;
      }
    }
#endif
    BAND* band=band_get_band(i);
    GtkWidget *b=gtk_button_new_with_label(band->title);
    gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white);
    //gtk_widget_override_font(b, pango_font_description_from_string("Arial 20"));
    if(i==band_get_current()) {
      gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &gray);
      last_band=b;
    }
    gtk_widget_show(b);
    gtk_grid_attach(GTK_GRID(grid),b,i%5,i/5,1,1);
    g_signal_connect(b,"clicked",G_CALLBACK(band_select_cb),(gpointer *)i);
  }
  
  gtk_container_add(GTK_CONTAINER(content),grid);

  GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Close",GTK_RESPONSE_OK);
  //gtk_widget_override_font(close_button, pango_font_description_from_string("Arial 20"));
  gtk_widget_show_all(dialog);

  g_signal_connect_swapped (dialog,
                           "response",
                           G_CALLBACK (gtk_widget_destroy),
                           dialog);

  int result=gtk_dialog_run(GTK_DIALOG(dialog));
  
}
Exemplo n.º 18
0
static void exit_cb(GtkWidget *widget, gpointer data) {

  radioSaveState();

  GtkWidget *dialog=gtk_dialog_new_with_buttons("Exit",GTK_WINDOW(parent_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);

  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  GtkWidget *grid=gtk_grid_new();

  gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
  gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);

  GtkWidget *label=gtk_label_new("Exit?");
  //gtk_widget_override_font(label, pango_font_description_from_string("Arial 18"));
  gtk_widget_show(label);
  gtk_grid_attach(GTK_GRID(grid),label,1,0,1,1);

  GtkWidget *b_yes=gtk_button_new_with_label("Yes");
  //gtk_widget_override_font(b_yes, pango_font_description_from_string("Arial 18"));
  gtk_widget_show(b_yes);
  gtk_grid_attach(GTK_GRID(grid),b_yes,0,1,1,1);
  g_signal_connect(b_yes,"pressed",G_CALLBACK(yes_cb),NULL);

  GtkWidget *b_halt=gtk_button_new_with_label("Halt System");
  //gtk_widget_override_font(b_halt, pango_font_description_from_string("Arial 18"));
  gtk_widget_show(b_halt);
  gtk_grid_attach(GTK_GRID(grid),b_halt,2,1,1,1);
  g_signal_connect(b_halt,"pressed",G_CALLBACK(halt_cb),NULL);

  gtk_container_add(GTK_CONTAINER(content),grid);
  GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Cancel",GTK_RESPONSE_OK);
  //gtk_widget_override_font(close_button, pango_font_description_from_string("Arial 18"));
  gtk_widget_show_all(dialog);

  g_signal_connect_swapped (dialog,
                           "response",
                           G_CALLBACK (gtk_widget_destroy),
                           dialog);

  int result=gtk_dialog_run(GTK_DIALOG(dialog));

}
Exemplo n.º 19
0
static void
open_alignment_window (void)
{
  GtkWidget *grid;
  int i;
  GEnumClass *align_class;

  test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (test_window), "Alignment");

  g_signal_connect (test_window, "delete-event",
                    G_CALLBACK (gtk_main_quit), test_window);

  gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (test_window), 500, 500);

  align_class = g_type_class_peek (GTK_TYPE_ALIGN);

  grid = gtk_grid_new ();
  gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
  gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);

  gtk_container_add (GTK_CONTAINER (test_window), grid);

  for (i = 0; i < align_class->n_values; ++i)
    {
      int j;
      for (j = 0; j < align_class->n_values; ++j)
        {
          GtkWidget *child =
            create_aligned(align_class->values[i].value,
                           align_class->values[j].value);

          gtk_grid_attach (GTK_GRID (grid), child, i, j, 1, 1);
        }
    }

  gtk_widget_show_all (test_window);
}
Exemplo n.º 20
0
static void filter_cb(GtkWidget *widget, gpointer data) {
  BANDSTACK_ENTRY *entry=bandstack_entry_get_current();
  FILTER* band_filters=filters[entry->mode];
  GtkWidget *dialog=gtk_dialog_new_with_buttons("Mode",GTK_WINDOW(parent_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  GtkWidget *grid=gtk_grid_new();
  gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
  gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);

  GtkWidget *b;
  int i;
  for(i=0;i<FILTERS;i++) {
    FILTER* band_filter=&band_filters[i];
    GtkWidget *b=gtk_button_new_with_label(band_filters[i].title);
    //gtk_widget_override_font(b, pango_font_description_from_string("Arial 20"));
    if(i==entry->filter) {
      gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &gray);
      last_filter=b;
    } else {
      gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white);
    }
    gtk_widget_show(b);
    gtk_grid_attach(GTK_GRID(grid),b,i%5,i/5,1,1);
    g_signal_connect(b,"pressed",G_CALLBACK(filter_select_cb),(gpointer *)i);
  }
  gtk_container_add(GTK_CONTAINER(content),grid);
  GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Close",GTK_RESPONSE_OK);
  //gtk_widget_override_font(close_button, pango_font_description_from_string("Arial 20"));
  gtk_widget_show_all(dialog);

  g_signal_connect_swapped (dialog,
                           "response",
                           G_CALLBACK (gtk_widget_destroy),
                           dialog);

  int result=gtk_dialog_run(GTK_DIALOG(dialog));

}
Exemplo n.º 21
0
/* **************************
 * ***** DISPLAY DIALOG *****
 * **************************
 */
static void display_dialog()
{
    TRACE(stdout, "%s", "Displaying button panel...");

    GtkWidget *window         = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    GtkWidget *grid           = gtk_grid_new();
    GtkWidget *label          = gtk_label_new("Choose an action for the Elysia Login Manager.");
    GtkWidget *blank          = gtk_label_new(" ");
    GtkWidget *refresh_button = gtk_button_new_with_label("Restart");
    GtkWidget *quit_button    = gtk_button_new_with_label("Quit");
    GtkWidget *cancel_button  = gtk_button_new_with_label("Cancel");
    struct elyapp app;
    setup_app_settings(&app, PANEL_DIA_CONFIG, NULL, NULL);
    setup_config_pos(&app);
    set_app_pos(&app);
    gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
    gtk_grid_attach(GTK_GRID(grid), label,          0, 0, 5, 1);
    gtk_grid_attach(GTK_GRID(grid), blank,          0, 1, 5, 1);
    gtk_grid_attach(GTK_GRID(grid), refresh_button, 0, 2, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), cancel_button,  3, 2, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), quit_button,    4, 2, 1, 1);
    gtk_container_add(GTK_CONTAINER(window), grid);
    gtk_widget_show(label);
    gtk_widget_show(blank);    
    gtk_widget_show(refresh_button);
    gtk_widget_show(quit_button);
    gtk_widget_show(cancel_button);
    gtk_widget_show(grid);
    gtk_widget_show(window);
    g_signal_connect(G_OBJECT(refresh_button), "clicked", G_CALLBACK(refresh_ely),   NULL);
    g_signal_connect(G_OBJECT(quit_button),    "clicked", G_CALLBACK(quit_ely),      NULL);
    g_signal_connect(G_OBJECT(cancel_button),  "clicked", G_CALLBACK(cancel_ely),    window);
    g_signal_connect(window,                   "destroy", G_CALLBACK(gtk_main_quit), NULL);

    TRACE(stdout, "%s", "Done displaying button panel.");
}
Exemplo n.º 22
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *grid;
  GtkWidget *window;
  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *label3;
  GtkWidget *hseparator;
  GtkWidget *vseparator;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Separator Example");

  label1 = gtk_label_new ("Below, a horizontal separator.");
  label2 = gtk_label_new ("On the right, a vertical separator.");
  label3 = gtk_label_new ("On the left, a vertical separator.");

  vseparator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  hseparator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

  grid = gtk_grid_new ();

  gtk_grid_attach (GTK_GRID (grid), label1, 0, 0, 3, 1);
  gtk_grid_attach (GTK_GRID (grid), hseparator, 0, 1, 3, 1);
  gtk_grid_attach (GTK_GRID (grid), label2, 0, 2, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), vseparator, 1, 2, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), label3, 2, 2, 1, 1);

  gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);

  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_widget_show_all (window);
}
Exemplo n.º 23
0
static GtkWidget *create_editor_widgets(radio_conf_t * conf)
{
    GtkWidget      *table;
    GtkWidget      *label;

    table = gtk_grid_new();
    gtk_container_set_border_width(GTK_CONTAINER(table), 5);
    gtk_grid_set_column_homogeneous(GTK_GRID(table), FALSE);
    gtk_grid_set_row_homogeneous(GTK_GRID(table), FALSE);
    gtk_grid_set_column_spacing(GTK_GRID(table), 5);
    gtk_grid_set_row_spacing(GTK_GRID(table), 5);

    /* Config name */
    label = gtk_label_new(_("Name"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);

    name = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(name), 25);
    g_signal_connect(name, "changed", G_CALLBACK(name_changed), NULL);
    gtk_widget_set_tooltip_text(name,
                                _("Enter a short name for this configuration, "
                                  "e.g. IC910-1.\n"
                                  "Allowed characters: "
                                  "0..9, a..z, A..Z, - and _"));
    gtk_grid_attach(GTK_GRID(table), name, 1, 0, 3, 1);

    /* Host */
    label = gtk_label_new(_("Host"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);

    host = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(host), 50);
    gtk_entry_set_text(GTK_ENTRY(host), "localhost");
    gtk_widget_set_tooltip_text(host,
                                _("Enter the host where rigctld is running. "
                                  "You can use both host name and IP address, "
                                  "e.g. 192.168.1.100\n\n"
                                  "If gpredict and rigctld are running on the "
                                  "same computer use localhost"));
    gtk_grid_attach(GTK_GRID(table), host, 1, 1, 3, 1);

    /* port */
    label = gtk_label_new(_("Port"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);

    port = gtk_spin_button_new_with_range(1024, 65535, 1);
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), 4532);
    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(port), 0);
    gtk_widget_set_tooltip_text(port,
                                _("Enter the port number where rigctld is "
                                  "listening"));
    gtk_grid_attach(GTK_GRID(table), port, 1, 2, 1, 1);

    /* radio type */
    label = gtk_label_new(_("Radio type"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    //gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
    gtk_grid_attach(GTK_GRID(table), label, 0, 3, 1, 1);

    type = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("RX only"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("TX only"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("Simplex TRX"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type), _("Duplex TRX"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type),
                                   _("FT817/857/897 (auto)"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type),
                                   _("FT817/857/897 (manual)"));
    gtk_combo_box_set_active(GTK_COMBO_BOX(type), RIG_TYPE_RX);
    g_signal_connect(type, "changed", G_CALLBACK(type_changed), NULL);
    gtk_widget_set_tooltip_markup(type,
                                  _("<b>RX only:</b>  The radio shall only be "
                                    "used as receiver. If <i>Monitor PTT "
                                    "status</i> is checked the doppler tuning "
                                    "will be suspended while PTT is ON "
                                    "(manual TX). If not, the controller will "
                                    "always perform doppler tuning and "
                                    "you cannot use the same RIG for uplink.\n\n"
                                    "<b>TX only:</b>  The radio shall only be "
                                    "used for uplink. If <i>Monitor PTT status</i>"
                                    " is checked the doppler tuning will be "
                                    "suspended while PTT is OFF (manual RX).\n\n"
                                    "<b>Simplex TRX:</b>  The radio should be "
                                    "used for both up- and downlink but in "
                                    "simplex mode only. This option requires "
                                    "that the PTT status is monitored (otherwise "
                                    "gpredict cannot know whether to tune the "
                                    "RX or the TX).\n\n"
                                    "<b>Duplex:</b>  The radio is a full duplex "
                                    "radio, such as the IC910H. Gpredict will "
                                    "be continuously tuning both uplink and "
                                    "downlink simultaneously and not care about "
                                    "PTT setting.\n\n"
                                    "<b>FT817/857/897 (auto):</b> "
                                    "This is a special mode that can be used with "
                                    "YAESU FT-817, 857 and 897 radios. These radios"
                                    " do not allow computer control while in TX mode."
                                    " Therefore, TX Doppler correction is applied "
                                    "while the radio is in RX mode by toggling "
                                    "between VFO A/B.\n\n"
                                    "<b>FT817/857/897 (manual):</b> "
                                    "This is similar to the previous mode except"
                                    " that switching to TX is done by pressing the"
                                    " SPACE key on the keyboard. Gpredict will "
                                    "then update the TX Doppler before actually"
                                    " switching to TX."));
    gtk_grid_attach(GTK_GRID(table), type, 1, 3, 2, 1);

    /* ptt */
    label = gtk_label_new(_("PTT status"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 4, 1, 1);

    ptt = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(ptt), _("None"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(ptt), _("Read PTT"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(ptt), _("Read DCD"));
    gtk_combo_box_set_active(GTK_COMBO_BOX(ptt), 0);
    g_signal_connect(ptt, "changed", G_CALLBACK(ptt_changed), NULL);
    gtk_widget_set_tooltip_markup(ptt,
                                  _("Select PTT type.\n\n"
                                    "<b>None:</b>\nDon't read PTT status from this radio.\n\n"
                                    "<b>Read PTT:</b>\nRead PTT status using get_ptt CAT command. "
                                    "You have to check that your radio and hamlib supports this.\n\n"
                                    "<b>Read DCD:</b>\nRead PTT status using get_dcd command. "
                                    "This can be used if your radio does not support the read_ptt "
                                    "CAT command and you have a special interface that can "
                                    "read squelch status and send it via CTS."));
    gtk_grid_attach(GTK_GRID(table), ptt, 1, 4, 2, 1);

    /* VFO Up/Down */
    label = gtk_label_new(_("VFO Up/Down"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 5, 1, 1);

    vfo = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(vfo), _("Not applicable"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(vfo),
                                   _("MAIN \342\206\221 / SUB \342\206\223"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(vfo),
                                   _("SUB \342\206\221 / MAIN \342\206\223"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(vfo),
                                   _("A \342\206\221 / B \342\206\223"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(vfo),
                                   _("B \342\206\221 / A \342\206\223"));
    gtk_combo_box_set_active(GTK_COMBO_BOX(vfo), 0);
    g_signal_connect(vfo, "changed", G_CALLBACK(vfo_changed), NULL);
    gtk_widget_set_tooltip_markup(vfo,
                                  _
                                  ("Select which VFO to use for uplink and downlink. "
                                   "This setting is used for full-duplex radios only, "
                                   "such as the IC-910H, FT-847 and the TS-2000.\n\n"
                                   "<b>IC-910H:</b> MAIN\342\206\221 / SUB\342\206\223\n"
                                   "<b>FT-847:</b> SUB\342\206\221 / MAIN\342\206\223\n"
                                   "<b>TS-2000:</b> B\342\206\221 / A\342\206\223"));
    gtk_grid_attach(GTK_GRID(table), vfo, 1, 5, 2, 1);

    /* Downconverter LO frequency */
    label = gtk_label_new(_("LO Down"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 6, 1, 1);

    lo = gtk_spin_button_new_with_range(-10000, 10000, 1);
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(lo), 0);
    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(lo), 0);
    gtk_widget_set_tooltip_text(lo,
                                _
                                ("Enter the frequency of the local oscillator "
                                 " of the downconverter, if any."));
    gtk_grid_attach(GTK_GRID(table), lo, 1, 6, 2, 1);

    label = gtk_label_new(_("MHz"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 3, 6, 1, 1);

    /* Upconverter LO frequency */
    label = gtk_label_new(_("LO Up"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 7, 1, 1);

    loup = gtk_spin_button_new_with_range(-10000, 10000, 1);
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(loup), 0);
    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(loup), 0);
    gtk_widget_set_tooltip_text(loup,
                                _
                                ("Enter the frequency of the local oscillator "
                                 "of the upconverter, if any."));
    gtk_grid_attach(GTK_GRID(table), loup, 1, 7, 2, 1);

    label = gtk_label_new(_("MHz"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 3, 7, 1, 1);

    /* AOS / LOS signalling */
    label = gtk_label_new(_("Signalling"));
    g_object_set(label, "xalign", 1.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 8, 1, 1);

    sigaos = gtk_check_button_new_with_label(_("AOS"));
    gtk_grid_attach(GTK_GRID(table), sigaos, 1, 8, 1, 1);
    gtk_widget_set_tooltip_text(sigaos,
                                _("Enable AOS signalling for this radio."));

    siglos = gtk_check_button_new_with_label(_("LOS"));
    gtk_grid_attach(GTK_GRID(table), siglos, 2, 8, 1, 1);
    gtk_widget_set_tooltip_text(siglos,
                                _("Enable LOS signalling for this radio."));

    if (conf->name != NULL)
        update_widgets(conf);

    gtk_widget_show_all(table);

    return table;
}
Exemplo n.º 24
0
bool
zathura_init(zathura_t* zathura)
{
  if (zathura == NULL) {
    return false;
  }

  /* create zathura (config/data) directory */
  if (g_mkdir_with_parents(zathura->config.config_dir, 0771) == -1) {
    girara_error("Could not create '%s': %s", zathura->config.config_dir, strerror(errno));
  }

  if (g_mkdir_with_parents(zathura->config.data_dir, 0771) == -1) {
    girara_error("Could not create '%s': %s", zathura->config.data_dir, strerror(errno));
  }

  /* load plugins */
  zathura_plugin_manager_load(zathura->plugins.manager);

  /* configuration */
  config_load_default(zathura);

  /* load global configuration files */
  char* config_path = girara_get_xdg_path(XDG_CONFIG_DIRS);
  girara_list_t* config_dirs = girara_split_path_array(config_path);
  ssize_t size = girara_list_size(config_dirs) - 1;
  for (; size >= 0; --size) {
    const char* dir = girara_list_nth(config_dirs, size);
    char* file = g_build_filename(dir, ZATHURA_RC, NULL);
    config_load_file(zathura, file);
    g_free(file);
  }
  girara_list_free(config_dirs);
  g_free(config_path);

  config_load_file(zathura, GLOBAL_RC);

  /* load local configuration files */
  char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);
  config_load_file(zathura, configuration_file);
  g_free(configuration_file);

  /* UI */
  if (girara_session_init(zathura->ui.session, "zathura") == false) {
    goto error_free;
  }

  /* girara events */
  zathura->ui.session->events.buffer_changed  = cb_buffer_changed;
  zathura->ui.session->events.unknown_command = cb_unknown_command;

  /* zathura signals */
  zathura->signals.refresh_view = g_signal_new("refresh-view",
                                               GTK_TYPE_WIDGET,
                                               G_SIGNAL_RUN_LAST,
                                               0,
                                               NULL,
                                               NULL,
                                               g_cclosure_marshal_generic,
                                               G_TYPE_NONE,
                                               1,
                                               G_TYPE_POINTER);

  g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "refresh-view",
                   G_CALLBACK(cb_refresh_view), zathura);

  /* page view */
#if (GTK_MAJOR_VERSION == 3)
  zathura->ui.page_widget = gtk_grid_new();
  gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
  gtk_grid_set_column_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
#else
  zathura->ui.page_widget = gtk_table_new(0, 0, TRUE);
#endif
  if (zathura->ui.page_widget == NULL) {
    goto error_free;
  }

  g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "size-allocate", G_CALLBACK(cb_view_resized), zathura);

  GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(
                 GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));

  /* Connect hadjustment signals */
  g_signal_connect(G_OBJECT(hadjustment), "value-changed",
      G_CALLBACK(cb_view_hadjustment_value_changed), zathura);
  g_signal_connect(G_OBJECT(hadjustment), "changed",
      G_CALLBACK(cb_view_hadjustment_changed), zathura);

  GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(
                 GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));

  /* Connect vadjustment signals */
  g_signal_connect(G_OBJECT(vadjustment), "value-changed",
      G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
  g_signal_connect(G_OBJECT(vadjustment), "changed",
      G_CALLBACK(cb_view_vadjustment_changed), zathura);

  /* page view alignment */
  zathura->ui.page_widget_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
  if (zathura->ui.page_widget_alignment == NULL) {
    goto error_free;
  }
  gtk_container_add(GTK_CONTAINER(zathura->ui.page_widget_alignment), zathura->ui.page_widget);

#if (GTK_MAJOR_VERSION == 3)
  gtk_widget_set_hexpand_set(zathura->ui.page_widget_alignment, TRUE);
  gtk_widget_set_hexpand(zathura->ui.page_widget_alignment, FALSE);
  gtk_widget_set_vexpand_set(zathura->ui.page_widget_alignment, TRUE);
  gtk_widget_set_vexpand(zathura->ui.page_widget_alignment, FALSE);
#endif


  gtk_widget_show(zathura->ui.page_widget);

  /* statusbar */
  zathura->ui.statusbar.file = girara_statusbar_item_add(zathura->ui.session, TRUE, TRUE, TRUE, NULL);
  if (zathura->ui.statusbar.file == NULL) {
    goto error_free;
  }

  zathura->ui.statusbar.buffer = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
  if (zathura->ui.statusbar.buffer == NULL) {
    goto error_free;
  }

  zathura->ui.statusbar.page_number = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
  if (zathura->ui.statusbar.page_number == NULL) {
    goto error_free;
  }

  girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, _("[No name]"));

  /* signals */
  g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), zathura);

  /* database */
  char* database = NULL;
  girara_setting_get(zathura->ui.session, "database", &database);

  if (g_strcmp0(database, "plain") == 0) {
    girara_debug("Using plain database backend.");
    zathura->database = zathura_plaindatabase_new(zathura->config.data_dir);
#ifdef WITH_SQLITE
  } else if (g_strcmp0(database, "sqlite") == 0) {
    girara_debug("Using sqlite database backend.");
    char* tmp = g_build_filename(zathura->config.data_dir, "bookmarks.sqlite", NULL);
    zathura->database = zathura_sqldatabase_new(tmp);
    g_free(tmp);
#endif
  } else {
    girara_error("Database backend '%s' is not supported.", database);
  }
  g_free(database);

  if (zathura->database == NULL) {
    girara_error("Unable to initialize database. Bookmarks won't be available.");
  } else {
    g_object_set(zathura->ui.session->command_history, "io", zathura->database, NULL);
  }

  /* bookmarks */
  zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
                                 (girara_free_function_t) zathura_bookmark_free);

  /* jumplist */

  int jumplist_size = 20;
  girara_setting_get(zathura->ui.session, "jumplist-size", &jumplist_size);

  zathura->jumplist.max_size = jumplist_size < 0 ? 0 : jumplist_size;
  zathura->jumplist.list = NULL;
  zathura->jumplist.size = 0;
  zathura->jumplist.cur = NULL;

  return true;

error_free:

  if (zathura->ui.page_widget != NULL) {
    g_object_unref(zathura->ui.page_widget);
  }

  if (zathura->ui.page_widget_alignment != NULL) {
    g_object_unref(zathura->ui.page_widget_alignment);
  }

  return false;
}
Exemplo n.º 25
0
static void
photos_properties_dialog_constructed (GObject *object)
{
  PhotosPropertiesDialog *self = PHOTOS_PROPERTIES_DIALOG (object);
  GApplication *app;
  g_autoptr (GDateTime) date_modified = NULL;
  GtkStyleContext *context;
  GtkWidget *author_w = NULL;
  GtkWidget *content_area;
  GtkWidget *date_created_w = NULL;
  GtkWidget *date_modified_data;
  GtkWidget *date_modified_w;
  GtkWidget *dimensions_w = NULL;
  GtkWidget *exposure_time_w = NULL;
  GtkWidget *flash_w = NULL;
  GtkWidget *fnumber_w = NULL;
  GtkWidget *focal_length_w = NULL;
  GtkWidget *iso_speed_w = NULL;
  GtkWidget *item_type;
  GtkWidget *item_type_data;
  GtkWidget *modified_w = NULL;
  GtkWidget *source;
  GtkWidget *source_data;
  GtkWidget *title;
  GQuark equipment;
  GQuark flash;
  PhotosBaseItem *item;
  PhotosSearchContextState *state;
  const gchar *author;
  const gchar *location;
  const gchar *name;
  const gchar *type_description;
  g_autofree gchar *date_created_str = NULL;
  g_autofree gchar *date_modified_str = NULL;
  gdouble exposure_time;
  gdouble fnumber;
  gdouble focal_length;
  gdouble iso_speed;
  gint64 ctime;
  gint64 mtime;
  glong height;
  glong width;

  G_OBJECT_CLASS (photos_properties_dialog_parent_class)->constructed (object);

  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

  self->item_mngr = g_object_ref (state->item_mngr);

  {
    g_autoptr (GError) error = NULL;

    self->queue = photos_tracker_queue_dup_singleton (NULL, &error);
    if (G_UNLIKELY (error != NULL))
      g_warning ("Unable to create PhotosTrackerQueue: %s", error->message);
  }

  item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (self->item_mngr, self->urn));

  mtime = photos_base_item_get_mtime (item);
  date_modified = g_date_time_new_from_unix_local (mtime);
  date_modified_str = g_date_time_format (date_modified, "%c");

  ctime = photos_base_item_get_date_created (item);
  if (ctime >= 0)
    {
      g_autoptr (GDateTime) date_created = NULL;

      date_created = g_date_time_new_from_unix_local (ctime);
      date_created_str = g_date_time_format (date_created, "%c");
    }

  self->grid = gtk_grid_new ();
  gtk_widget_set_halign (self->grid, GTK_ALIGN_CENTER);
  gtk_widget_set_margin_start (self->grid, 24);
  gtk_widget_set_margin_end (self->grid, 24);
  gtk_widget_set_margin_bottom (self->grid, 12);
  gtk_widget_set_margin_top (self->grid, 12);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (self->grid), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_column_homogeneous (GTK_GRID (self->grid), TRUE);
  gtk_grid_set_column_spacing (GTK_GRID (self->grid), 24);
  gtk_grid_set_row_homogeneous (GTK_GRID (self->grid), TRUE);
  gtk_grid_set_row_spacing (GTK_GRID (self->grid), 6);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (self));
  gtk_box_pack_start (GTK_BOX (content_area), self->grid, TRUE, TRUE, 2);

  /* Translators: this is the label next to the photo title in the
   * properties dialog
   */
  title = gtk_label_new (C_("Document Title", "Title"));
  gtk_widget_set_halign (title, GTK_ALIGN_END);
  context = gtk_widget_get_style_context (title);
  gtk_style_context_add_class (context, "dim-label");
  gtk_container_add (GTK_CONTAINER (self->grid), title);

  author = photos_base_item_get_author (item);
  if (author != NULL && author[0] != '\0')
    {
      /* Translators: this is the label next to the photo author in
       * the properties dialog
       */
      author_w = gtk_label_new (C_("Document Author", "Author"));
      gtk_widget_set_halign (author_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (author_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), author_w);
    }

  source = gtk_label_new (_("Source"));
  gtk_widget_set_halign (source, GTK_ALIGN_END);
  context = gtk_widget_get_style_context (source);
  gtk_style_context_add_class (context, "dim-label");
  gtk_container_add (GTK_CONTAINER (self->grid), source);

  date_modified_w = gtk_label_new (_("Date Modified"));
  gtk_widget_set_halign (date_modified_w, GTK_ALIGN_END);
  context = gtk_widget_get_style_context (date_modified_w);
  gtk_style_context_add_class (context, "dim-label");
  gtk_container_add (GTK_CONTAINER (self->grid), date_modified_w);

  if (date_created_str != NULL)
    {
      date_created_w = gtk_label_new (_("Date Created"));
      gtk_widget_set_halign (date_created_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (date_created_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), date_created_w);
    }

  /* Translators: this is the label next to the photo type in the
   * properties dialog
   */
  item_type = gtk_label_new (C_("Document Type", "Type"));
  gtk_widget_set_halign (item_type, GTK_ALIGN_END);
  context = gtk_widget_get_style_context (item_type);
  gtk_style_context_add_class (context, "dim-label");
  gtk_container_add (GTK_CONTAINER (self->grid), item_type);

  height = (glong) photos_base_item_get_height (item);
  width = (glong) photos_base_item_get_width (item);
  if (height > 0 && width > 0)
    {
      dimensions_w = gtk_label_new (_("Dimensions"));
      gtk_widget_set_halign (dimensions_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (dimensions_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), dimensions_w);
    }

  location = photos_base_item_get_location (item);
  if (location != NULL && location[0] != '\0' && G_LIKELY (self->queue != NULL))
    {
      g_autoptr (PhotosQuery) query = NULL;

      self->location_w = gtk_label_new (_("Location"));
      gtk_widget_set_halign (self->location_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (self->location_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), self->location_w);

      query = photos_query_builder_location_query (state, location);
      photos_tracker_queue_select (self->queue,
                                   query,
                                   NULL,
                                   photos_properties_dialog_location_query_executed,
                                   g_object_ref (self),
                                   g_object_unref);
    }

  equipment = photos_base_item_get_equipment (item);
  if (equipment != 0)
    {
      self->camera_w = gtk_label_new (_("Camera"));
      gtk_widget_set_halign (self->camera_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (self->camera_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), self->camera_w);
    }

  exposure_time = photos_base_item_get_exposure_time (item);
  if (exposure_time > 0.0)
    {
      exposure_time_w = gtk_label_new (_("Exposure"));
      gtk_widget_set_halign (exposure_time_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (exposure_time_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), exposure_time_w);
    }

  fnumber = photos_base_item_get_fnumber (item);
  if (fnumber > 0.0)
    {
      fnumber_w = gtk_label_new (_("Aperture"));
      gtk_widget_set_halign (fnumber_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (fnumber_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), fnumber_w);
    }

  focal_length = photos_base_item_get_focal_length (item);
  if (focal_length > 0.0)
    {
      focal_length_w = gtk_label_new (_("Focal Length"));
      gtk_widget_set_halign (focal_length_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (focal_length_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), focal_length_w);
    }

  iso_speed = photos_base_item_get_iso_speed (item);
  if (iso_speed > 0.0)
    {
      iso_speed_w = gtk_label_new (_("ISO Speed"));
      gtk_widget_set_halign (iso_speed_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (iso_speed_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), iso_speed_w);
    }

  flash = photos_base_item_get_flash (item);
  if (flash != 0)
    {
      flash_w = gtk_label_new (_("Flash"));
      gtk_widget_set_halign (flash_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (flash_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), flash_w);
    }

  if (!photos_base_item_is_collection (item))
    {
      modified_w = gtk_label_new (_("Modifications"));
      gtk_widget_set_halign (modified_w, GTK_ALIGN_END);
      gtk_widget_set_valign (modified_w, GTK_ALIGN_BASELINE);
      gtk_widget_set_vexpand (modified_w, TRUE);
      context = gtk_widget_get_style_context (modified_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (self->grid), modified_w);
    }

  name = photos_base_item_get_name (item);

  if (PHOTOS_IS_LOCAL_ITEM (item))
    {
      self->title_entry = gtk_entry_new ();
      gtk_widget_set_halign (self->title_entry, GTK_ALIGN_START);
      gtk_widget_set_hexpand (self->title_entry, TRUE);
      gtk_entry_set_activates_default (GTK_ENTRY (self->title_entry), TRUE);
      gtk_entry_set_text (GTK_ENTRY (self->title_entry), name);
      gtk_entry_set_width_chars (GTK_ENTRY (self->title_entry), 40);
      gtk_editable_set_editable (GTK_EDITABLE (self->title_entry), TRUE);

      g_signal_connect (self->title_entry,
                        "changed",
                        G_CALLBACK (photos_properties_dialog_title_entry_changed),
                        self);
    }
  else
    {
      self->title_entry = gtk_label_new (name);
      gtk_widget_set_halign (self->title_entry, GTK_ALIGN_START);
      gtk_label_set_ellipsize (GTK_LABEL (self->title_entry), PANGO_ELLIPSIZE_END);
      gtk_label_set_max_width_chars (GTK_LABEL (self->title_entry), 40);
    }

  gtk_grid_attach_next_to (GTK_GRID (self->grid), self->title_entry, title, GTK_POS_RIGHT, 2, 1);

  if (author_w != NULL)
    {
      GtkWidget *author_data;

      author_data = gtk_label_new (author);
      gtk_widget_set_halign (author_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), author_data, author_w, GTK_POS_RIGHT, 2, 1);
    }

  source_data = photos_base_item_get_source_widget (item);
  gtk_grid_attach_next_to (GTK_GRID (self->grid), source_data, source, GTK_POS_RIGHT, 2, 1);

  date_modified_data = gtk_label_new (date_modified_str);
  gtk_widget_set_halign (date_modified_data, GTK_ALIGN_START);
  gtk_grid_attach_next_to (GTK_GRID (self->grid), date_modified_data, date_modified_w, GTK_POS_RIGHT, 2, 1);

  if (date_created_w != NULL)
    {
      GtkWidget *date_created_data;

      date_created_data = gtk_label_new (date_created_str);
      gtk_widget_set_halign (date_created_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), date_created_data, date_created_w, GTK_POS_RIGHT, 2, 1);
    }

  type_description = photos_base_item_get_type_description (item);
  item_type_data = gtk_label_new (type_description);
  gtk_widget_set_halign (item_type_data, GTK_ALIGN_START);
  gtk_grid_attach_next_to (GTK_GRID (self->grid), item_type_data, item_type, GTK_POS_RIGHT, 2, 1);

  if (dimensions_w != NULL)
    {
      GtkWidget *dims_data;
      g_autofree gchar *dims_str = NULL;
      gulong n = (gulong) height;

      dims_str = g_strdup_printf (ngettext ("%ld × %ld pixel", "%ld × %ld pixels", n), width, height);
      dims_data = gtk_label_new (dims_str);
      gtk_widget_set_halign (dims_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), dims_data, dimensions_w, GTK_POS_RIGHT, 2, 1);
    }

  if (self->camera_w != NULL)
    {
      photos_camera_cache_get_camera_async (self->camera_cache,
                                            equipment,
                                            self->cancellable,
                                            photos_properties_dialog_get_camera,
                                            self);
    }

  if (exposure_time_w != NULL)
    {
      GtkWidget *exposure_time_data;
      g_autofree gchar *exposure_time_str = NULL;

      exposure_time_str = g_strdup_printf ("%.3lf sec", exposure_time);
      exposure_time_data = gtk_label_new (exposure_time_str);
      gtk_widget_set_halign (exposure_time_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), exposure_time_data, exposure_time_w, GTK_POS_RIGHT, 2, 1);
    }

  if (fnumber_w != NULL)
    {
      GtkWidget *fnumber_data;
      g_autofree gchar *fnumber_str = NULL;

      fnumber_str = g_strdup_printf ("f/%.1lf", fnumber);
      fnumber_data = gtk_label_new (fnumber_str);
      gtk_widget_set_halign (fnumber_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), fnumber_data, fnumber_w, GTK_POS_RIGHT, 2, 1);
    }

  if (focal_length_w != NULL)
    {
      GtkWidget *focal_length_data;
      g_autofree gchar *focal_length_str = NULL;

      focal_length_str = g_strdup_printf ("%.0lf mm", focal_length);
      focal_length_data = gtk_label_new (focal_length_str);
      gtk_widget_set_halign (focal_length_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), focal_length_data, focal_length_w, GTK_POS_RIGHT, 2, 1);
    }

  if (iso_speed_w != NULL)
    {
      GtkWidget *iso_speed_data;
      g_autofree gchar *iso_speed_str = NULL;

      iso_speed_str = g_strdup_printf ("%.0lf", iso_speed);
      iso_speed_data = gtk_label_new (iso_speed_str);
      gtk_widget_set_halign (iso_speed_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), iso_speed_data, iso_speed_w, GTK_POS_RIGHT, 2, 1);
    }

  if (flash_w != NULL)
    {
      GtkWidget *flash_data;
      g_autofree gchar *flash_str = NULL;

      if (flash == PHOTOS_FLASH_OFF)
        flash_str = g_strdup (_("Off, did not fire"));
      else if (flash == PHOTOS_FLASH_ON)
        flash_str = g_strdup (_("On, fired"));
      else
        {
          const gchar *str;

          str = g_quark_to_string (flash);
          g_warning ("Unknown value for nmm:flash: %s", str);
        }

      flash_data = gtk_label_new (flash_str);
      gtk_widget_set_halign (flash_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (self->grid), flash_data, flash_w, GTK_POS_RIGHT, 2, 1);
    }

  if (modified_w != NULL)
    {
      GtkWidget *modified_grid;

      photos_base_item_pipeline_is_edited_async (item,
                                                 self->cancellable,
                                                 photos_properties_dialog_pipeline_is_edited,
                                                 self);

      modified_grid = gtk_grid_new ();
      gtk_widget_set_hexpand (modified_grid, TRUE);
      gtk_orientable_set_orientation (GTK_ORIENTABLE (modified_grid), GTK_ORIENTATION_HORIZONTAL);

      self->modified_data = gtk_label_new (NULL);
      gtk_widget_set_halign (self->modified_data, GTK_ALIGN_START);
      gtk_widget_set_hexpand (self->modified_data, TRUE);
      gtk_widget_set_no_show_all (self->modified_data, TRUE);
      gtk_widget_set_valign (self->modified_data, GTK_ALIGN_BASELINE);
      gtk_widget_set_vexpand (self->modified_data, TRUE);
      context = gtk_widget_get_style_context (self->modified_data);
      gtk_style_context_add_class (context, "photos-fade-out");
      gtk_container_add (GTK_CONTAINER (modified_grid), self->modified_data);

      self->revert_button = gtk_button_new_with_label (_("Discard all Edits"));
      gtk_widget_set_halign (self->revert_button, GTK_ALIGN_END);
      gtk_widget_set_hexpand (self->revert_button, TRUE);
      gtk_widget_set_no_show_all (self->revert_button, TRUE);
      context = gtk_widget_get_style_context (self->revert_button);
      gtk_style_context_add_class (context, "destructive-action");
      gtk_style_context_add_class (context, "photos-fade-out");
      gtk_container_add (GTK_CONTAINER (modified_grid), self->revert_button);

      g_signal_connect_swapped (self->revert_button,
                                "clicked",
                                G_CALLBACK (photos_properties_dialog_revert_clicked),
                                self);

      gtk_grid_attach_next_to (GTK_GRID (self->grid), modified_grid, modified_w, GTK_POS_RIGHT, 2, 1);
    }

}
Exemplo n.º 26
0
void *GTKGeomWindow::build_preferences( GtkWidget *notebook )
{
    if( _prefdata )
	delete _prefdata;
    _prefdata = new PreferencesData;

    // ****************************************************************************
    // Geometry notebook

    GtkWidget *grid = gtk_grid_new();
    gtk_grid_set_column_homogeneous( GTK_GRID(grid), TRUE );
    gtk_widget_set_hexpand( grid, TRUE );
    uint32_t yl = 0;

    // ****************************************************************************

    // Manual eqlines
    GtkWidget *label = gtk_label_new( "Manual eqlines" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    _prefdata->manual_eqlines_entry = gtk_entry_new();
    std::vector<double> eqlines_manual = _geomplot.get_eqlines_manual();
    std::string s;
    for( size_t a = 0; a < eqlines_manual.size(); a++ ) {
	char ss[128];
	snprintf( ss, 128, "%g", eqlines_manual[a] );
	s += ss;
	if( a != eqlines_manual.size()-1 )
	    s += " ";
    }
    gtk_entry_set_text( GTK_ENTRY(_prefdata->manual_eqlines_entry), s.c_str() );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 1, 1 );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->manual_eqlines_entry, 1, yl, 1, 1 );
    yl++;

    // Automatic eqlines
    label = gtk_label_new( "Automatic eqlines" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    size_t eqlines_auto = _geomplot.get_eqlines_auto();
    GtkAdjustment *automatic_eqlines_adj = gtk_adjustment_new( eqlines_auto, 0, 1000, 1, 10, 0 );
    _prefdata->automatic_eqlines_spin = gtk_spin_button_new( automatic_eqlines_adj, 1, 0 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 1, 1 );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->automatic_eqlines_spin, 1, yl, 1, 1 );
    yl++;

    // Particle division
    label = gtk_label_new( "Trajectory division" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    size_t particle_div = _geomplot.get_particle_div();
    GtkAdjustment *particle_div_adj = gtk_adjustment_new( particle_div, 0, 1000000, 1, 10, 0 );
    _prefdata->particle_div_spin = gtk_spin_button_new( particle_div_adj, 1, 0 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 1, 1 );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->particle_div_spin, 1, yl, 1, 1 );
    yl++;

    // Particle division, offset
    label = gtk_label_new( "Trajectory offset" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    size_t particle_offset = _geomplot.get_particle_offset();
    GtkAdjustment *particle_offset_adj = gtk_adjustment_new( particle_offset, 0, 1000000, 1, 10, 0 );
    _prefdata->particle_offset_spin = gtk_spin_button_new( particle_offset_adj, 1, 0 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 1, 1 );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->particle_offset_spin, 1, yl, 1, 1 );
    yl++;

    // QM discretation
    label = gtk_label_new( "Q/M discretation" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    _prefdata->qmdiscretation_check = gtk_check_button_new_with_label( "on/off" );
    bool qm_discretation = _geomplot.get_qm_discretation();
    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->qmdiscretation_check), qm_discretation );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 1, 1 );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->qmdiscretation_check, 1, yl, 1, 1 );
    yl++;

    // Mesh
    label = gtk_label_new( "Mesh" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    _prefdata->meshen_check = gtk_check_button_new_with_label( "on/off" );
    bool mesh = _geomplot.get_mesh();
    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->meshen_check), mesh );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 1, 1 );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->meshen_check, 1, yl, 1, 1 );
    yl++;

    // Add notebook page
    label = gtk_label_new( "Geometry" );
    gtk_notebook_append_page( GTK_NOTEBOOK(notebook), grid, label );

    // ****************************************************************************
    // FieldGraph notebook, 4x4 grid

    grid = gtk_grid_new();
    gtk_grid_set_column_homogeneous( GTK_GRID(grid), TRUE );
    gtk_widget_set_hexpand( grid, TRUE );
    yl = 0;

    // ****************************************************************************

    // Field selection
    label = gtk_label_new( "Field selection" );
    gtk_misc_set_alignment( GTK_MISC(label), 0.0, 0.5 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 4, 1 );
    yl++;

    // First grid row
    _prefdata->field_none_radio = gtk_radio_button_new_with_label_from_widget( NULL, 
									       "None" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_none_radio, 0, yl, 1, 1 );
    _prefdata->field_J_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									    "J" );
    if( !_tdens )
	gtk_widget_set_sensitive( _prefdata->field_J_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_J_radio, 1, yl, 1, 1 );
    _prefdata->field_rho_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									      "rho" );
    if( !_scharge )
	gtk_widget_set_sensitive( _prefdata->field_rho_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_rho_radio, 2, yl, 1, 1 );
    _prefdata->field_phi_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									      "phi" );
    if( !_epot )
	gtk_widget_set_sensitive( _prefdata->field_phi_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_phi_radio, 3, yl, 1, 1 );
    yl++;

    // Second grid row
    _prefdata->field_E_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									    "|E|" );
    if( !_epot )
	gtk_widget_set_sensitive( _prefdata->field_E_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_E_radio, 0, yl, 1, 1 );
    _prefdata->field_Ex_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									     "Ex" );
    if( !_epot )
	gtk_widget_set_sensitive( _prefdata->field_Ex_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_Ex_radio, 1, yl, 1, 1 );
    _prefdata->field_Ey_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									     "Ey" );
    if( !_epot )
	gtk_widget_set_sensitive( _prefdata->field_Ey_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_Ey_radio, 2, yl, 1, 1 );
    _prefdata->field_Ez_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									     "Ez" );
    if( !_epot )
	gtk_widget_set_sensitive( _prefdata->field_Ez_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_Ez_radio, 3, yl, 1, 1 );
    yl++;

    // Third grid row
    _prefdata->field_B_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									    "|B|" );
    if( !_bfield )
	gtk_widget_set_sensitive( _prefdata->field_B_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_B_radio, 0, yl, 1, 1 );
    _prefdata->field_Bx_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									     "Bx" );
    if( !_bfield )
	gtk_widget_set_sensitive( _prefdata->field_Bx_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_Bx_radio, 1, yl, 1, 1 );
    _prefdata->field_By_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									     "By" );
    if( !_bfield )
	gtk_widget_set_sensitive( _prefdata->field_By_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_By_radio, 2, yl, 1, 1 );
    _prefdata->field_Bz_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->field_none_radio), 
									     "Bz" );
    if( !_bfield )
	gtk_widget_set_sensitive( _prefdata->field_Bz_radio, false );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->field_Bz_radio, 3, yl, 1, 1 );
    yl++;

    field_type_e ftype = FIELD_NONE;
    if( _geomplot.fieldgraph() )
	ftype = _geomplot.fieldgraph()->field_type();
    switch( ftype ) {
    case FIELD_NONE:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_none_radio), true );	
	break;
    case FIELD_TRAJDENS:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_J_radio), true );	
	break;
    case FIELD_SCHARGE:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_rho_radio), true );	
	break;
    case FIELD_EPOT:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_phi_radio), true );	
	break;
    case FIELD_EFIELD:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_E_radio), true );	
	break;
    case FIELD_EFIELD_X:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_Ex_radio), true );	
	break;
    case FIELD_EFIELD_Y:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_Ey_radio), true );	
	break;
    case FIELD_EFIELD_Z:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_Ez_radio), true );	
	break;
    case FIELD_BFIELD:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_B_radio), true );	
	break;
    case FIELD_BFIELD_X:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_Bx_radio), true );	
	break;
    case FIELD_BFIELD_Y:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_By_radio), true );	
	break;
    case FIELD_BFIELD_Z:
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->field_Bz_radio), true );	
	break;
    };
    g_signal_connect( _prefdata->field_none_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_J_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_rho_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_phi_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_E_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_Ex_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_Ey_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_Ez_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_B_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_Bx_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_By_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );
    g_signal_connect( _prefdata->field_Bz_radio, "toggled",
		      G_CALLBACK(field_toggled), (gpointer)this );

    // Zscaling
    zscale_e zscale = _geomplot.fieldgraph()->get_zscale();
    label = gtk_label_new( "Zscale" );
    gtk_misc_set_alignment( GTK_MISC(label), 0.0, 0.5 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 2, 1 );

    _prefdata->zscale_lin_radio = gtk_radio_button_new_with_label_from_widget( NULL, 
									   "Linear" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->zscale_lin_radio, 2, yl, 2, 1 );
    yl++;
    _prefdata->zscale_log_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->zscale_lin_radio), 
									   "Logarithmic" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->zscale_log_radio, 2, yl, 2, 1 );
    yl++;
    _prefdata->zscale_rellog_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->zscale_lin_radio), 
									      "Relative log" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->zscale_rellog_radio, 2, yl, 2, 1 );
    yl++;

    if( zscale == ZSCALE_LINEAR )
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->zscale_lin_radio), true );
    else if( zscale == ZSCALE_LOG )
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->zscale_log_radio), true );
    else
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->zscale_rellog_radio), true );

    // Interpolation type
    interpolation_e interp = _geomplot.fieldgraph()->get_interpolation();    
    label = gtk_label_new( "Interpolation" );
    gtk_misc_set_alignment( GTK_MISC(label), 0.0, 0.5 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 2, 1 );

    _prefdata->int_closest_radio = gtk_radio_button_new_with_label_from_widget( NULL, 
									    "Closest" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->int_closest_radio, 2, yl, 2, 1 );
    yl++;
    _prefdata->int_bilinear_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->int_closest_radio), 
									     "Bilinear" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->int_bilinear_radio, 2, yl, 2, 1 );
    yl++;
    _prefdata->int_bicubic_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_prefdata->int_closest_radio), 
									    "Bicubic" );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->int_bicubic_radio, 2, yl, 2, 1 );
    yl++;

    if( interp == INTERPOLATION_CLOSEST )
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->int_closest_radio), true );
    else if( interp == INTERPOLATION_BILINEAR )
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->int_bilinear_radio), true );
    else
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(_prefdata->int_bicubic_radio), true );

    // Ranges
    double zmin, zmax;
    _geomplot.fieldgraph()->get_zrange( zmin, zmax );

    // Range zmin
    label = gtk_label_new( "Range zmin" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 2, 1 );
    _prefdata->zmin_entry = gtk_entry_new();
    //s = to_string( zmin );
    //gtk_entry_set_text( GTK_ENTRY(_prefdata->zmin_entry), s.c_str() );
    char st[128];
    snprintf( st, 128, "%g", zmin );
    gtk_entry_set_text( GTK_ENTRY(_prefdata->zmin_entry), st );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->zmin_entry, 2, yl, 2, 1 );
    yl++;

    // Range zmax
    label = gtk_label_new( "Range zmax" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 2, 1 );
    _prefdata->zmax_entry = gtk_entry_new();
    //s = to_string( zmax );
    //gtk_entry_set_text( GTK_ENTRY(_prefdata->zmax_entry), s.c_str() );
    snprintf( st, 128, "%g", zmax );
    gtk_entry_set_text( GTK_ENTRY(_prefdata->zmax_entry), st );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->zmax_entry, 2, yl, 2, 1 );
    yl++;

    // Palette steps
    int steps = _geomplot.fieldgraph()->palette().get_steps();
    label = gtk_label_new( "Palette steps" );
    gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
    gtk_grid_attach( GTK_GRID(grid), label, 0, yl, 2, 1 );
    _prefdata->palette_steps_entry = gtk_entry_new();
    snprintf( st, 128, "%d", steps );
    gtk_entry_set_text( GTK_ENTRY(_prefdata->palette_steps_entry), st );
    gtk_grid_attach( GTK_GRID(grid), _prefdata->palette_steps_entry, 2, yl, 2, 1 );
    yl++;

    // ****************************************************************************

    // Add notebook page
    label = gtk_label_new( "FieldGraph" );
    gtk_notebook_append_page( GTK_NOTEBOOK(notebook), grid, label );

    return( NULL );
}
/**
 * autoar_gtk_chooser_advanced_new:
 * @default_format: an #AutoarFormat
 * @default_filter: an #AutoarFilter
 *
 * Create a #GtkGrid with two lists. One list shows all available formats,
 * and the other list shows all available filters.
 *
 * Returns: (transfer full): a new #GtkGrid widget
 **/
GtkWidget*
autoar_gtk_chooser_advanced_new (AutoarFormat default_format,
                                 AutoarFilter default_filter)
{
  GtkWidget *advanced_widget;
  GtkGrid *advanced;

  GtkTreeModel *format_model;
  GtkWidget *format_widget;
  GtkTreeView *format;
  GtkTreeSelection *format_selection;
  GtkCellRenderer *format_renderer;
  GtkTreePath *format_path;

  GtkTreeModel *filter_model;
  GtkWidget *filter_widget;
  GtkTreeView *filter;
  GtkTreeSelection *filter_selection;
  GtkCellRenderer *filter_renderer;
  GtkTreePath *filter_path;

  GtkWidget *description_widget;
  GtkLabel *description;

  advanced_widget = gtk_grid_new ();
  advanced = GTK_GRID (advanced_widget);
  gtk_grid_set_row_spacing (advanced, 5);
  gtk_grid_set_column_spacing (advanced, 5);
  gtk_grid_set_column_homogeneous (advanced, TRUE);

  format_model = advanced_format_store ();
  format_widget = gtk_tree_view_new_with_model (format_model);
  format = GTK_TREE_VIEW (format_widget);
  format_selection = gtk_tree_view_get_selection (format);
  format_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_selection_set_mode (format_selection, GTK_SELECTION_SINGLE);
  gtk_tree_view_insert_column_with_attributes (format, -1, _("Format"),
                                               format_renderer, "text",
                                               ADVANCED_FORMAT_COL_DESCRIPTION,
                                               NULL);
  if (autoar_format_is_valid (default_format)) {
    GtkTreeIter iter;
    gboolean valid;
    format_path = NULL;
    for (valid = gtk_tree_model_get_iter_first (format_model, &iter);
         valid;
         valid = gtk_tree_model_iter_next (format_model, &iter)) {
      int get_format;
      gtk_tree_model_get (format_model, &iter,
                          ADVANCED_FORMAT_COL_FORMAT, &get_format, -1);
      if (default_format == get_format) {
        format_path = gtk_tree_model_get_path (format_model, &iter);
        break;
      }
    }
    if (format_path == NULL)
      format_path = gtk_tree_path_new_first ();
  } else {
    format_path = gtk_tree_path_new_first ();
  }
  gtk_tree_view_set_cursor (format, format_path, NULL, FALSE);
  gtk_tree_path_free (format_path);
  gtk_grid_attach (advanced, format_widget, 0, 0, 1, 1);
  g_object_unref (format_model);

  filter_model = advanced_filter_store ();
  filter_widget = gtk_tree_view_new_with_model (filter_model);
  filter = GTK_TREE_VIEW (filter_widget);
  filter_selection = gtk_tree_view_get_selection (filter);
  filter_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_selection_set_mode (filter_selection, GTK_SELECTION_SINGLE);
  gtk_tree_view_insert_column_with_attributes (filter, -1, _("Filter"),
                                               filter_renderer, "text",
                                               ADVANCED_FILTER_COL_DESCRIPTION,
                                               NULL);
  if (autoar_filter_is_valid (default_filter)) {
    GtkTreeIter iter;
    gboolean valid;
    filter_path = NULL;
    for (valid = gtk_tree_model_get_iter_first (filter_model, &iter);
         valid;
         valid = gtk_tree_model_iter_next (filter_model, &iter)) {
      int get_filter;
      gtk_tree_model_get (filter_model, &iter,
                          ADVANCED_FILTER_COL_FILTER, &get_filter, -1);
      if (default_filter == get_filter) {
        filter_path = gtk_tree_model_get_path (filter_model, &iter);
        break;
      }
    }
    if (filter_path == NULL)
      filter_path = gtk_tree_path_new_first ();
  } else {
    filter_path = gtk_tree_path_new_first ();
  }
  gtk_tree_view_set_cursor (filter, filter_path, NULL, FALSE);
  gtk_tree_path_free (filter_path);
  gtk_grid_attach (advanced, filter_widget, 1, 0, 1, 1);
  g_object_unref (filter_model);

  description_widget = gtk_label_new (NULL);
  description = GTK_LABEL (description_widget);
  gtk_label_set_justify (description, GTK_JUSTIFY_CENTER);
  gtk_grid_attach (advanced, description_widget, 0, 1, 2, 1);

  g_signal_connect (format_widget, "cursor-changed",
                    G_CALLBACK (advanced_update_description_cb), advanced);
  g_signal_connect (filter_widget, "cursor-changed",
                    G_CALLBACK (advanced_update_description_cb), advanced);

  /* Run the callback now to set the initial text on the label */
  advanced_update_description_cb (NULL, advanced_widget);

  return advanced_widget;
}
Exemplo n.º 28
0
void gui_init(dt_lib_module_t *self)
{
  dt_lib_image_t *d = (dt_lib_image_t *)malloc(sizeof(dt_lib_image_t));
  self->data = (void *)d;
  self->widget = gtk_grid_new();
  GtkGrid *grid = GTK_GRID(self->widget);
  gtk_grid_set_row_spacing(grid, DT_PIXEL_APPLY_DPI(5));
  gtk_grid_set_column_spacing(grid, DT_PIXEL_APPLY_DPI(5));
  gtk_grid_set_column_homogeneous(grid, TRUE);
  int line = 0;

  GtkWidget *button;

  button = gtk_button_new_with_label(_("remove"));
  d->remove_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("remove from the collection"), (char *)NULL);
  gtk_grid_attach(grid, button, 0, line, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(0));

  button = gtk_button_new_with_label(_("delete"));
  d->delete_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("physically delete from disk"), (char *)NULL);
  gtk_grid_attach(grid, button, 2, line++, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(1));


  button = gtk_button_new_with_label(_("move"));
  d->move_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("move to other folder"), (char *)NULL);
  gtk_grid_attach(grid, button, 0, line, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(8));

  button = gtk_button_new_with_label(_("copy"));
  d->copy_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("copy to other folder"), (char *)NULL);
  gtk_grid_attach(grid, button, 2, line++, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(9));


  button = gtk_button_new_with_label(_("create HDR"));
  d->create_hdr_button = button;
  gtk_grid_attach(grid, button, 0, line, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(7));
  g_object_set(G_OBJECT(button), "tooltip-text", _("create a high dynamic range image from selected shots"),
               (char *)NULL);

  button = gtk_button_new_with_label(_("duplicate"));
  d->duplicate_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text",
               _("add a duplicate to the collection, including its history stack"), (char *)NULL);
  gtk_grid_attach(grid, button, 2, line++, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(3));


  button = dtgtk_button_new(dtgtk_cairo_paint_refresh, CPF_DO_NOT_USE_BORDER);
  d->rotate_ccw_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("rotate selected images 90 degrees CCW"), (char *)NULL);
  gtk_grid_attach(grid, button, 0, line, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(4));

  button = dtgtk_button_new(dtgtk_cairo_paint_refresh, 1 | CPF_DO_NOT_USE_BORDER);
  d->rotate_cw_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("rotate selected images 90 degrees CW"), (char *)NULL);
  gtk_grid_attach(grid, button, 1, line, 1, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(5));

  button = gtk_button_new_with_label(_("reset rotation"));
  d->reset_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("reset rotation to EXIF data"), (char *)NULL);
  gtk_grid_attach(grid, button, 2, line++, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(6));


  button = gtk_button_new_with_label(_("copy locally"));
  d->cache_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("copy the image locally"), (char *)NULL);
  gtk_grid_attach(grid, button, 0, line, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(12));

  button = gtk_button_new_with_label(_("resync local copy"));
  d->uncache_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("synchronize the image's XMP and remove the local copy"),
               (char *)NULL);
  gtk_grid_attach(grid, button, 2, line++, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(13));


  button = gtk_button_new_with_label(_("group"));
  d->group_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text",
               _("add selected images to expanded group or create a new one"), (char *)NULL);
  gtk_grid_attach(grid, button, 0, line, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(10));

  button = gtk_button_new_with_label(_("ungroup"));
  d->ungroup_button = button;
  g_object_set(G_OBJECT(button), "tooltip-text", _("remove selected images from the group"), (char *)NULL);
  gtk_grid_attach(grid, button, 2, line, 2, 1);
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(11));
}
Exemplo n.º 29
0
/*
 * attach v4l2 controls tab widget
 * args:
 *   parent - tab parent widget
 *
 * asserts:
 *   parent is not null
 *
 * returns: error code (0 -OK)
 */
int gui_attach_gtk3_v4l2ctrls(GtkWidget *parent)
{
	/*assertions*/
	assert(parent != NULL);

	if(debug_level > 1)
		printf("GUVCVIEW: attaching v4l2 controls\n");

	GtkWidget *img_controls_grid = gtk_grid_new();
	gtk_widget_show (img_controls_grid);

	gtk_grid_set_column_homogeneous (GTK_GRID(img_controls_grid), FALSE);
	gtk_widget_set_hexpand (img_controls_grid, TRUE);
	gtk_widget_set_halign (img_controls_grid, GTK_ALIGN_FILL);

	gtk_grid_set_row_spacing (GTK_GRID(img_controls_grid), 4);
	gtk_grid_set_column_spacing (GTK_GRID (img_controls_grid), 4);
	gtk_container_set_border_width (GTK_CONTAINER (img_controls_grid), 2);

	int i = 0;
	int n = 0;
	v4l2_ctrl_t *current = v4l2core_get_control_list();

    for(; current != NULL; current = current->next, ++n)
    {
		if(current == NULL)
		{
			fprintf(stderr, "GUVCVIEW: ERROR (attach gtk3 controls) empty control in list\n");
			break;
		}

		if(!is_control_panel &&
		   (current->control.id == V4L2_CID_FOCUS_LOGITECH ||
		    current->control.id == V4L2_CID_FOCUS_ABSOLUTE))
		{
			++n; /*add a virtual software autofocus control*/
		}

		widget_list_size = n + 1;

		control_widgets_list = realloc(control_widgets_list, sizeof(control_widgets_t) * widget_list_size);
		if(control_widgets_list == NULL)
		{
			fprintf(stderr,"GUVCVIEW: FATAL memory allocation failure (gui_attach_gtk3_v4l2ctrls): %s\n", strerror(errno));
			exit(-1);
		}
		/*label*/
		char *tmp;
        tmp = g_strdup_printf ("%s:", current->name);
        control_widgets_list[widget_list_size - 1].label = gtk_label_new (tmp);
        g_free(tmp);
        gtk_widget_show (control_widgets_list[widget_list_size - 1].label);
#if GTK_VER_AT_LEAST(3,15)
				gtk_label_set_xalign(GTK_LABEL(control_widgets_list[widget_list_size - 1].label), 1);
				gtk_label_set_yalign(GTK_LABEL(control_widgets_list[widget_list_size - 1].label), 0.5);
#else
				gtk_misc_set_alignment (GTK_MISC (control_widgets_list[widget_list_size - 1].label), 1, 0.5);
#endif
        

		control_widgets_list[widget_list_size - 1].id = current->control.id;
        control_widgets_list[widget_list_size - 1].widget = NULL;
        control_widgets_list[widget_list_size - 1].widget2 = NULL; /*usually a spin button*/

		switch (current->control.type)
		{
			case V4L2_CTRL_TYPE_INTEGER:

				switch (current->control.id)
				{
					//special cases
					case V4L2_CID_PAN_RELATIVE:
					case V4L2_CID_TILT_RELATIVE:
					{
						control_widgets_list[n].widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);

						GtkWidget *PanTilt1 = NULL;
						GtkWidget *PanTilt2 = NULL;
						if(current->control.id == V4L2_CID_PAN_RELATIVE)
						{
							PanTilt1 = gtk_button_new_with_label(_("Left"));
							PanTilt2 = gtk_button_new_with_label(_("Right"));
						}
						else
						{
							PanTilt1 = gtk_button_new_with_label(_("Down"));
							PanTilt2 = gtk_button_new_with_label(_("Up"));
						}

						gtk_widget_show (PanTilt1);
						gtk_widget_show (PanTilt2);
						gtk_box_pack_start(GTK_BOX(control_widgets_list[n].widget),PanTilt1,TRUE,TRUE,2);
						gtk_box_pack_start(GTK_BOX(control_widgets_list[n].widget),PanTilt2,TRUE,TRUE,2);

						g_object_set_data (G_OBJECT (PanTilt1), "control_info",
							GINT_TO_POINTER(current->control.id));
						g_object_set_data (G_OBJECT (PanTilt2), "control_info",
							GINT_TO_POINTER(current->control.id));

						/*connect signals*/
						g_signal_connect (GTK_BUTTON(PanTilt1), "clicked",
							G_CALLBACK (button_PanTilt1_clicked), NULL);
						g_signal_connect (GTK_BUTTON(PanTilt2), "clicked",
							G_CALLBACK (button_PanTilt2_clicked), NULL);

						gtk_widget_show (control_widgets_list[n].widget);

						control_widgets_list[n].widget2 = gtk_spin_button_new_with_range(-256, 256, 64);

						gtk_editable_set_editable(GTK_EDITABLE(control_widgets_list[n].widget2), TRUE);

						if(current->control.id == V4L2_CID_PAN_RELATIVE)
							gtk_spin_button_set_value (GTK_SPIN_BUTTON(control_widgets_list[n].widget2), v4l2core_get_pan_step());
						else
							gtk_spin_button_set_value (GTK_SPIN_BUTTON(control_widgets_list[n].widget2),v4l2core_get_tilt_step());

						/*connect signal*/
						g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_info",
							GINT_TO_POINTER(current->control.id));
						g_signal_connect(GTK_SPIN_BUTTON(control_widgets_list[n].widget2),"value-changed",
							G_CALLBACK (pan_tilt_step_changed), NULL);

						gtk_widget_show (control_widgets_list[n].widget2);

						break;
					}

					case V4L2_CID_PAN_RESET:
					case V4L2_CID_TILT_RESET:
					{
						control_widgets_list[n].widget = gtk_button_new_with_label(" ");
						gtk_widget_show (control_widgets_list[n].widget);

						g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
							GINT_TO_POINTER(current->control.id));

						/*connect signal*/
						g_signal_connect (GTK_BUTTON(control_widgets_list[n].widget), "clicked",
							G_CALLBACK (button_clicked), NULL);

						break;
					};

					case V4L2_CID_LED1_MODE_LOGITECH:
					{
						char* LEDMenu[4] = {_("Off"),_("On"),_("Blinking"),_("Auto")};
						/*turn it into a menu control*/
						if(!current->menu)
                    					current->menu = calloc(4+1, sizeof(struct v4l2_querymenu));
                    				else
                    					current->menu = realloc(current->menu,  (4+1) * sizeof(struct v4l2_querymenu));
						if(current->menu == NULL)
						{
							fprintf(stderr,"GUVCVIEW: FATAL memory allocation failure (gui_attach_gtk3_v4l2ctrls): %s\n", strerror(errno));
							exit(-1);
						}

						current->menu[0].id = current->control.id;
						current->menu[0].index = 0;
						current->menu[0].name[0] = 'N'; /*just set something here*/
						current->menu[1].id = current->control.id;
						current->menu[1].index = 1;
						current->menu[1].name[0] = 'O';
						current->menu[2].id = current->control.id;
						current->menu[2].index = 2;
						current->menu[2].name[0] = 'B';
						current->menu[3].id = current->control.id;
						current->menu[3].index = 3;
						current->menu[3].name[0] = 'A';
						current->menu[4].id = current->control.id;
						current->menu[4].index = current->control.maximum+1;
						current->menu[4].name[0] = '\0';

						int j = 0;
						int def = 0;

						control_widgets_list[n].widget = gtk_combo_box_text_new ();
						for (j = 0; current->menu[j].index <= current->control.maximum; j++)
						{
							gtk_combo_box_text_append_text (
								GTK_COMBO_BOX_TEXT (control_widgets_list[n].widget),
								(char *) LEDMenu[j]);
							if(current->value == current->menu[j].index)
								def = j;
						}

						gtk_combo_box_set_active (GTK_COMBO_BOX(control_widgets_list[n].widget), def);
						gtk_widget_show (control_widgets_list[n].widget);

						g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
                           	GINT_TO_POINTER(current->control.id));

						/*connect signal*/
						g_signal_connect (GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget), "changed",
							G_CALLBACK (combo_changed), NULL);

						break;
					}

					case V4L2_CID_RAW_BITS_PER_PIXEL_LOGITECH:
					{
						/*turn it into a menu control*/
						char* BITSMenu[2] = {_("8 bit"),_("12 bit")};
						/*turn it into a menu control*/
						if(!current->menu)
							current->menu = calloc(2+1, sizeof(struct v4l2_querymenu));
						else
							current->menu = realloc(current->menu, (2+1) * sizeof(struct v4l2_querymenu));
						if(current->menu == NULL)
						{
							fprintf(stderr,"GUVCVIEW: FATAL memory allocation failure (gui_attach_gtk3_v4l2ctrls): %s\n", strerror(errno));
							exit(-1);
						}
						current->menu[0].id = current->control.id;
						current->menu[0].index = 0;
						current->menu[0].name[0] = 'o'; /*just set something here*/
						current->menu[1].id = current->control.id;
						current->menu[1].index = 1;
						current->menu[1].name[0] = 'd';
						current->menu[2].id = current->control.id;
						current->menu[2].index = 2;
						current->menu[2].name[0] = '\0';

						int j = 0;
						int def = 0;
						control_widgets_list[n].widget = gtk_combo_box_text_new ();
						for (j = 0; current->menu[j].index <= current->control.maximum; j++)
						{
							//if (debug_level > 0)
							//	printf("GUVCVIEW: adding menu entry %d: %d, %s\n",j, current->menu[j].index, current->menu[j].name);
							gtk_combo_box_text_append_text (
								GTK_COMBO_BOX_TEXT (control_widgets_list[n].widget),
								(char *) BITSMenu[j]);
							if(current->value == current->menu[j].index)
								def = j;
						}

						gtk_combo_box_set_active (GTK_COMBO_BOX(control_widgets_list[n].widget), def);
						gtk_widget_show (control_widgets_list[n].widget);

						g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
							GINT_TO_POINTER(current->control.id));
						/*connect signal*/
						g_signal_connect (GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget), "changed",
							G_CALLBACK (combo_changed), NULL);
						break;
					}

					case V4L2_CID_FOCUS_LOGITECH:
					case V4L2_CID_FOCUS_ABSOLUTE:

						if(!is_control_panel)
						{
							/*add a virtual control for software autofocus*/
							control_widgets_list[n-1].widget = gtk_check_button_new_with_label (_("Auto Focus (continuous)"));
							control_widgets_list[n-1].widget2 = gtk_button_new_with_label (_("set Focus"));

							gtk_widget_show (control_widgets_list[n-1].widget);
							gtk_widget_show (control_widgets_list[n-1].widget2);


							gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (control_widgets_list[n-1].widget), FALSE);

							g_signal_connect (G_OBJECT (control_widgets_list[n-1].widget), "toggled",
								G_CALLBACK (autofocus_changed), NULL);
							g_signal_connect (G_OBJECT (control_widgets_list[n-1].widget2), "clicked",
								G_CALLBACK (setfocus_clicked), NULL);

							gtk_grid_attach(GTK_GRID(img_controls_grid), control_widgets_list[n-1].widget, 1, i, 1 , 1);
							gtk_widget_set_halign (control_widgets_list[n-1].widget, GTK_ALIGN_FILL);
							gtk_widget_set_hexpand (control_widgets_list[n-1].widget, TRUE);
							gtk_grid_attach(GTK_GRID(img_controls_grid), control_widgets_list[n-1].widget2, 2, i, 1 , 1);

							i++;
						}

					default: /*standard case - hscale + spin*/
					{
						/* check for valid range */
						if((current->control.maximum > current->control.minimum) && (current->control.step != 0))
						{
							GtkAdjustment *adjustment =  gtk_adjustment_new (
								current->value,
								current->control.minimum,
								current->control.maximum,
								current->control.step,
								current->control.step*10,
								0);

							control_widgets_list[n].widget = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);

							gtk_scale_set_draw_value (GTK_SCALE (control_widgets_list[n].widget), FALSE);
							gtk_scale_set_digits(GTK_SCALE(control_widgets_list[n].widget), 0);

							gtk_widget_show (control_widgets_list[n].widget);

							control_widgets_list[n].widget2= gtk_spin_button_new(adjustment, current->control.step, 0);

							gtk_editable_set_editable(GTK_EDITABLE(control_widgets_list[n].widget2),TRUE);

							gtk_widget_show (control_widgets_list[n].widget2);

							g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
								GINT_TO_POINTER(current->control.id));
							g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_info",
								GINT_TO_POINTER(current->control.id));

							if(!is_control_panel &&
							   (current->control.id == V4L2_CID_FOCUS_LOGITECH ||
							    current->control.id == V4L2_CID_FOCUS_ABSOLUTE))
							{
								g_object_set_data (G_OBJECT (control_widgets_list[n-1].widget), "control_entry",
									control_widgets_list[n].widget);
								g_object_set_data (G_OBJECT (control_widgets_list[n-1].widget), "control2_entry",
									control_widgets_list[n].widget2);
							}

							/*connect signals*/
							g_signal_connect (GTK_SCALE(control_widgets_list[n].widget), "value-changed",
								G_CALLBACK (slider_changed), NULL);
							g_signal_connect(GTK_SPIN_BUTTON(control_widgets_list[n].widget2),"value-changed",
								G_CALLBACK (spin_changed), NULL);
						}
						else
                          fprintf(stderr, "GUVCVIEW: (Invalid range) [MAX <= MIN] for control id: 0x%08x \n", current->control.id);

						break;
					}
				}
				break;

#ifdef V4L2_CTRL_TYPE_INTEGER64
			case V4L2_CTRL_TYPE_INTEGER64:

				widget = gtk_entry_new();
				gtk_entry_set_max_length(control_widgets_list[n].widget, current->control.maximum);

				//control_widgets_list[n].widget2 = gtk_button_new_from_stock(GTK_STOCK_APPLY);
				control_widgets_list[n].widget2 = gtk_button_new_with_mnemonic (_("_Apply"));

				gtk_widget_show (control_widgets_list[n].widget);
				gtk_widget_show (control_widgets_list[n].widget2);

				g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_info",
					GINT_TO_POINTER(current->control.id));
				g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_entry",
					widget);

				/*connect signal*/
				g_signal_connect (GTK_BUTTON(control_widgets_list[n].widget2), "clicked",
					G_CALLBACK (int64_button_clicked), NULL);

				break;
#endif
#ifdef V4L2_CTRL_TYPE_STRING
			case V4L2_CTRL_TYPE_STRING:

				control_widgets_list[n].widget = gtk_entry_new();
				gtk_entry_set_max_length(control_widgets_list[n].widget, current->control.maximum);

				//control_widgets_list[n].widget2= gtk_button_new_from_stock(GTK_STOCK_APPLY);
				control_widgets_list[n].widget2 = gtk_button_new_with_mnemonic (_("_Apply"));

				gtk_widget_show (control_widgets_list[n].widget);
				gtk_widget_show (control_widgets_list[n].widget2);

				g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_info",
					GINT_TO_POINTER(current->control.id));
				g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_entry",
					widget);

				/*connect signal*/
				g_signal_connect (GTK_BUTTON(control_widgets_list[n].widget2), "clicked",
					G_CALLBACK (string_button_clicked), NULL);

				break;
#endif
#ifdef V4L2_CTRL_TYPE_BITMASK
			case V4L2_CTRL_TYPE_BITMASK:

					control_widgets_list[n].widget = gtk_entry_new();

					//control_widgets_list[n].widget2 = gtk_button_new_from_stock(GTK_STOCK_APPLY);
					control_widgets_list[n].widget2 = gtk_button_new_with_mnemonic (_("_Apply"));

					gtk_widget_show (control_widgets_list[n].widget);
					gtk_widget_show (control_widgets_list[n].widget2);

					g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_info",
                        GINT_TO_POINTER(current->control.id));
					g_object_set_data (G_OBJECT (control_widgets_list[n].widget2), "control_entry",
						widget);

                    g_signal_connect (GTK_BUTTON(control_widgets_list[n].widget2), "clicked",
                        G_CALLBACK (bitmask_button_clicked), NULL);

				break;
#endif
#ifdef V4L2_CTRL_TYPE_INTEGER_MENU
			case V4L2_CTRL_TYPE_INTEGER_MENU:
#endif
            case V4L2_CTRL_TYPE_MENU:

				if(current->menu)
				{
					int j = 0;
					int def = 0;
					control_widgets_list[n].widget = gtk_combo_box_text_new ();

					for (j = 0; current->menu[j].index <= current->control.maximum; j++)
					{
						if(current->control.type == V4L2_CTRL_TYPE_MENU)
						{
							gtk_combo_box_text_append_text (
								GTK_COMBO_BOX_TEXT (control_widgets_list[n].widget),
								(char *) current->menu_entry[j]);
						}
#ifdef V4L2_CTRL_TYPE_INTEGER_MENU
						else
						{
							char buffer[30]="0";
							snprintf(buffer, "%" PRIu64 "", 29, current->menu[j].value);
							gtk_combo_box_text_append_text (
								GTK_COMBO_BOX_TEXT (control_widgets_list[n].widget), buffer);
						}
#endif
						if(current->value == current->menu[j].index)
							def = j;
					}

					gtk_combo_box_set_active (GTK_COMBO_BOX(control_widgets_list[n].widget), def);
					gtk_widget_show (control_widgets_list[n].widget);

					g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
						GINT_TO_POINTER(current->control.id));

					/*connect signal*/
					g_signal_connect (GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget), "changed",
						G_CALLBACK (combo_changed), NULL);
				}
                break;

			case V4L2_CTRL_TYPE_BUTTON:

				control_widgets_list[n].widget = gtk_button_new_with_label(" ");
				gtk_widget_show (control_widgets_list[n].widget);

				g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
					GINT_TO_POINTER(current->control.id));

				g_signal_connect (GTK_BUTTON(control_widgets_list[n].widget), "clicked",
					G_CALLBACK (button_clicked), NULL);
                break;

            case V4L2_CTRL_TYPE_BOOLEAN:

				if(current->control.id ==V4L2_CID_DISABLE_PROCESSING_LOGITECH)
				{
					control_widgets_list[n].widget2 = gtk_combo_box_text_new ();

					gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget2),
						"GBGB... | RGRG...");
					gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget2),
						"GRGR... | BGBG...");
					gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget2),
						"BGBG... | GRGR...");
					gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(control_widgets_list[n].widget2),
						"RGRG... | GBGB...");

					v4l2core_set_bayer_pix_order(0);
					
					gtk_combo_box_set_active(GTK_COMBO_BOX(control_widgets_list[n].widget2), v4l2core_get_bayer_pix_order());

					gtk_widget_show (control_widgets_list[n].widget2);

					/*connect signal*/
					g_signal_connect (GTK_COMBO_BOX_TEXT (control_widgets_list[n].widget2), "changed",
						G_CALLBACK (bayer_pix_ord_changed), NULL);

					uint8_t isbayer = (current->value ? TRUE : FALSE);
					v4l2core_set_isbayer(isbayer);
				}

				control_widgets_list[n].widget = gtk_check_button_new();
				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (control_widgets_list[n].widget),
					current->value ? TRUE : FALSE);
				gtk_widget_show (control_widgets_list[n].widget);

				g_object_set_data (G_OBJECT (control_widgets_list[n].widget), "control_info",
					GINT_TO_POINTER(current->control.id));

				/*connect signal*/
				g_signal_connect (GTK_TOGGLE_BUTTON(control_widgets_list[n].widget), "toggled",
					G_CALLBACK (check_changed), NULL);

                break;

			default:
				printf("control[%d]:(unknown - 0x%x) 0x%x '%s'\n",i ,current->control.type,
					current->control.id, current->control.name);
				break;
		}

		/*attach widgets to grid*/
		gtk_grid_attach(GTK_GRID(img_controls_grid), control_widgets_list[n].label, 0, i, 1 , 1);

		if(control_widgets_list[n].widget)
		{
			gtk_grid_attach(GTK_GRID(img_controls_grid), control_widgets_list[n].widget, 1, i, 1 , 1);
            gtk_widget_set_halign (control_widgets_list[n].widget, GTK_ALIGN_FILL);
			gtk_widget_set_hexpand (control_widgets_list[n].widget, TRUE);
		}

		if(control_widgets_list[n].widget2)
		{
			gtk_grid_attach(GTK_GRID(img_controls_grid), control_widgets_list[n].widget2, 2, i, 1 , 1);
		}

        i++;
    }

	/*add control grid to parent container*/
	gtk_container_add(GTK_CONTAINER(parent), img_controls_grid);

	gui_gtk3_update_controls_state();

	return 0;
}
Exemplo n.º 30
0
void create_kbm_window()
{
  if (hime_kbm_window) {
    gtk_window_present(GTK_WINDOW(hime_kbm_window));
    return;
  }

  load_setttings();

  hime_kbm_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(hime_kbm_window), GTK_WIN_POS_MOUSE);
  gtk_window_set_has_resize_grip(GTK_WINDOW(hime_kbm_window), FALSE);

  g_signal_connect (G_OBJECT (hime_kbm_window), "delete_event",
                    G_CALLBACK (close_kbm_window),
                    NULL);

  gtk_window_set_title (GTK_WINDOW (hime_kbm_window), _("HIME 注音/詞音設定"));
  gtk_container_set_border_width (GTK_CONTAINER (hime_kbm_window), 1);

  GtkWidget *vbox_top = gtk_vbox_new (FALSE, 3);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (hime_kbm_window), vbox_top);


  GtkWidget *hbox_lr = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox_top), hbox_lr, TRUE, TRUE, 0);


  GtkWidget *vbox_l = gtk_vbox_new (FALSE, 3);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_l), GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (hbox_lr), vbox_l, TRUE, TRUE, 10);

  GtkWidget *vbox_r = gtk_vbox_new (FALSE, 3);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_r), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_homogeneous(GTK_GRID(vbox_r), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox_lr), vbox_r, TRUE, TRUE, 10);


  GtkWidget *frame_kbm = gtk_frame_new(_("鍵盤排列方式/選擇鍵/選單每列字數"));
  gtk_box_pack_start (GTK_BOX (vbox_l), frame_kbm, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_kbm), 1);
  gtk_container_add (GTK_CONTAINER (frame_kbm), create_kbm_opts());

  gtk_box_pack_start (GTK_BOX (vbox_l), create_en_pho_key_sel(_("(詞音) 切換[中/英]輸入")), TRUE, TRUE, 0);

  GtkWidget *frame_tsin_space_opt = gtk_frame_new(_("(詞音) 鍵入空白鍵"));
  gtk_box_pack_start (GTK_BOX (vbox_l), frame_tsin_space_opt, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_tsin_space_opt), 1);

  GtkWidget *box_tsin_space_opt = gtk_vbox_new (FALSE, 0);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(box_tsin_space_opt), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (frame_tsin_space_opt), box_tsin_space_opt);
  gtk_container_set_border_width (GTK_CONTAINER (box_tsin_space_opt), 1);

  GSList *group_tsin_space_opt = NULL;
  int current_idx = get_currnet_tsin_space_option_idx();
  new_select_idx_tsin_space_opt = current_idx;

  gsize i;
  for(i=0; i< tsin_space_optionsN; i++) {
    GtkWidget *button = gtk_radio_button_new_with_label (group_tsin_space_opt, _(tsin_space_options[i].name));
    gtk_box_pack_start (GTK_BOX (box_tsin_space_opt), button, TRUE, TRUE, 0);

    group_tsin_space_opt = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));

    g_signal_connect (G_OBJECT (button), "clicked",
       G_CALLBACK (callback_button_clicked_tsin_space_opt), (gpointer) i);

    if (i==current_idx)
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  }

  GtkWidget *hbox_tsin_phrase_pre_select = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_tsin_phrase_pre_select , TRUE, TRUE, 1);
  check_button_tsin_phrase_pre_select = gtk_check_button_new_with_label(_("詞音輸入預選詞視窗"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_phrase_pre_select), check_button_tsin_phrase_pre_select, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_phrase_pre_select), tsin_phrase_pre_select);


  GtkWidget *hbox_phonetic_char_dynamic_sequence = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_phonetic_char_dynamic_sequence , TRUE, TRUE, 1);
  check_button_phonetic_char_dynamic_sequence = gtk_check_button_new_with_label(_("依使用頻率調整字的順序"));
  gtk_box_pack_start (GTK_BOX (hbox_phonetic_char_dynamic_sequence), check_button_phonetic_char_dynamic_sequence, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_phonetic_char_dynamic_sequence), phonetic_char_dynamic_sequence);


  GtkWidget *hbox_pho_hide_row2 = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_pho_hide_row2 , TRUE, TRUE, 1);
  check_button_pho_hide_row2 = gtk_check_button_new_with_label(_("注音隱藏第二列 (注音符號)"));
  gtk_box_pack_start (GTK_BOX (hbox_pho_hide_row2), check_button_pho_hide_row2, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_pho_hide_row2), pho_hide_row2);


  GtkWidget *hbox_pho_in_row1 = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_l), hbox_pho_in_row1 , TRUE, TRUE, 1);
  check_button_pho_in_row1 = gtk_check_button_new_with_label(_("注音符號移至第一列"));
  gtk_box_pack_start (GTK_BOX (hbox_pho_in_row1), check_button_pho_in_row1, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_pho_in_row1), pho_in_row1);


  GtkWidget *hbox_phonetic_huge_tab = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_phonetic_huge_tab , TRUE, TRUE, 1);
  check_button_phonetic_huge_tab = gtk_check_button_new_with_label(_("使用巨大 UTF-8 字集"));
  gtk_box_pack_start (GTK_BOX (hbox_phonetic_huge_tab), check_button_phonetic_huge_tab, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_phonetic_huge_tab), phonetic_huge_tab);


  GtkWidget *hbox_tsin_tone_char_input = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_tone_char_input , TRUE, TRUE, 1);
  check_button_tsin_tone_char_input = gtk_check_button_new_with_label(_("(詞音) 輸入注音聲調符號"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_tone_char_input), check_button_tsin_tone_char_input, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_tone_char_input), tsin_tone_char_input);


  GtkWidget *hbox_tsin_tab_phrase_end = gtk_hbox_new(FALSE, 1);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_tab_phrase_end , TRUE, TRUE, 1);
  check_button_tsin_tab_phrase_end = gtk_check_button_new_with_label(_("(詞音) 使用 Escape/Tab 斷詞"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_tab_phrase_end), check_button_tsin_tab_phrase_end, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_tab_phrase_end), tsin_tab_phrase_end);

  GtkWidget *hbox_tsin_tail_select_key = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_tail_select_key , TRUE, TRUE, 1);
  check_button_tsin_tail_select_key = gtk_check_button_new_with_label(_("選擇鍵顯示於候選字(詞)後方"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_tail_select_key), check_button_tsin_tail_select_key, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_tail_select_key), tsin_tail_select_key);

  GtkWidget *hbox_tsin_buffer_editing_mode = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_buffer_editing_mode , TRUE, TRUE, 1);
  check_button_tsin_buffer_editing_mode = gtk_check_button_new_with_label(_("\\ 鍵可切換 jkx 鍵編輯模式"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_buffer_editing_mode), check_button_tsin_buffer_editing_mode, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_buffer_editing_mode), tsin_buffer_editing_mode);

  GtkWidget *hbox_tsin_use_pho_near = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_r), hbox_tsin_use_pho_near , TRUE, TRUE, 1);
  check_button_tsin_use_pho_near = gtk_check_button_new_with_label(_("按下 ↑ 鍵查詢近似音"));
  gtk_box_pack_start (GTK_BOX (hbox_tsin_use_pho_near), check_button_tsin_use_pho_near, FALSE, FALSE, 0);
  gtk_toggle_button_set_active(
     GTK_TOGGLE_BUTTON(check_button_tsin_use_pho_near), tsin_use_pho_near);

  GtkWidget *frame_tsin_buffer_size = gtk_frame_new(_("(詞音) 的編輯緩衝區大小"));
  gtk_box_pack_start (GTK_BOX (vbox_r), frame_tsin_buffer_size, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_tsin_buffer_size), 1);
  GtkAdjustment *adj_gtab_in =
   (GtkAdjustment *) gtk_adjustment_new (tsin_buffer_size, 10.0, MAX_PH_BF, 1.0, 1.0, 0.0);
  spinner_tsin_buffer_size = gtk_spin_button_new (adj_gtab_in, 0, 0);
  gtk_container_add (GTK_CONTAINER (frame_tsin_buffer_size), spinner_tsin_buffer_size);

  GtkWidget *frame_tsin_cursor_color = gtk_frame_new(_("詞音游標的顏色"));
  gtk_box_pack_start (GTK_BOX (vbox_r), frame_tsin_cursor_color, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame_tsin_cursor_color), 1);
  GtkWidget *button_tsin_cursor_color = gtk_button_new();
  g_signal_connect (G_OBJECT (button_tsin_cursor_color), "clicked",
                    G_CALLBACK (cb_tsin_cursor_color), G_OBJECT (hime_kbm_window));
  da_cursor =  gtk_drawing_area_new();
  gtk_container_add (GTK_CONTAINER (button_tsin_cursor_color), da_cursor);
  gdk_color_parse(tsin_cursor_color, &tsin_cursor_gcolor);
#if !GTK_CHECK_VERSION(2,91,6)
  gtk_widget_modify_bg(da_cursor, GTK_STATE_NORMAL, &tsin_cursor_gcolor);
#else
  GdkRGBA rgbbg;
  gdk_rgba_parse(&rgbbg, gdk_color_to_string(&tsin_cursor_gcolor));
  gtk_widget_override_background_color(da_cursor, GTK_STATE_FLAG_NORMAL, &rgbbg);
#endif
  gtk_widget_set_size_request(da_cursor, 16, 2);
  gtk_container_add (GTK_CONTAINER (frame_tsin_cursor_color), button_tsin_cursor_color);

  GtkWidget *hbox_cancel_ok = gtk_hbox_new (FALSE, 10);
  gtk_grid_set_column_homogeneous(GTK_GRID(hbox_cancel_ok), TRUE);
  gtk_box_pack_start (GTK_BOX (vbox_top), hbox_cancel_ok , FALSE, FALSE, 5);
  GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  if (button_order)
    gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
  else
    gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
  GtkWidget *button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
#if !GTK_CHECK_VERSION(2,91,2)
  if (button_order)
    gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5);
  else
    gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5);
#else
  if (button_order)
    gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_LEFT, 1, 1);
  else
    gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_RIGHT, 1, 1);
#endif

  g_signal_connect (G_OBJECT (button_cancel), "clicked",
                            G_CALLBACK (close_kbm_window),
                            G_OBJECT (hime_kbm_window));

  g_signal_connect_swapped (G_OBJECT (button_ok), "clicked",
                            G_CALLBACK (cb_ok),
                            G_OBJECT (hime_kbm_window));

  GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button_cancel);

  gtk_widget_show_all (hime_kbm_window);

  return;
}