Example #1
0
File: chrome.c Project: 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);
}
Example #2
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);
}
Example #3
0
static void
photos_dropdown_init (PhotosDropdown *self)
{
  GApplication *app;
  GtkStyleContext *context;
  PhotosSearchContextState *state;

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

  self->srch_mtch_mngr = g_object_ref (state->srch_mtch_mngr);
  self->srch_typ_mngr = g_object_ref (state->srch_typ_mngr);
  self->src_mngr = g_object_ref (state->src_mngr);

  self->grid = gtk_grid_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (self->grid), GTK_ORIENTATION_HORIZONTAL);
  gtk_grid_set_row_homogeneous (GTK_GRID (self->grid), TRUE);
  gtk_container_add (GTK_CONTAINER (self), self->grid);

  photos_dropdown_add_manager (self, self->src_mngr);
  photos_dropdown_add_manager (self, self->srch_typ_mngr);
  photos_dropdown_add_manager (self, self->srch_mtch_mngr);

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  gtk_style_context_add_class (context, "photos-dropdown");
  gtk_widget_hide (GTK_WIDGET(self));
  gtk_widget_show_all (GTK_WIDGET (self->grid));
}
Example #4
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);
}
Example #5
0
File: dialpad.c Project: 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);
  }
}
Example #6
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);
}
Example #7
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);
}
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;
}
Example #9
0
File: vfo.c Project: 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;
}
Example #10
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);

}
Example #11
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;
}
Example #12
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);
}
Example #13
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));
  
}
Example #14
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));

}
Example #15
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);
}
Example #16
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));

}
Example #17
0
static void
empty_grid (void)
{
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *child;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Empty grid");
  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);

  child = test_widget ("(0, 0)", "red");
  gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
  gtk_widget_set_hexpand (child, TRUE);
  gtk_widget_set_vexpand (child, TRUE);

  gtk_widget_show_all (window);
  gtk_widget_hide (child);
}
Example #18
0
static void
homogeneous_changed (GtkToggleButton *toggle_button,
		    GtkGrid *grid)
{
  gtk_grid_set_row_homogeneous (grid, gtk_toggle_button_get_active (toggle_button));
}
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;
}
Example #20
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;
}
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);
    }

}
Example #22
0
int main(int argc, char *argv[]) {

  GtkWidget *window;
  GtkWidget *table;

  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *label3;

  GtkWidget *entry1;
  GtkWidget *entry2;
  GtkWidget *entry3;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_title(GTK_WINDOW(window), "GtkEntry");
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);

   table = gtk_grid_new();
  gtk_grid_insert_row (GTK_GRID(table),0);
  gtk_grid_insert_row (GTK_GRID(table),1);
  gtk_grid_insert_row (GTK_GRID(table),2);
  gtk_grid_insert_column (GTK_GRID(table),0);
  gtk_grid_insert_column (GTK_GRID(table),1);
  gtk_grid_set_row_homogeneous(GTK_GRID(table),TRUE);
  gtk_grid_set_column_homogeneous(GTK_GRID(table),TRUE);
  gtk_container_add(GTK_CONTAINER(window), table);

  label1 = gtk_label_new("Name");
  label2 = gtk_label_new("Age");
  label3 = gtk_label_new("Occupation");


  gtk_grid_attach(GTK_GRID(table), label1, 0, 0, 1, 1);
  gtk_grid_attach(GTK_GRID(table), label2, 0, 1, 1, 1);
  gtk_grid_attach(GTK_GRID(table), label3, 0, 2, 1, 1);

  entry1 = gtk_entry_new();
  entry2 = gtk_entry_new();
  entry3 = gtk_entry_new();

  gtk_grid_attach(GTK_GRID(table), entry1, 1, 0, 1, 1);
  gtk_grid_attach(GTK_GRID(table), entry2, 1, 1, 1, 1);
  gtk_grid_attach(GTK_GRID(table), entry3, 1, 2, 1, 1);

  gtk_widget_show(table);

  gtk_widget_show(label1);
  gtk_widget_show(label2);
  gtk_widget_show(label3);

  gtk_widget_show(entry1);
  gtk_widget_show(entry2);
  gtk_widget_show(entry3);

  gtk_widget_show(window);

  g_signal_connect(window, "destroy",
      G_CALLBACK(gtk_main_quit), NULL);

  gtk_main();

  return 0;
}
Example #23
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;
}
Example #24
0
void
add_boxes_and_grid (AppWidgets *widgets)
{
    GtkWidget *button[NUM_OF_BUTTONS];
    GtkWidget *frame[NUM_OF_WIDGETS];
    GtkWidget *box[NUM_OF_WIDGETS];

    const gchar *button_label[] = {"Encrypt", "Decrypt", "Sign", "Verify Signature", "Compute", "Compare"};
    const gchar *frame_label[] = {"File", "Text", "Hash"};
    const gchar *button_name[] = {"enc_btn", "dec_file_btn", "sign_file_btn", "ver_sig_btn",
                                  "enc_txt_btn", "dec_txt_btn",
                                  "compute_hash_btn", "compare_hash_btn"};

    gint i;
    for (i = 0; i < NUM_OF_BUTTONS; i++) {
        if (i < 4) {
            button[i] = gtk_button_new_with_label (button_label[i]);
        }
    }

    button[4] = gtk_button_new_with_label (button_label[0]);
    button[5] = gtk_button_new_with_label (button_label[1]);
    button[6] = gtk_button_new_with_label (button_label[4]);
    button[7] = gtk_button_new_with_label (button_label[5]);

    for (i = 0; i < NUM_OF_BUTTONS; i++) {
        gtk_widget_set_name (GTK_WIDGET (button[i]), button_name[i]);
    }

    for (i = 0; i < NUM_OF_WIDGETS; i++) {
        frame[i] = gtk_frame_new (frame_label[i]);
        box[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
        gtk_container_add (GTK_CONTAINER (frame[i]), box[i]);
    }

    for (i = 0; i < NUM_OF_BUTTONS; i++) {
        gtk_widget_set_margin_bottom (button[i], 5);
        if (i < 4) {
            gtk_box_pack_start (GTK_BOX (box[0]), button[i], TRUE, TRUE, 2);
        }
        else if (i >= 4 && i < 6) {
            gtk_box_pack_start (GTK_BOX (box[1]), button[i], TRUE, TRUE, 2);
        }
        else {
            gtk_box_pack_start (GTK_BOX (box[2]), button[i], TRUE, TRUE, 2);
        }
    }

    // TODO add verify signature button
    g_signal_connect (button[0], "clicked", G_CALLBACK (encrypt_file_cb), widgets->main_window);
    g_signal_connect (button[1], "clicked", G_CALLBACK (decrypt_file_cb), widgets->main_window);
    g_signal_connect (button[2], "clicked", G_CALLBACK (sign_file_cb), widgets->main_window);
    g_signal_connect (button[3], "clicked", G_CALLBACK (verify_signature_cb), widgets->main_window);
    gtk_widget_set_sensitive (button[4], FALSE);
    gtk_widget_set_sensitive (button[5], FALSE);
    g_signal_connect (button[6], "clicked", G_CALLBACK (compute_hash_cb), widgets->main_window);
    g_signal_connect (button[7], "clicked", G_CALLBACK (compare_files_hash_cb), widgets->main_window);

    GtkWidget *grid = gtk_grid_new ();
    gtk_container_add (GTK_CONTAINER (widgets->main_window), grid);
    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), 5);

    gtk_grid_attach (GTK_GRID (grid), frame[0], 0, 0, 3, 2);
    gtk_grid_attach (GTK_GRID (grid), frame[1], 0, 2, 3, 2);
    gtk_grid_attach (GTK_GRID (grid), frame[2], 0, 4, 3, 2);
}
static void
photos_properties_dialog_constructed (GObject *object)
{
  PhotosPropertiesDialog *self = PHOTOS_PROPERTIES_DIALOG (object);
  PhotosPropertiesDialogPrivate *priv = self->priv;
  GDateTime *date_modified;
  GtkStyleContext *context;
  GtkWidget *author_w = NULL;
  GtkWidget *content_area;
  GtkWidget *date_created_w = NULL;
  GtkWidget *date_modified_data;
  GtkWidget *date_modified_w;
  GtkWidget *exposure_time_w = NULL;
  GtkWidget *flash_w = NULL;
  GtkWidget *fnumber_w = NULL;
  GtkWidget *focal_length_w = NULL;
  GtkWidget *height_w = NULL;
  GtkWidget *iso_speed_w = NULL;
  GtkWidget *item_type;
  GtkWidget *item_type_data;
  GtkWidget *source;
  GtkWidget *source_data;
  GtkWidget *title;
  GtkWidget *width_w = NULL;
  GQuark equipment;
  GQuark flash;
  PhotosBaseItem *item;
  const gchar *author;
  const gchar *name;
  const gchar *type_description;
  gchar *date_created_str = NULL;
  gchar *date_modified_str;
  gdouble exposure_time;
  gdouble fnumber;
  gdouble focal_length;
  gdouble iso_speed;
  gint64 ctime;
  gint64 height;
  gint64 mtime;
  gint64 width;

  G_OBJECT_CLASS (photos_properties_dialog_parent_class)->constructed (object);

  item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, priv->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");
  g_date_time_unref (date_modified);

  ctime = photos_base_item_get_date_created (item);
  if (ctime != -1)
    {
      GDateTime *date_created;

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

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

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (self));
  gtk_box_pack_start (GTK_BOX (content_area), priv->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 (priv->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 (priv->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 (priv->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 (priv->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 (priv->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 (priv->grid), item_type);

  width = photos_base_item_get_width (item);
  if (width > 0)
    {
      width_w = gtk_label_new (_("Width"));
      gtk_widget_set_halign (width_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (width_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (priv->grid), width_w);
    }

  height = photos_base_item_get_height (item);
  if (height > 0)
    {
      height_w = gtk_label_new (_("Height"));
      gtk_widget_set_halign (height_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (height_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (priv->grid), height_w);
    }

  equipment = photos_base_item_get_equipment (item);
  photos_camera_cache_get_camera_async (priv->camera_cache,
                                        equipment,
                                        priv->cancellable,
                                        photos_properties_dialog_get_camera,
                                        self);
  if (equipment != 0)
    {
      priv->camera_w = gtk_label_new (_("Camera"));
      gtk_widget_set_halign (priv->camera_w, GTK_ALIGN_END);
      context = gtk_widget_get_style_context (priv->camera_w);
      gtk_style_context_add_class (context, "dim-label");
      gtk_container_add (GTK_CONTAINER (priv->grid), priv->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 (priv->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 (priv->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 (priv->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 (priv->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 (priv->grid), flash_w);
    }

  name = photos_base_item_get_name (item);

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

      g_signal_connect (priv->title_entry,
                        "changed",
                        G_CALLBACK (photos_properties_dialog_title_entry_changed),
                        self);
    }
  else
    {
      priv->title_entry = gtk_label_new (name);
      gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START);
    }

  gtk_grid_attach_next_to (GTK_GRID (priv->grid), priv->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 (priv->grid), author_data, author_w, GTK_POS_RIGHT, 2, 1);
    }

  if (PHOTOS_IS_FACEBOOK_ITEM (item))
    {
      const gchar *source_name;

      source_name = photos_base_item_get_source_name (item);
      source_data = gtk_link_button_new_with_label ("https://www.facebook.com/", source_name);
      gtk_widget_set_halign (source_data, GTK_ALIGN_START);
    }
  else if (PHOTOS_IS_FLICKR_ITEM (item))
    {
      const gchar *source_name;

      source_name = photos_base_item_get_source_name (item);
      source_data = gtk_link_button_new_with_label ("https://www.flickr.com/", source_name);
      gtk_widget_set_halign (source_data, GTK_ALIGN_START);
    }
  else /* local item */
    {
      if (photos_base_item_is_collection (item))
        {
          const gchar *source_name;

          source_name = photos_base_item_get_source_name (item);
          source_data = gtk_label_new (source_name);
          gtk_widget_set_halign (source_data, GTK_ALIGN_START);
        }
      else
        {
          GFile *file;
          GFile *source_link;
          GtkWidget *label;
          const gchar *uri;
          gchar *source_path;
          gchar *source_uri;

          uri = photos_base_item_get_uri (item);
          file = g_file_new_for_uri (uri);
          source_link = g_file_get_parent (file);
          source_path = g_file_get_path (source_link);
          source_uri = g_file_get_uri (source_link);

          source_data = gtk_link_button_new_with_label (source_uri, source_path);
          gtk_widget_set_halign (source_data, GTK_ALIGN_START);

          label = gtk_bin_get_child (GTK_BIN (source_data));
          gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);

          g_object_unref (source_link);
          g_object_unref (file);
        }
    }

  gtk_grid_attach_next_to (GTK_GRID (priv->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 (priv->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 (priv->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 (priv->grid), item_type_data, item_type, GTK_POS_RIGHT, 2, 1);

  if (width_w != NULL)
    {
      GtkWidget *width_data;
      gchar *width_str;

      width_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", width);
      width_data = gtk_label_new (width_str);
      gtk_widget_set_halign (width_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (priv->grid), width_data, width_w, GTK_POS_RIGHT, 2, 1);
      g_free (width_str);
    }

  if (height_w != NULL)
    {
      GtkWidget *height_data;
      gchar *height_str;

      height_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", height);
      height_data = gtk_label_new (height_str);
      gtk_widget_set_halign (height_data, GTK_ALIGN_START);
      gtk_grid_attach_next_to (GTK_GRID (priv->grid), height_data, height_w, GTK_POS_RIGHT, 2, 1);
      g_free (height_str);
    }

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

      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 (priv->grid), exposure_time_data, exposure_time_w, GTK_POS_RIGHT, 2, 1);
      g_free (exposure_time_str);
    }

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

      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 (priv->grid), fnumber_data, fnumber_w, GTK_POS_RIGHT, 2, 1);
      g_free (fnumber_str);
    }

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

      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 (priv->grid), focal_length_data, focal_length_w, GTK_POS_RIGHT, 2, 1);
      g_free (focal_length_str);
    }

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

      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 (priv->grid), iso_speed_data, iso_speed_w, GTK_POS_RIGHT, 2, 1);
      g_free (iso_speed_str);
    }

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

      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
        g_assert_not_reached ();

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

  g_free (date_created_str);
  g_free (date_modified_str);
}
config_dialog_t *create_event_config_dialog_content(event_config_t *event, GtkWidget *content)
{
    if (content == NULL)
        content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

    //event_config_t *event = get_event_config(event_name);

    GtkWidget *option_table = gtk_grid_new();
    gtk_grid_set_row_homogeneous(GTK_GRID(option_table), FALSE);
    gtk_grid_set_column_homogeneous(GTK_GRID(option_table), FALSE);
    gtk_grid_set_row_spacing(GTK_GRID(option_table), 2);
    g_object_set_data(G_OBJECT(option_table), "n-rows", (gpointer)-1);

    gtk_widget_set_hexpand(option_table, TRUE);
    gtk_widget_set_vexpand(option_table, TRUE);
    gtk_widget_set_halign(option_table, GTK_ALIGN_FILL);
    gtk_widget_set_valign(option_table, GTK_ALIGN_FILL);

    /* table to hold advanced options
     * hidden in expander which is visible only if there's at least
     * one advanced option
    */

    GtkWidget *adv_option_table = gtk_grid_new();
    gtk_grid_set_row_homogeneous(GTK_GRID(adv_option_table), FALSE);
    gtk_grid_set_column_homogeneous(GTK_GRID(adv_option_table), FALSE);
    gtk_grid_set_row_spacing(GTK_GRID(adv_option_table), 2);
    g_object_set_data(G_OBJECT(adv_option_table), "n-rows", (gpointer)-1);

    GtkWidget *adv_expander = gtk_expander_new(_("Advanced"));
    gtk_container_add(GTK_CONTAINER(adv_expander), adv_option_table);
    g_object_set_data(G_OBJECT(option_table), "advanced-options", adv_option_table);

    has_password_option = false;
    /* it's already stored in config_dialog_t from the previous call
     * we need to set it to null so we create a new list for the actual
     * event_config
     * note: say *NO* to the global variables!
    */
    g_option_list = NULL;
    /* this fills the g_option_list, so we can use it for new_config_dialog */
    g_list_foreach(event->options, &add_option_to_table, option_table);

    /* if there is at least one password option, add checkbox to disable storing passwords */
    if (has_password_option)
    {
        unsigned last_row = add_one_row_to_grid(GTK_GRID(option_table));
        GtkWidget *pass_store_cb = gtk_check_button_new_with_label(_("Don't store passwords"));
        gtk_grid_attach(GTK_GRID(option_table), pass_store_cb,
                /*left,top:*/ 0, last_row,
                /*width,height:*/ 1, 1);
        const char *store_passwords = get_user_setting("store_passwords");
        if (store_passwords && !strcmp(store_passwords, "no"))
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pass_store_cb), 1);
        g_signal_connect(pass_store_cb, "toggled", G_CALLBACK(on_show_pass_store_cb), NULL);
    }

    gtk_box_pack_start(GTK_BOX(content), option_table, false, false, 20);

    /* add the adv_option_table to the dialog only if there is some adv option */
    if (g_list_length(gtk_container_get_children(GTK_CONTAINER(adv_option_table))) > 0)
        gtk_box_pack_start(GTK_BOX(content), adv_expander, false, false, 0);

    /* add warning if secrets service is not available showing the nagging dialog
     * is considered "too heavy UI" be designers
     */
    if (!is_event_config_user_storage_available())
    {
        GtkWidget *keyring_warn_lbl =
        gtk_label_new(
          _("Secret Service is not available, your settings won't be saved!"));
        static const GdkColor red = { .red = 0xffff };
        gtk_widget_modify_fg(keyring_warn_lbl, GTK_STATE_NORMAL, &red);
        gtk_box_pack_start(GTK_BOX(content), keyring_warn_lbl, false, false, 0);
    }

    gtk_widget_show_all(content); //make it all visible

    //g_option_list is filled on
    config_dialog_t *cdialog = new_config_dialog(NULL,
                                    g_option_list,
                                    (config_save_fun_t)save_data_from_event_dialog_name
                                    );

    return cdialog;
}
Example #27
0
static void cw_cb(GtkWidget *widget, gpointer data) {
  GtkWidget *dialog=gtk_dialog_new_with_buttons("CW",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 *cw_keyer_internal_b=gtk_check_button_new_with_label("CW Internal - Speed (WPM)");
  //gtk_widget_override_font(cw_keyer_internal_b, pango_font_description_from_string("Arial 18"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw_keyer_internal_b), cw_keyer_internal);
  gtk_widget_show(cw_keyer_internal_b);
  gtk_grid_attach(GTK_GRID(grid),cw_keyer_internal_b,0,0,1,1);
  g_signal_connect(cw_keyer_internal_b,"toggled",G_CALLBACK(cw_keyer_internal_cb),NULL);

  GtkWidget *cw_keyer_speed_b=gtk_spin_button_new_with_range(1.0,60.0,1.0);
  //gtk_widget_override_font(cw_keyer_speed_b, pango_font_description_from_string("Arial 18"));
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(cw_keyer_speed_b),(double)cw_keyer_speed);
  gtk_widget_show(cw_keyer_speed_b);
  gtk_grid_attach(GTK_GRID(grid),cw_keyer_speed_b,1,0,1,1);
  g_signal_connect(cw_keyer_speed_b,"value_changed",G_CALLBACK(cw_keyer_speed_value_changed_cb),NULL);

  GtkWidget *cw_breakin_b=gtk_check_button_new_with_label("CW Break In - Delay (ms)");
  //gtk_widget_override_font(cw_breakin_b, pango_font_description_from_string("Arial 18"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw_breakin_b), cw_breakin);
  gtk_widget_show(cw_breakin_b);
  gtk_grid_attach(GTK_GRID(grid),cw_breakin_b,0,1,1,1);
  g_signal_connect(cw_breakin_b,"toggled",G_CALLBACK(cw_breakin_cb),NULL);

  GtkWidget *cw_keyer_hang_time_b=gtk_spin_button_new_with_range(0.0,1000.0,1.0);
  //gtk_widget_override_font(cw_keyer_hang_time_b, pango_font_description_from_string("Arial 18"));
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(cw_keyer_hang_time_b),(double)cw_keyer_hang_time);
  gtk_widget_show(cw_keyer_hang_time_b);
  gtk_grid_attach(GTK_GRID(grid),cw_keyer_hang_time_b,1,1,1,1);
  g_signal_connect(cw_keyer_hang_time_b,"value_changed",G_CALLBACK(cw_keyer_hang_time_value_changed_cb),NULL);
  
  GtkWidget *cw_keyer_straight=gtk_radio_button_new_with_label(NULL,"CW KEYER STRAIGHT");
  //gtk_widget_override_font(cw_keyer_straight, pango_font_description_from_string("Arial 18"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw_keyer_straight), cw_keyer_mode==KEYER_STRAIGHT);
  gtk_widget_show(cw_keyer_straight);
  gtk_grid_attach(GTK_GRID(grid),cw_keyer_straight,0,2,1,1);
  g_signal_connect(cw_keyer_straight,"pressed",G_CALLBACK(cw_keyer_mode_cb),(gpointer *)KEYER_STRAIGHT);

  GtkWidget *cw_keyer_mode_a=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(cw_keyer_straight),"CW KEYER MODE A");
  //gtk_widget_override_font(cw_keyer_mode_a, pango_font_description_from_string("Arial 18"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw_keyer_mode_a), cw_keyer_mode==KEYER_MODE_A);
  gtk_widget_show(cw_keyer_mode_a);
  gtk_grid_attach(GTK_GRID(grid),cw_keyer_mode_a,0,3,1,1);
  g_signal_connect(cw_keyer_mode_a,"pressed",G_CALLBACK(cw_keyer_mode_cb),(gpointer *)KEYER_MODE_A);

  GtkWidget *cw_keyer_mode_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(cw_keyer_mode_a),"CW KEYER MODE B");
  //gtk_widget_override_font(cw_keyer_mode_b, pango_font_description_from_string("Arial 18"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw_keyer_mode_b), cw_keyer_mode==KEYER_MODE_B);
  gtk_widget_show(cw_keyer_mode_b);
  gtk_grid_attach(GTK_GRID(grid),cw_keyer_mode_b,0,4,1,1);
  g_signal_connect(cw_keyer_mode_b,"pressed",G_CALLBACK(cw_keyer_mode_cb),(gpointer *)KEYER_MODE_B);

  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 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));
}
/* Construct the status bar widget. */
static GtkWidget *
libre_impuesto_window_construct_headerbar (LibreImpuestoWindow *impuesto_window)
{
  gint size;
  time_t secs;
  GDate *today;
  struct tm *tm;
  GtkStateFlags state;
  GtkWidget *headerbar;
  gchar buffer[100] = "";
  GtkWidget *header_area;
  GtkWidget *grid_layout;
  GtkStyleContext *context;
  PangoFontDescription *font_desc;
  GtkWidget *label_libre_impuesto, *label_software_libre, *label_date;


  secs = time (NULL);
  tm = localtime (&secs);

  header_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
  g_object_bind_property (
		impuesto_window, "headerbar-visible",
		header_area, "visible",
		G_BINDING_SYNC_CREATE);

  headerbar = gtk_event_box_new();
  gtk_box_pack_start (GTK_BOX (header_area), 
		      headerbar, FALSE, FALSE, 0);

  gtk_widget_set_name (headerbar, "libre-impuesto-header");
  gtk_widget_set_size_request (headerbar, -1, 56);

  grid_layout = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (headerbar), grid_layout);
  gtk_grid_set_column_homogeneous (GTK_GRID(grid_layout), TRUE);
  gtk_grid_set_row_homogeneous (GTK_GRID (grid_layout), TRUE);

  label_libre_impuesto = gtk_label_new (_("Libre Impuestos"));
  gtk_grid_attach (GTK_GRID (grid_layout), label_libre_impuesto, 0, 0, 1, 1);  

  context = gtk_widget_get_style_context (label_libre_impuesto);
  state = gtk_widget_get_state_flags (label_libre_impuesto);
  size = pango_font_description_get_size (gtk_style_context_get_font (
								      context, 
								      state));
  font_desc = pango_font_description_new ();
  pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
  pango_font_description_set_size (font_desc, size * PANGO_SCALE_X_LARGE);
  gtk_widget_override_font (label_libre_impuesto, font_desc);
  pango_font_description_free (font_desc);

  gtk_misc_set_alignment (GTK_MISC (label_libre_impuesto), 0.2, 0.4);
  gtk_widget_show (label_libre_impuesto);

  label_software_libre = gtk_label_new (_("www.softwarelibre.org.bo"));
  gtk_grid_attach (GTK_GRID (grid_layout), label_software_libre, 1, 0, 1, 1);  
  gtk_misc_set_alignment (GTK_MISC (label_software_libre), 0.5, 0.8);
  gtk_widget_show (label_software_libre);

  today = g_date_new_dmy((gint)tm->tm_mday, 
			 (gint)tm->tm_mon + 1, 
			 1900 + tm->tm_year);

  g_date_strftime (buffer, 100-1, "%A, %d de %B de %Y", today);
  label_date = gtk_label_new (g_ascii_strup (buffer,100-1));
  g_date_free(today);

  gtk_grid_attach (GTK_GRID (grid_layout), label_date, 2, 0, 1, 1);  
  gtk_misc_set_alignment (GTK_MISC (label_date), 0.9, 0.5);

  return header_area;
}
Example #29
0
int main (int argc, char *argv[])
{
    //const std::string creatureDB[]={"pidgeot","gardevoir"}; - For creature catalog~~
    //std::cout<<creatureDB[0];

    /* Initialize GTK+ */
    g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
    gtk_init (&argc, &argv);
    g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);

    /* Main window configuration */
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (GTK_WINDOW (win), false);
    gtk_widget_set_size_request(win,windowWidth,windowHeight);
    gtk_container_set_border_width (GTK_CONTAINER (win), 0);
    gtk_window_set_title (GTK_WINDOW (win), "Pokemon");
    gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
    gtk_widget_realize (win);
    g_signal_connect (win, "destroy", gtk_main_quit, NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(win),"images/winIcon.png",NULL);
    //gtk_window_set_decorated (GTK_WINDOW(win),FALSE); //Óáèðàåò ñòàíäàðòíîå îôîðìëåíèå îêíà windows

    /* Initializing objects */
    zeBigContainer = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    zeBigContainerOverlay = gtk_overlay_new();
    topPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    topPartCenter = gtk_alignment_new (0.5,0.5,1,1);
    topPartLeft = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    topPartCenter = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    topPartRight = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    bottomPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    buttons = gtk_grid_new ();
    dialogScrollFrame = gtk_scrolled_window_new(NULL,NULL);
    dialogText = gtk_text_view_new ();
    dialogBuffer = gtk_text_buffer_new (NULL);
    button1 = gtk_button_new ();
    button2 = gtk_button_new ();
    button3 = gtk_button_new ();
    button4 = gtk_button_new_with_label ("Restart");
    button5 = gtk_button_new_with_label ("Back to choosing screen");
    topMidPart = gtk_image_new_from_file ("images/topPic.jpg");
    IMGBackground = gtk_image_new_from_file ("images/pokeBackground.jpg");
    leftImage = gtk_image_new_from_file ("images/filler.PNG");
    rightImage = gtk_image_new_from_file ("images/filler.PNG");
    leftBar = gtk_progress_bar_new ();
    rightBar = gtk_progress_bar_new ();

    /* Setting dialogText */
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_LEFT, 5);
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_BOTTOM, 20);
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_TOP, 5);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(dialogText), FALSE);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(dialogText), FALSE);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dialogText),GTK_WRAP_WORD);

    /* Setting progress bars */
    gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(rightBar),TRUE);
    gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(leftBar),TRUE);
    gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(rightBar),TRUE);

    /* Various initializations */
    gtk_box_set_homogeneous((GtkBox*)topPartCenter,TRUE);
    gtk_box_set_homogeneous((GtkBox*)topPart,TRUE);
    gtk_box_set_homogeneous((GtkBox*)bottomPart,TRUE);
    gtk_box_set_homogeneous((GtkBox*)zeBigContainer,TRUE);
    gtk_grid_set_row_homogeneous((GtkGrid*)buttons,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)buttons,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)buttons,12);
    gtk_grid_set_column_spacing((GtkGrid*)buttons,12);
    g_object_set (buttons,"margin",12,NULL);
    g_object_set (topPart,"margin",12,NULL);
    gtk_container_set_border_width(GTK_CONTAINER(dialogScrollFrame),5);
    //gtk_box_set_child_packing((GtkBox*)zeBigContainer,bottomPart,gTRUE,gTRUE,100,GTK_PACK_START);
    gtk_text_view_set_buffer (GTK_TEXT_VIEW(dialogText), dialogBuffer);
    gtk_text_buffer_set_text(dialogBuffer, "", -1);
    //gtk_text_buffer_get_iter_at_offset (dialogBuffer, &lastCharIter, -1);
    gtk_text_buffer_get_end_iter(dialogBuffer, &endIter);
    fontDesc = pango_font_description_from_string("Consolas");
    gtk_widget_override_font(dialogText,fontDesc);
    endMark = gtk_text_mark_new ("endMark",FALSE);
    endMark = gtk_text_buffer_get_mark(dialogBuffer,"insert");
    gtk_button_set_always_show_image(GTK_BUTTON(button1),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(button2),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(button3),TRUE);

    /* Building objects */
    gtk_container_add (GTK_CONTAINER(win),zeBigContainerOverlay);
    gtk_overlay_add_overlay(GTK_OVERLAY(zeBigContainerOverlay),zeBigContainer);
    gtk_container_add (GTK_CONTAINER(zeBigContainerOverlay),IMGBackground);
    gtk_container_add (GTK_CONTAINER(zeBigContainer),topPart);
    gtk_container_add (GTK_CONTAINER(zeBigContainer),bottomPart);
    gtk_container_add (GTK_CONTAINER(topPart),topPartLeft); // Â topPartLeft âñòàâëÿòü ëåâûé áàð
    gtk_container_add (GTK_CONTAINER(topPartLeft),leftBar);
    gtk_container_add (GTK_CONTAINER(topPartLeft),leftImage);
    gtk_container_add (GTK_CONTAINER(topPart),topPartCenter);
    gtk_container_add (GTK_CONTAINER(topPart),topPartRight); // â topPartRight - ïðàâûé...
    gtk_container_add (GTK_CONTAINER(topPartRight),rightBar);
    gtk_container_add (GTK_CONTAINER(topPartRight),rightImage);
    gtk_container_add (GTK_CONTAINER(topPartCenter),topMidPart);
    gtk_container_add (GTK_CONTAINER(bottomPart),dialogScrollFrame);
    gtk_container_add (GTK_CONTAINER(dialogScrollFrame),dialogText);
    gtk_container_add (GTK_CONTAINER(bottomPart),buttons);
    gtk_grid_attach (GTK_GRID(buttons),button1, 1,1,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button2, 1,2,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button3, 1,3,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button4, 1,4,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button5, 1,5,1,1);

    /* Signal connects and some shiatd */
    g_signal_connect(G_OBJECT(button1), "clicked", Cast1, NULL);
    g_signal_connect(G_OBJECT(button2), "clicked", Cast2, NULL);
    g_signal_connect(G_OBJECT(button3), "clicked", Cast3, NULL);
    g_signal_connect(G_OBJECT(button4), "clicked", combatStart, NULL);
    g_signal_connect(G_OBJECT(button5), "clicked", backToChoosingScreen,NULL);

    /* Creature chooser window configuration */ // TO BE CONTINUED..........................................................................
    /* Window creation/configuration (win2) */
    win2win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (GTK_WINDOW (win2win), false);
    gtk_widget_set_size_request(win2win,windowWidth,windowHeight);
    gtk_window_set_title (GTK_WINDOW (win2win), "Pokemon creature chooser");
    gtk_window_set_position (GTK_WINDOW (win2win), GTK_WIN_POS_CENTER);
    gtk_widget_realize (win2win);
    g_signal_connect (win2win, "destroy", gtk_main_quit, NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(win2win),"images/winIcon.png",NULL);


    /* Initializing objects (win2) */
    win2topLabel = gtk_image_new_from_file("images/logo.png");
    //win2topLabel = gtk_label_new("");
    //gtk_label_set_markup(GTK_LABEL(win2topLabel),"<small>Small</small><big>Bold</big>");
    win2BigContainer = gtk_grid_new();
    win2BigContainerOverlay = gtk_overlay_new ();
    win2TopPart = gtk_grid_new ();
    win2MiddlePart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    win2BottomPart = gtk_grid_new();
    win2BackgroundIMG = gtk_image_new_from_file ("images/pokeBackground.jpg");
    win2button1 = gtk_button_new_with_label(">>Switch Screens<<");
    win2button2 = gtk_button_new_with_label("Exit");
    win2buttonReset = gtk_button_new_with_label("Reset");
    win2creatureIcon1 = gtk_button_new();
    win2creatureIcon2 = gtk_button_new();
    win2creatureIcon3 = gtk_button_new();
    win2creatureIcon4 = gtk_button_new();
    win2creatureIcon5 = gtk_button_new();
    win2creatureIcon1IMG = gtk_image_new_from_file("images/ImagePidgeotSmall.png");
    win2creatureIcon2IMG = gtk_image_new_from_file("images/ImageGardevoirSmall.png");
    win2creatureIcon3IMG = gtk_image_new_from_file("images/ImageArcanineSmall.png");
    win2creatureIcon4IMG = gtk_image_new_from_file("images/ImagePikachuSmall.png");
    win2creatureIcon5IMG = gtk_image_new_from_file("images/ImageFishSmall.png");
    win2ImageVersus = gtk_image_new_from_file ("images/versus.png");
    win2MiddleFirst = gtk_image_new_from_file ("images/facelessVoid.png");
    win2MiddleSecond = gtk_image_new_from_file ("images/facelessVoid.png");

    /* Various initializations (win2) */
    gtk_grid_set_row_homogeneous((GtkGrid*)win2BigContainer,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2BigContainer,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2BigContainer,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2BigContainer,12);
    //g_object_set (win2BigContainer,"margin",12,NULL);

    gtk_grid_set_row_homogeneous((GtkGrid*)win2BottomPart,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2BottomPart,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2BottomPart,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2BottomPart,12);
    g_object_set (win2BottomPart,"margin",12,NULL);

    gtk_grid_set_row_homogeneous((GtkGrid*)win2TopPart,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2TopPart,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2TopPart,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2TopPart,12);
    g_object_set (win2TopPart,"margin",12,NULL);

    gtk_box_set_homogeneous(GTK_BOX(win2MiddlePart),TRUE);

    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon1),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon2),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon3),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon4),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon5),TRUE);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon1),win2creatureIcon1IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon2),win2creatureIcon2IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon3),win2creatureIcon3IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon4),win2creatureIcon4IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon5),win2creatureIcon5IMG);

    /* Building objects (win2) */
    gtk_container_add (GTK_CONTAINER(win2win),win2BigContainerOverlay);
    gtk_overlay_add_overlay(GTK_OVERLAY(win2BigContainerOverlay),win2BigContainer);
    gtk_container_add (GTK_CONTAINER(win2BigContainerOverlay),win2BackgroundIMG);
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2topLabel,1,1,1,2);//1
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2TopPart,1,2,1,3);//3
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon1,1,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon2,2,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon3,3,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon4,4,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon5,5,1,1,1);
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2MiddlePart,1,5,1,3);//3
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2BottomPart,1,8,1,3);//3
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleFirst);
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2ImageVersus);
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleSecond);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2button1, 1,1,3,1);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2buttonReset,4,1,1,1);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2button2, 5,1,1,1);

    /* Signal connects (win2) */
    g_signal_connect (G_OBJECT(win2button1),"clicked",win2StartGame,NULL);
    g_signal_connect (G_OBJECT(win2button2),"clicked",gtk_main_quit,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon1),"clicked",win2pidgeotSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon2),"clicked",win2gardevoirSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon3),"clicked",win2arcanineSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon4),"clicked",win2pikachuSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon5),"clicked",win2mightyfishSelect,NULL);
    g_signal_connect (G_OBJECT(win2buttonReset),"clicked",win2CharReset,NULL);

    /* Other stuff */
    srand(time(NULL));
    write ("___________________________________________________\n");

    /* Enter the main loop */
    gtk_widget_show_all (win2win);
    gtk_main ();

    return 0;
};
Example #30
0
File: main.c Project: g0orx/pihpsdr
gint init(void* arg) {

  gint x;
  gint y;

  DISCOVERED* d;

  char *res;
  char wisdom_directory[1024];
  char wisdom_file[1024];

  fprintf(stderr,"init\n");

  audio_get_cards(0);
  audio_get_cards(1);

  cursor_arrow=gdk_cursor_new(GDK_ARROW);
  cursor_watch=gdk_cursor_new(GDK_WATCH);

  GdkWindow *gdk_splash_window = gtk_widget_get_window(splash_window);
  gdk_window_set_cursor(gdk_splash_window,cursor_watch);

  init_radio();

  // check if wisdom file exists
  res=getcwd(wisdom_directory, sizeof(wisdom_directory));
  strcpy(&wisdom_directory[strlen(wisdom_directory)],"/");
  strcpy(wisdom_file,wisdom_directory);
  strcpy(&wisdom_file[strlen(wisdom_file)],"wdspWisdom");
  splash_status("Checking FFTW Wisdom file ...");
  if(access(wisdom_file,F_OK)<0) {
      int rc=sem_init(&wisdom_sem, 0, 0);
      rc=pthread_create(&wisdom_thread_id, NULL, wisdom_thread, (void *)wisdom_directory);
      while(sem_trywait(&wisdom_sem)<0) {
        splash_status(wisdom_get_status());
        while (gtk_events_pending ())
          gtk_main_iteration ();
        usleep(100000); // 100ms
      }
  }

  while(!start) {
      gdk_window_set_cursor(gdk_splash_window,cursor_watch);
      selected_device=0;
      devices=0;
      splash_status("Old Protocol ... Discovering Devices");
      old_discovery();
      splash_status("New Protocol ... Discovering Devices");
      new_discovery();
#ifdef LIMESDR
      splash_status("LimeSDR ... Discovering Devices");
      lime_discovery();
#endif
      splash_status("Discovery");
      if(devices==0) {
          gdk_window_set_cursor(gdk_splash_window,cursor_arrow);
          fprintf(stderr,"No devices found!\n");
          GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
          discovery_dialog = gtk_message_dialog_new (GTK_WINDOW(splash_window),
                                 flags,
                                 GTK_MESSAGE_ERROR,
                                 GTK_BUTTONS_OK_CANCEL,
                                 "No devices found! Retry Discovery?");
          gtk_widget_override_font(discovery_dialog, pango_font_description_from_string("FreeMono 18"));
          gint result=gtk_dialog_run (GTK_DIALOG (discovery_dialog));
          gtk_widget_destroy(discovery_dialog);
          if(result==GTK_RESPONSE_CANCEL) {
               _exit(0);
          }
      } else {
          fprintf(stderr,"%s: found %d devices.\n", (char *)arg, devices);
          gdk_window_set_cursor(gdk_splash_window,cursor_arrow);
          GtkDialogFlags flags=GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
          discovery_dialog = gtk_dialog_new_with_buttons ("Discovered",
                                      GTK_WINDOW(splash_window),
                                      flags,
#ifdef GPIO
                                      "Configure GPIO",
                                      GTK_RESPONSE_YES,
#endif
                                      "Discover",
                                      GTK_RESPONSE_REJECT,
                                      "Exit",
                                      GTK_RESPONSE_CLOSE,
                                      NULL);

          gtk_widget_override_font(discovery_dialog, pango_font_description_from_string("FreeMono 18"));
          GtkWidget *content;

          content=gtk_dialog_get_content_area(GTK_DIALOG(discovery_dialog));

          GtkWidget *grid=gtk_grid_new();
          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);

          int i;
          char version[16];
          char text[128];
          for(i=0;i<devices;i++) {
              d=&discovered[i];
fprintf(stderr,"%p protocol=%d name=%s\n",d,d->protocol,d->name);
              if(d->protocol==ORIGINAL_PROTOCOL) {
                  sprintf(version,"%d.%d",
                        d->software_version/10,
                        d->software_version%10);
              } else {
                  sprintf(version,"%d.%d.%d",
                        d->software_version/100,
                        (d->software_version%100)/10,
                        d->software_version%10);
              }
              switch(d->protocol) {
                case ORIGINAL_PROTOCOL:
                case NEW_PROTOCOL:
                  sprintf(text,"%s (%s %s) %s (%02X:%02X:%02X:%02X:%02X:%02X) on %s\n",
                        d->name,
                        d->protocol==ORIGINAL_PROTOCOL?"old":"new",
                        version,
                        inet_ntoa(d->info.network.address.sin_addr),
                        d->info.network.mac_address[0],
                        d->info.network.mac_address[1],
                        d->info.network.mac_address[2],
                        d->info.network.mac_address[3],
                        d->info.network.mac_address[4],
                        d->info.network.mac_address[5],
                        d->info.network.interface_name);
                  break;
#ifdef LIMESDR
                case LIMESDR_PROTOCOL:
/*
                  sprintf(text,"%s (%s %s)\n",
                        d->name,
                        "lime",
                        version);
*/
                  sprintf(text,"%s\n",
                        d->name);
                  break;
#endif
              }

              GtkWidget *label=gtk_label_new(text);
              gtk_widget_override_font(label, pango_font_description_from_string("FreeMono 12"));
              gtk_widget_show(label);
              gtk_grid_attach(GTK_GRID(grid),label,0,i,3,1);

              GtkWidget *start_button=gtk_button_new_with_label("Start");
              gtk_widget_override_font(start_button, pango_font_description_from_string("FreeMono 18"));
              gtk_widget_show(start_button);
              gtk_grid_attach(GTK_GRID(grid),start_button,3,i,1,1);
              g_signal_connect(start_button,"pressed",G_CALLBACK(start_cb),(gpointer)d);

              // if not available then cannot start it
              if(d->status!=STATE_AVAILABLE) {
                gtk_button_set_label(GTK_BUTTON(start_button),"In Use");
                gtk_widget_set_sensitive(start_button, FALSE);
              }

              // if not on the same subnet then cannot start it
              if((d->info.network.interface_address.sin_addr.s_addr&d->info.network.interface_netmask.sin_addr.s_addr) != (d->info.network.address.sin_addr.s_addr&d->info.network.interface_netmask.sin_addr.s_addr)) {
                gtk_button_set_label(GTK_BUTTON(start_button),"Subnet!");
                gtk_widget_set_sensitive(start_button, FALSE);
              }

          }

          gtk_container_add (GTK_CONTAINER (content), grid);
          gtk_widget_show_all(discovery_dialog);
          gint result=gtk_dialog_run(GTK_DIALOG(discovery_dialog));

          if(result==GTK_RESPONSE_CLOSE) {
              _exit(0);
          }
         
          if(!start) {
            gtk_widget_destroy(discovery_dialog);
          }
#ifdef GPIO
          if(result==GTK_RESPONSE_YES) {
              configure_gpio(splash_window);
          }
#endif
      }
  }

  gdk_window_set_cursor(gdk_splash_window,cursor_watch);

  splash_status("Initializing wdsp ...");

fprintf(stderr,"selected radio=%p device=%d\n",radio,radio->device);

  protocol=radio->protocol;
  device=radio->device;


  switch(radio->protocol) {
    case ORIGINAL_PROTOCOL:
    case NEW_PROTOCOL:
      sprintf(property_path,"%02X-%02X-%02X-%02X-%02X-%02X.props",
                        radio->info.network.mac_address[0],
                        radio->info.network.mac_address[1],
                        radio->info.network.mac_address[2],
                        radio->info.network.mac_address[3],
                        radio->info.network.mac_address[4],
                        radio->info.network.mac_address[5]);
      break;
#ifdef LIMESDR
    case LIMESDR_PROTOCOL:
      sprintf(property_path,"limesdr.props");
      break;
#endif
  }

  radioRestoreState();

  fprintf(stderr,"malloc samples\n");
  if(radio->protocol==NEW_PROTOCOL) {
    samples=malloc(display_width*sizeof(float)*2*4); // 192 -> 48
  } else {
    samples=malloc(display_width*sizeof(float)*2);
  }

  //splash_status("Initializing wdsp ...");
  fprintf(stderr,"wdsp_init\n");
  wdsp_init(0,display_width,radio->protocol);

  switch(radio->protocol) {
    case ORIGINAL_PROTOCOL:
      splash_status("Initializing old protocol ...");
  fprintf(stderr,"old_protocol_init\n");
      old_protocol_init(0,display_width);
      break;
    case NEW_PROTOCOL:
      splash_status("Initializing new protocol ...");
  fprintf(stderr,"new_protocol_init\n");
      new_protocol_init(0,display_width);
      break;
#ifdef LIMESDR
    case LIMESDR_PROTOCOL:
      splash_status("Initializing lime protocol ...");
      lime_protocol_init(0,display_width);
      break;
#endif
  }

  fprintf(stderr,"gpio_init\n");
  splash_status("Initializing GPIO ...");
#ifdef GPIO
  if(gpio_init()<0) {
  }
#endif

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "pihpsdr");
  gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS);
  gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
  g_signal_connect (window, "delete-event", G_CALLBACK (main_delete), NULL);

  fixed=gtk_fixed_new();
  gtk_container_add(GTK_CONTAINER(window), fixed);
  y=0;

fprintf(stderr,"vfo_height=%d\n",VFO_HEIGHT);
  vfo = vfo_init(VFO_WIDTH,VFO_HEIGHT,window);
  gtk_fixed_put(GTK_FIXED(fixed),vfo,0,0);



  rit_control = rit_init(RIT_WIDTH,MENU_HEIGHT,window);
  gtk_fixed_put(GTK_FIXED(fixed),rit_control,VFO_WIDTH,y);

fprintf(stderr,"menu_height=%d\n",MENU_HEIGHT);
  //menu = menu_init(MENU_WIDTH,MENU_HEIGHT,window);
  menu = new_menu_init(MENU_WIDTH-RIT_WIDTH,MENU_HEIGHT,window);
  gtk_fixed_put(GTK_FIXED(fixed),menu,VFO_WIDTH+((MENU_WIDTH/3)*2),y);

fprintf(stderr,"meter_height=%d\n",METER_HEIGHT);
  meter = meter_init(METER_WIDTH,METER_HEIGHT,window);
  gtk_fixed_put(GTK_FIXED(fixed),meter,VFO_WIDTH+MENU_WIDTH,y);
  y+=VFO_HEIGHT;

  if(display_panadapter) {
    int height=PANADAPTER_HEIGHT;
    if(!display_waterfall) {
      height+=WATERFALL_HEIGHT;
      if(!display_sliders) {
        height+=SLIDERS_HEIGHT;
      }
      if(!display_toolbar) {
        height+=TOOLBAR_HEIGHT;
      }
    } else {
      if(!display_sliders) {
        height+=SLIDERS_HEIGHT/2;
      }
    }
fprintf(stderr,"panadapter_height=%d\n",height);
    panadapter = panadapter_init(display_width,height);
    gtk_fixed_put(GTK_FIXED(fixed),panadapter,0,VFO_HEIGHT);
    y+=height;
  }

  if(display_waterfall) {
    int height=WATERFALL_HEIGHT;
    if(!display_panadapter) {
      height+=PANADAPTER_HEIGHT;
    }
    if(!display_sliders) {
      if(display_panadapter) {
        height+=SLIDERS_HEIGHT/2;
      } else {
        height+=SLIDERS_HEIGHT;
      }
    }
    if(!display_toolbar) {
      height+=TOOLBAR_HEIGHT;
    }
fprintf(stderr,"waterfall_height=%d\n",height);
    waterfall = waterfall_init(display_width,height);
    gtk_fixed_put(GTK_FIXED(fixed),waterfall,0,y);
    y+=height;

  }

#ifdef PSK
    int psk_height=PSK_WATERFALL_HEIGHT;
    if(!display_sliders) {
      psk_height+=SLIDERS_HEIGHT/2;
    }
    if(!display_toolbar) {
      psk_height+=TOOLBAR_HEIGHT/2;
    }
    psk_waterfall = psk_waterfall_init(display_width,psk_height);
    gtk_fixed_put(GTK_FIXED(fixed),psk_waterfall,0,VFO_HEIGHT);
    psk = init_psk();
    gtk_fixed_put(GTK_FIXED(fixed),psk,0,VFO_HEIGHT+psk_height);
#endif

  if(display_sliders) {
fprintf(stderr,"sliders_height=%d\n",SLIDERS_HEIGHT);
    sliders = sliders_init(display_width,SLIDERS_HEIGHT,window);
    gtk_fixed_put(GTK_FIXED(fixed),sliders,0,y);
    y+=SLIDERS_HEIGHT;
  }

  if(display_toolbar) {
fprintf(stderr,"toolbar_height=%d\n",TOOLBAR_HEIGHT);
    toolbar = toolbar_init(display_width,TOOLBAR_HEIGHT,window);
    gtk_fixed_put(GTK_FIXED(fixed),toolbar,0,y);
    y+=TOOLBAR_HEIGHT;
  }

  splash_close();

  gtk_widget_show_all (window);

  if(full_screen) {
    gtk_window_fullscreen(GTK_WINDOW(window));
  }

  GdkWindow *gdk_window = gtk_widget_get_window(window);
  gdk_window_set_cursor(gdk_window,cursor_arrow);

  // start the receiver
  SetChannelState(CHANNEL_RX0,1,1);

  //update_timer_id=gdk_threads_add_timeout(1000/updates_per_second, update, NULL);
  update_timer_id=gdk_threads_add_timeout_full(G_PRIORITY_HIGH_IDLE,1000/updates_per_second, update, NULL, NULL);

  // save every 30 seconds
  save_timer_id=gdk_threads_add_timeout(30000, save_cb, NULL);


  if(protocol!=NEW_PROTOCOL) {
    setFrequency(getFrequency());
  }

#ifdef PSK
  if(mode==modePSK) {
    show_psk();
  } else {
    show_waterfall();
  }
#endif

  g_idle_add(vfo_update,(gpointer)NULL);

  return 0;
}