Ejemplo n.º 1
0
int 
main (int argc, char **argv)
{
  char *text;
  GtkWidget *window;
  GtkWidget *scrollwin;
  GtkWidget *vbox, *hbox;
  GtkWidget *frame;
  GtkWidget *checkbutton;

  gtk_init (&argc, &argv);
  
  if (argc != 2)
    {
      fprintf (stderr, "Usage: %s FILE\n", g_get_prgname ());
      exit(1);
    }

  /* Create the list of paragraphs from the supplied file
   */
  text = read_file (argv[1]);
  if (!text)
    exit(1);

  context = pango_win32_get_context ();

  paragraphs = split_paragraphs (text);

  pango_context_set_language (context, pango_language_from_string ("en_US"));
  pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);

  font_description = pango_font_description_new ();
  pango_font_description_set_family(font_description, "sans");
  pango_font_description_set_size(font_description, 16 * PANGO_SCALE);
#if 0 /* default init ok? */
  font_description.style = PANGO_STYLE_NORMAL;
  font_description.variant = PANGO_VARIANT_NORMAL;
  font_description.weight = 500;
  font_description.stretch = PANGO_STRETCH_NORMAL;
#endif

  pango_context_set_font_description (context, font_description);

  /* Create the user interface
   */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);

  gtk_signal_connect (GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  vbox = gtk_vbox_new (FALSE, 4);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  hbox = make_font_selector ();
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  
  scrollwin = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
				  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  
  gtk_box_pack_start (GTK_BOX (vbox), scrollwin, TRUE, TRUE, 0);
  
  layout = gtk_layout_new (NULL, NULL);
  gtk_widget_set_events (layout, GDK_BUTTON_PRESS_MASK);
  gtk_widget_set_app_paintable (layout, TRUE);

  gtk_signal_connect (GTK_OBJECT (layout), "size_allocate",
		      GTK_SIGNAL_FUNC (size_allocate), paragraphs);
  gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
		      GTK_SIGNAL_FUNC (expose), paragraphs);
  gtk_signal_connect (GTK_OBJECT (layout), "draw",
		      GTK_SIGNAL_FUNC (draw), paragraphs);
  gtk_signal_connect (GTK_OBJECT (layout), "button_press_event",
		      GTK_SIGNAL_FUNC (button_press), paragraphs);
#if GTK_CHECK_VERSION (1,3,2)
  gtk_widget_set_double_buffered (layout, FALSE);
#endif
  gtk_container_add (GTK_CONTAINER (scrollwin), layout);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

  message_label = gtk_label_new ("Current char:");
  gtk_misc_set_padding (GTK_MISC (message_label), 1, 1);
  gtk_misc_set_alignment (GTK_MISC (message_label), 0.0, 0.5);
  gtk_container_add (GTK_CONTAINER (frame), message_label);

  checkbutton = gtk_check_button_new_with_label ("Use RTL global direction");
  gtk_signal_connect (GTK_OBJECT (checkbutton), "toggled",
		      GTK_SIGNAL_FUNC (checkbutton_toggled), NULL);
  gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0);

  gtk_widget_show_all (window);

  gtk_main ();
  
  return 0;
}
Ejemplo n.º 2
0
// Create and handle the plugin's dialog
gboolean dialog(PluginData *pd)
{
	gimp_ui_init (PLUG_IN_BINARY, FALSE);
	GtkWidget *dialog, *main_hbox, *hbox_buttons, *preview, *graph, *vbox, *preview_button, *preview_hd_checkbox;
	dialog = gimp_dialog_new ("Frequency Curves", PLUG_IN_BINARY,
														NULL, (GtkDialogFlags)0,
														gimp_standard_help_func, PLUG_IN_NAME,
														GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
														GTK_STOCK_OK,     GTK_RESPONSE_OK,
														NULL);
	
	main_hbox = gtk_hbox_new (FALSE, 12);
	gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12);
	gtk_container_add (GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), main_hbox);
	
	curve_init(&pd->curve_user);
	curve_copy(&pd->curve_user, &pd->curve_fft);
	
	pd->preview = gimp_drawable_preview_new (pd->drawable, 0);
	gtk_box_pack_start (GTK_BOX (main_hbox), pd->preview, TRUE, TRUE, 0);
	gtk_widget_show (pd->preview);
	
	g_signal_connect_swapped (pd->preview, "invalidated", G_CALLBACK (preview_invalidated), pd);
	
	vbox = gtk_vbox_new (FALSE, 12);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
	gtk_container_add (GTK_CONTAINER(main_hbox), vbox);
	gtk_widget_show(vbox);
	
	graph = pd->graph = gtk_drawing_area_new();
	pd->graph_pixmap = NULL;
	gtk_widget_set_size_request (graph, GRAPH_WIDTH, GRAPH_HEIGHT);
	gtk_widget_set_events (graph, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | 
	                              GDK_POINTER_MOTION_HINT_MASK | GDK_ENTER_NOTIFY_MASK | 
	                              GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 
	                              GDK_BUTTON1_MOTION_MASK);
	gtk_container_add (GTK_CONTAINER (vbox), graph);
	gtk_widget_show (graph);
	g_signal_connect (graph, "event", G_CALLBACK (graph_events), pd);
	
	hbox_buttons = gtk_hbox_new (FALSE, 12);
	gtk_container_set_border_width (GTK_CONTAINER (hbox_buttons), 12);
	gtk_container_add (GTK_CONTAINER(vbox), hbox_buttons);
	gtk_widget_show(hbox_buttons);
	
	preview_button = gtk_button_new_with_mnemonic ("HD _Preview");
	gtk_box_pack_start (GTK_BOX (hbox_buttons), preview_button, FALSE, FALSE, 0);
	gtk_widget_show (preview_button);
	g_signal_connect (preview_button, "clicked", G_CALLBACK (preview_hd), pd);
	
	preview_hd_checkbox = gtk_check_button_new_with_label("Always preview HD");
	gtk_box_pack_start (GTK_BOX (hbox_buttons), preview_hd_checkbox, FALSE, FALSE, 0);
	gtk_widget_show (preview_hd_checkbox);
	pd->do_preview_hd = FALSE;
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(preview_hd_checkbox), FALSE);
	g_signal_connect (preview_hd_checkbox, "toggled", G_CALLBACK (preview_hd_toggled), pd);
	
	gtk_widget_show(main_hbox);
	gtk_widget_show(dialog);
	fft_prepare(pd);
	histogram_generate(pd);
	wavelet_prepare(pd);
	gboolean run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
	if (run)
	{
		// set the region mode to actual writing
		gimp_pixel_rgn_init(&pd->region, pd->drawable, 0, 0, pd->image_width, pd->image_height, TRUE, TRUE);
		fft_apply(pd);
		gimp_pixel_rgn_set_rect(&pd->region, pd->img_pixels, 0, 0, pd->image_width, pd->image_height);
		// show the result
		gimp_drawable_flush(pd->drawable);
		gimp_drawable_merge_shadow(pd->drawable->drawable_id, TRUE);
		gimp_drawable_update(pd->drawable->drawable_id, pd->selection_offset_x, pd->selection_offset_y, pd->selection_width, pd->selection_height);
		gimp_displays_flush();
	}
	fft_destroy(pd);
	wavelet_destroy(pd);
	gtk_widget_destroy (dialog);
	return run;
}
Ejemplo n.º 3
0
AppletInfo *
mate_panel_applet_register (GtkWidget       *applet,
		       gpointer         data,
		       GDestroyNotify   data_destroy,
		       PanelWidget     *panel,
		       gboolean         locked,
		       gint             pos,
		       gboolean         exactpos,
		       PanelObjectType  type,
		       const char      *id)
{
	AppletInfo *info;
	gchar *path;
	gchar *locked_changed;

	g_return_val_if_fail (applet != NULL && panel != NULL, NULL);

	if (gtk_widget_get_has_window (applet))
		gtk_widget_set_events (applet, (gtk_widget_get_events (applet) |
						APPLET_EVENT_MASK) &
				       ~( GDK_POINTER_MOTION_MASK |
					  GDK_POINTER_MOTION_HINT_MASK));

	info = g_new0 (AppletInfo, 1);
	info->type         = type;
	info->widget       = applet;
	info->menu         = NULL;
	info->data         = data;
	info->data_destroy = data_destroy;
	info->user_menu    = NULL;
	info->move_item    = NULL;
	info->id           = g_strdup (id);

	path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
	info->settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
	g_free (path);

	g_object_set_data (G_OBJECT (applet), "applet_info", info);

	if (type != PANEL_OBJECT_APPLET)
		panel_lockdown_notify_add (G_CALLBACK (mate_panel_applet_recreate_menu),
					   info);

	locked_changed = g_strdup_printf ("changed::%s", PANEL_OBJECT_LOCKED_KEY);
	g_signal_connect (info->settings,
					  locked_changed,
					  G_CALLBACK (mate_panel_applet_locked_change_notify),
					  G_OBJECT (applet));
	g_free (locked_changed);

	if (type == PANEL_OBJECT_DRAWER) {
		Drawer *drawer = data;
		PanelWidget *assoc_panel;

		assoc_panel = panel_toplevel_get_panel_widget (drawer->toplevel);

		g_object_set_data (G_OBJECT (applet),
				   MATE_PANEL_APPLET_ASSOC_PANEL_KEY, assoc_panel);
		assoc_panel->master_widget = applet;
		g_object_add_weak_pointer (
			G_OBJECT (applet), (gpointer *) &assoc_panel->master_widget);
	}

	g_object_set_data (G_OBJECT (applet),
			   MATE_PANEL_APPLET_FORBIDDEN_PANELS, NULL);

	registered_applets = g_slist_append (registered_applets, info);

	if (panel_widget_add (panel, applet, locked, pos, exactpos) == -1 &&
	    panel_widget_add (panel, applet, locked, 0, TRUE) == -1) {
		GSList *l;

		for (l = panels; l; l = l->next) {
			panel = PANEL_WIDGET (l->data);

			if (panel_widget_add (panel, applet, locked, 0, TRUE) != -1)
				break;
		}

		if (!l) {
			g_warning (_("Cannot find an empty spot"));
			panel_profile_delete_object (info);
			return NULL;
		}
	}

	if (BUTTON_IS_WIDGET (applet) ||
	    gtk_widget_get_has_window (applet)) {
		g_signal_connect (applet, "button_press_event",
				  G_CALLBACK (applet_button_press),
				  info);

		g_signal_connect (applet, "popup_menu",
				  G_CALLBACK (applet_popup_menu),
				  info);
	}

	g_signal_connect (applet, "destroy",
			  G_CALLBACK (mate_panel_applet_destroy),
			  info);

	mate_panel_applet_set_dnd_enabled (info, !locked);

	gtk_widget_show_all (applet);

	orientation_change (info, panel);
	size_change (info, panel);
	back_change (info, panel);

	if (type != PANEL_OBJECT_APPLET)
		gtk_widget_grab_focus (applet);
	else
		gtk_widget_child_focus (applet, GTK_DIR_TAB_FORWARD);

	return info;
}
Ejemplo n.º 4
0
int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *drawing_area;
  GtkWidget *vbox;

  GtkWidget *button;

  gtk_init (&argc, &argv);

  current_device = gdk_device_get_core_pointer ();

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (window, "Test Input");

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

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

  /* Create the drawing area */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 200, 200);
  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /* Signals used to handle backing pixmap */

  g_signal_connect (drawing_area, "expose_event",
		    G_CALLBACK (expose_event), NULL);
  g_signal_connect (drawing_area, "configure_event",
		    G_CALLBACK (configure_event), NULL);

  /* Event signals */

  g_signal_connect (drawing_area, "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);
  g_signal_connect (drawing_area, "button_press_event",
		    G_CALLBACK (button_press_event), NULL);
  g_signal_connect (drawing_area, "key_press_event",
		    G_CALLBACK (key_press_event), NULL);

  g_signal_connect (drawing_area, "leave_notify_event",
		    G_CALLBACK (leave_notify_event), NULL);
  g_signal_connect (drawing_area, "proximity_out_event",
		    G_CALLBACK (proximity_out_event), NULL);

  gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
			 | GDK_LEAVE_NOTIFY_MASK
			 | GDK_BUTTON_PRESS_MASK
			 | GDK_KEY_PRESS_MASK
			 | GDK_POINTER_MOTION_MASK
			 | GDK_POINTER_MOTION_HINT_MASK
			 | GDK_PROXIMITY_OUT_MASK);

  /* The following call enables tracking and processing of extension
     events for the drawing area */
  gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_ALL);

  GTK_WIDGET_SET_FLAGS (drawing_area, GTK_CAN_FOCUS);
  gtk_widget_grab_focus (drawing_area);

  /* .. And create some buttons */
  button = gtk_button_new_with_label ("Input Dialog");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  g_signal_connect (button, "clicked",
		    G_CALLBACK (create_input_dialog), NULL);
  gtk_widget_show (button);

  button = gtk_button_new_with_label ("Quit");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  g_signal_connect_swapped (button, "clicked",
			    G_CALLBACK (gtk_widget_destroy),
			    window);
  gtk_widget_show (button);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: jyby/xournal
void init_stuff (int argc, char *argv[])
{
  GtkWidget *w;
  GList *dev_list;
  GdkDevice *device;
  GdkScreen *screen;
  int i, j;
  struct Brush *b;
  gboolean can_xinput, success;
  gchar *tmppath, *tmpfn;

  // create some data structures needed to populate the preferences
  ui.default_page.bg = g_new(struct Background, 1);

  // initialize config file names
  tmppath = g_build_filename(g_get_home_dir(), CONFIG_DIR, NULL);
  mkdir(tmppath, 0700); // safer (MRU data may be confidential)
  ui.mrufile = g_build_filename(tmppath, MRU_FILE, NULL);
  ui.configfile = g_build_filename(tmppath, CONFIG_FILE, NULL);
  g_free(tmppath);

  // initialize preferences
  init_config_default();
  load_config_from_file();
  ui.font_name = g_strdup(ui.default_font_name);
  ui.font_size = ui.default_font_size;
  ui.hiliter_alpha_mask = 0xffffff00 + (guint)(255*ui.hiliter_opacity);

  // we need an empty canvas prior to creating the journal structures
  canvas = GNOME_CANVAS (gnome_canvas_new_aa ());

  // initialize data
  ui.default_page.bg->canvas_item = NULL;
  ui.layerbox_length = 0;

  if (argc > 2 || (argc == 2 && argv[1][0] == '-')) {
    printf(_("Invalid command line parameters.\n"
           "Usage: %s [filename.xoj]\n"), argv[0]);
    gtk_exit(0);
  }
   
  undo = NULL; redo = NULL;
  journal.pages = NULL;
  bgpdf.status = STATUS_NOT_INIT;

  new_journal();  
  
  ui.cur_item_type = ITEM_NONE;
  ui.cur_item = NULL;
  ui.cur_path.coords = NULL;
  ui.cur_path_storage_alloc = 0;
  ui.cur_path.ref_count = 1;
  ui.cur_widths = NULL;
  ui.cur_widths_storage_alloc = 0;

  ui.selection = NULL;
  ui.cursor = NULL;
  ui.pen_cursor_pix = ui.hiliter_cursor_pix = NULL;

  ui.cur_brush = &(ui.brushes[0][ui.toolno[0]]);
  for (j=0; j<=NUM_BUTTONS; j++)
    for (i=0; i < NUM_STROKE_TOOLS; i++) {
      b = &(ui.brushes[j][i]);
      b->tool_type = i;
      if (b->color_no>=0) {
        b->color_rgba = predef_colors_rgba[b->color_no];
        if (i == TOOL_HIGHLIGHTER) {
          b->color_rgba &= ui.hiliter_alpha_mask;
        }
      }
      b->thickness = predef_thickness[i][b->thickness_no];
    }
  for (i=0; i<NUM_STROKE_TOOLS; i++)
    g_memmove(ui.default_brushes+i, &(ui.brushes[0][i]), sizeof(struct Brush));

  ui.cur_mapping = 0;
  ui.which_unswitch_button = 0;
  ui.in_proximity = FALSE;
  ui.warned_generate_fontconfig = FALSE;
  
  reset_recognizer();

  // initialize various interface elements
  
  gtk_window_set_default_size(GTK_WINDOW (winMain), ui.window_default_width, ui.window_default_height);
  if (ui.maximize_at_start) gtk_window_maximize(GTK_WINDOW (winMain));
  update_toolbar_and_menu();
  update_font_button();

  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("journalApplyAllPages")), ui.bg_apply_all_pages);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("journalNewPageKeepsBG")), ui.new_page_bg_from_pdf);
  if (ui.fullscreen) {
    gtk_check_menu_item_set_active(
      GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), TRUE);
    gtk_toggle_tool_button_set_active(
      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), TRUE);
    gtk_window_fullscreen(GTK_WINDOW(winMain));
  }
  gtk_button_set_relief(GTK_BUTTON(GET_COMPONENT("buttonColorChooser")), GTK_RELIEF_NONE);

  allow_all_accels();
  add_scroll_bindings();

  // prevent interface items from stealing focus
  // glade doesn't properly handle can_focus, so manually set it
  gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(GET_COMPONENT("comboLayer")), FALSE);
  g_signal_connect(GET_COMPONENT("spinPageNo"), "activate",
          G_CALLBACK(handle_activate_signal), NULL);
  gtk_container_forall(GTK_CONTAINER(winMain), unset_flags, (gpointer)GTK_CAN_FOCUS);
  GTK_WIDGET_SET_FLAGS(GTK_WIDGET(canvas), GTK_CAN_FOCUS);
  GTK_WIDGET_SET_FLAGS(GTK_WIDGET(GET_COMPONENT("spinPageNo")), GTK_CAN_FOCUS);
  
  // install hooks on button/key/activation events to make the spinPageNo lose focus
  gtk_container_forall(GTK_CONTAINER(winMain), install_focus_hooks, NULL);

  // set up and initialize the canvas

  gtk_widget_show (GTK_WIDGET (canvas));
  w = GET_COMPONENT("scrolledwindowMain");
  gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (canvas));
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_events (GTK_WIDGET (canvas), 
     GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | 
     GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | 
     GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
     GDK_PROXIMITY_IN_MASK | GDK_PROXIMITY_OUT_MASK);
  gnome_canvas_set_pixels_per_unit (canvas, ui.zoom);
  gnome_canvas_set_center_scroll_region (canvas, TRUE);
  gtk_layout_get_hadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment;
  gtk_layout_get_vadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment;

  // set up the page size and canvas size
  update_page_stuff();

  g_signal_connect ((gpointer) canvas, "button_press_event",
                    G_CALLBACK (on_canvas_button_press_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "button_release_event",
                    G_CALLBACK (on_canvas_button_release_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "enter_notify_event",
                    G_CALLBACK (on_canvas_enter_notify_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "leave_notify_event",
                    G_CALLBACK (on_canvas_leave_notify_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "proximity_in_event",
                    G_CALLBACK (on_canvas_proximity_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "proximity_out_event",
                    G_CALLBACK (on_canvas_proximity_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "expose_event",
                    G_CALLBACK (on_canvas_expose_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "key_press_event",
                    G_CALLBACK (on_canvas_key_press_event),
                    NULL);
  g_signal_connect ((gpointer) canvas, "motion_notify_event",
                    G_CALLBACK (on_canvas_motion_notify_event),
                    NULL);
  g_signal_connect ((gpointer) gtk_layout_get_vadjustment(GTK_LAYOUT(canvas)),
                    "value-changed", G_CALLBACK (on_vscroll_changed),
                    NULL);
  g_signal_connect ((gpointer) gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)),
                    "value-changed", G_CALLBACK (on_hscroll_changed),
                    NULL);
  g_object_set_data (G_OBJECT (winMain), "canvas", canvas);

  screen = gtk_widget_get_screen(winMain);
  ui.screen_width = gdk_screen_get_width(screen);
  ui.screen_height = gdk_screen_get_height(screen);
  
  can_xinput = FALSE;
  dev_list = gdk_devices_list();
  while (dev_list != NULL) {
    device = (GdkDevice *)dev_list->data;
    if (device != gdk_device_get_core_pointer() && device->num_axes >= 2) {
      /* get around a GDK bug: map the valuator range CORRECTLY to [0,1] */
#ifdef ENABLE_XINPUT_BUGFIX
      gdk_device_set_axis_use(device, 0, GDK_AXIS_IGNORE);
      gdk_device_set_axis_use(device, 1, GDK_AXIS_IGNORE);
#endif
      gdk_device_set_mode(device, GDK_MODE_SCREEN);
      if (g_strrstr(device->name, "raser"))
        gdk_device_set_source(device, GDK_SOURCE_ERASER);
      can_xinput = TRUE;
    }
    dev_list = dev_list->next;
  }
  if (!can_xinput)
    gtk_widget_set_sensitive(GET_COMPONENT("optionsUseXInput"), FALSE);

  ui.use_xinput = ui.allow_xinput && can_xinput;

  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsProgressiveBG")), ui.progressive_bg);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPrintRuling")), ui.print_ruling);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutoloadPdfXoj")), ui.autoload_pdf_xoj);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutosaveXoj")), ui.autosave_enabled);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsLeftHanded")), ui.left_handed);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsShortenMenus")), ui.shorten_menus);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutoSavePrefs")), ui.auto_save_prefs);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsButtonSwitchMapping")), ui.button_switch_mapping);
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPenCursor")), ui.pen_cursor);
  
  hide_unimplemented();

  update_undo_redo_enabled();
  update_copy_paste_enabled();
  update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]);
  gtk_widget_grab_focus(GTK_WIDGET(canvas));

  // show everything...
  
  gtk_widget_show (winMain);
  update_cursor();

  /* this will cause extension events to get enabled/disabled, but
     we need the windows to be mapped first */
  gtk_check_menu_item_set_active(
    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsUseXInput")), ui.use_xinput);

  /* fix a bug in GTK+ 2.16 and 2.17: scrollbars shouldn't get extended
     input events from pointer motion when cursor moves into main window */

  if (!gtk_check_version(2, 16, 0)) {
    g_signal_connect (
      GET_COMPONENT("menubar"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      GET_COMPONENT("toolbarMain"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      GET_COMPONENT("toolbarPen"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      GET_COMPONENT("statusbar"),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      (gpointer)(gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(w))),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
    g_signal_connect (
      (gpointer)(gtk_scrolled_window_get_hscrollbar(GTK_SCROLLED_WINDOW(w))),
      "event", G_CALLBACK (filter_extended_events),
      NULL);
  }

  // load the MRU
  
  init_mru();

  // and finally, open a file specified on the command line
  // (moved here because display parameters weren't initialized yet...)
  
  if (argc == 1) return;
  set_cursor_busy(TRUE);
  if (g_path_is_absolute(argv[1]))
    tmpfn = g_strdup(argv[1]);
  else {
    tmppath = g_get_current_dir();
    tmpfn = g_build_filename(tmppath, argv[1], NULL);
    g_free(tmppath);
  }
  success = open_journal(tmpfn);
  g_free(tmpfn);
  set_cursor_busy(FALSE);
  if (!success) {
    w = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
       GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), argv[1]);
    gtk_dialog_run(GTK_DIALOG(w));
    gtk_widget_destroy(w);
  }
}
Ejemplo n.º 6
0
/*********************************************
* AddReferenceImage関数                      *
* 参考用画像の表示を追加                     *
* 引数                                       *
* reference	: 参考用画像表示ウィンドウの情報 *
* file_name	: 追加するファイル名             *
* pixels	: 画像のピクセルデータ           *
* width		: 画像の幅                       *
* height	: 画像の高さ                     *
* stride	: 画像の1行分のバイト数          *
* channel	: 画像のチャンネル数             *
*********************************************/
static void AddReferenceImage(
	REFERENCE_WINDOW* reference,
	const char* file_name,
	uint8* pixels,
	int width,
	int height,
	int stride,
	int channel
)
{
	GtkWidget *tab_label;
	GtkWidget *alignment;
	cairo_format_t format = (stride / width == 4) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;

	REFERENCE_IMAGE *image;
	image = reference->data->images[reference->data->num_image] =
		(REFERENCE_IMAGE*)MEM_ALLOC_FUNC(sizeof(**reference->data->images));
	image->pixels = pixels;
	image->width = width;
	image->height = height;
	image->stride = stride;
	image->channel = (uint8)channel;
	image->surface_p = cairo_image_surface_create_for_data(image->pixels,
		format, image->width, image->height, image->stride);
	image->zoom = image->rev_zoom = 1;
	image->app = reference->app;

	image->draw_area = gtk_drawing_area_new();
	gtk_widget_set_size_request(image->draw_area, image->width, image->height);
	gtk_widget_set_events(image->draw_area, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
		| GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
	(void)g_signal_connect(G_OBJECT(image->draw_area), "destroy",
		G_CALLBACK(OnDestroyReferenceImageDrawArea), image);
#if GTK_MAJOR_VERSION <= 2
	(void)g_signal_connect(G_OBJECT(image->draw_area), "expose_event",
		G_CALLBACK(DisplayReferenceImage), image);
#else
	(void)g_signal_connect(G_OBJECT(image->draw_area), "draw",
		G_CALLBACK(DisplayReferenceImage), image);
#endif
	(void)g_signal_connect(G_OBJECT(image->draw_area), "button_press_event",
		G_CALLBACK(ReferenceImageButtonPress), image);
	alignment = gtk_alignment_new(0.5f, 0.5f, 0.0f, 0.0f);
	gtk_container_add(GTK_CONTAINER(alignment), image->draw_area);

	image->scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(image->scroll),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(image->scroll), alignment);

	tab_label = CreateNotebookLabel(file_name, reference->data->note_book, reference->data->num_image,
		OnCloseReferenceImage, reference);
	gtk_notebook_append_page(GTK_NOTEBOOK(reference->data->note_book), image->scroll, tab_label);

	gtk_widget_show_all(image->scroll);
	gtk_widget_set_sensitive(reference->data->scale, TRUE);
	reference->data->active_image = reference->data->num_image;
#if GTK_MAJOR_VERSION <= 2
	gtk_notebook_set_page(GTK_NOTEBOOK(reference->data->note_book), reference->data->active_image);
#else
	gtk_notebook_set_current_page(GTK_NOTEBOOK(reference->data->note_book), reference->data->active_image);
#endif

	reference->data->num_image++;
}
Ejemplo n.º 7
0
int main( int   argc,char *argv[] )
{
  
  GtkWidget *vbox;
  GtkWidget *hbox;

  
  GtkWidget* menubar;
  GtkWidget* main_toolbar;	
  GtkWidget* tools_toolbar;	
  
  GtkWidget* colortable;	
  GtkWidget* frame;
  
  gtk_init (&argc, &argv);
 
  modified=0;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  gtk_window_set_title (GTK_WINDOW(window), "Illuminati");
 
  g_signal_connect (G_OBJECT (window), "delete-event",
                    G_CALLBACK (delete_event), NULL);

  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (delete_event), NULL);

  vbox = gtk_vbox_new (FALSE, 0);

  gtk_container_add(GTK_CONTAINER(window), vbox);
  

 
  /*To create the menu bar*/
  menubar = get_menubar_menu (window);

  gtk_box_pack_start (GTK_BOX(vbox),menubar, FALSE, FALSE, 0);
  gtk_widget_show (menubar);


 

  main_toolbar=get_main_toolbar();

 /* to make it nice we'll put the toolbar into the handle box, 
   * so that it can be detached from the main window */
  mainhandlebox = gtk_handle_box_new ();

  gtk_box_pack_start (GTK_BOX (vbox),mainhandlebox, FALSE, FALSE, 5);
  gtk_container_add (GTK_CONTAINER (mainhandlebox), main_toolbar);
  gtk_widget_show (main_toolbar);
  gtk_widget_show (mainhandlebox);

  

  /*hbox for tools_toolbar and drawing area*/
  hbox = gtk_hbox_new (FALSE, 2);

  gtk_box_pack_start (GTK_BOX (vbox),hbox, FALSE, FALSE, 0);

  tools_toolbar=get_tools_toolbar();
  toolhandlebox = gtk_handle_box_new ();

  gtk_box_pack_start (GTK_BOX(hbox),toolhandlebox, FALSE, FALSE, 5);
  gtk_container_add (GTK_CONTAINER (toolhandlebox), tools_toolbar);
  gtk_widget_show (tools_toolbar);
  gtk_widget_show (toolhandlebox);



  
  scrolled_win = gtk_scrolled_window_new (NULL, NULL);

  gtk_widget_set_size_request (GTK_WIDGET (scrolled_win),400,400);
  gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 1);

  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  

  gtk_box_pack_start (GTK_BOX (hbox), scrolled_win, TRUE, TRUE, 0);



  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (GTK_WIDGET (drawing_area),800,600);

  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),drawing_area);



  gtk_widget_show (drawing_area);


  gtk_widget_show (scrolled_win);



  gtk_widget_show (hbox);



  /* Signals used to handle backing pixmap */

  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
		    G_CALLBACK (expose_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area),"configure_event",
		    G_CALLBACK (configure_event), NULL);

  /* Event signals */

  g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "button_press_event",
		    G_CALLBACK (button_press_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "button_release_event",
                    G_CALLBACK(button_release_event),NULL);

  gtk_widget_set_events (drawing_area,GDK_EXPOSURE_MASK
			 | GDK_LEAVE_NOTIFY_MASK
                         | GDK_BUTTON_PRESS_MASK
			 | GDK_POINTER_MOTION_MASK
			 | GDK_POINTER_MOTION_HINT_MASK
                         | GDK_BUTTON_RELEASE_MASK);

   hbox = gtk_hbox_new (FALSE,0);

   gtk_box_pack_start(GTK_BOX (vbox),hbox, FALSE, FALSE, 2);
   

   frame=get_fgbgframe();
   

   gtk_box_pack_start(GTK_BOX (hbox),frame, FALSE, FALSE, 2);

   gtk_widget_show(frame);

   colortable=get_system_color_table();
  
   frame=gtk_frame_new("select color");

   gtk_widget_set_size_request (GTK_WIDGET (frame),400,75);

   gtk_box_pack_start(GTK_BOX (hbox),frame, TRUE, TRUE, 2);
  
   gtk_container_add(GTK_CONTAINER(frame),colortable); 


   gtk_widget_show (colortable); 

   gtk_widget_show(frame);

   gtk_widget_show (hbox);


   gtk_widget_show(vbox);

   gtk_widget_show(window);

  /*Initial tool set to PENCIL */
 
  display=gdk_display_get_default();              
 
  cursor=gdk_cursor_new(GDK_PENCIL);

  gdk_window_set_cursor(drawing_area->window,cursor);

  tool=PENCIL;

  gtk_button_set_relief(GTK_BUTTON(pencil_button),GTK_RELIEF_NORMAL);

  filename=g_strdup("Untitled.jpeg");	

  pixmap = gdk_pixmap_new (drawing_area->window,
			   drawing_area->allocation.width,
			   drawing_area->allocation.height,
			   -1);
  gdk_draw_rectangle (pixmap,
		      drawing_area->style->white_gc,
		      TRUE,
		      0, 0,
		      drawing_area->allocation.width,
		      drawing_area->allocation.height);


  gtk_main ();

  return 0;
}
Ejemplo n.º 8
0
GtkWidget *
do_drawingarea (GtkWidget *do_widget)
{
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *da;
  GtkWidget *label;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");

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

      gtk_container_set_border_width (GTK_CONTAINER (window), 8);

      vbox = gtk_vbox_new (FALSE, 8);
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
      gtk_container_add (GTK_CONTAINER (window), vbox);

      /*
       * Create the checkerboard area
       */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Checkerboard pattern</u>");
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);

      da = gtk_drawing_area_new ();
      /* set a minimum size */
      gtk_widget_set_size_request (da, 100, 100);

      gtk_container_add (GTK_CONTAINER (frame), da);

      g_signal_connect (da, "expose-event",
                        G_CALLBACK (checkerboard_expose), NULL);

      /*
       * Create the scribble area
       */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Scribble area</u>");
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);

      da = gtk_drawing_area_new ();
      /* set a minimum size */
      gtk_widget_set_size_request (da, 100, 100);

      gtk_container_add (GTK_CONTAINER (frame), da);

      /* Signals used to handle backing pixmap */

      g_signal_connect (da, "expose-event",
                        G_CALLBACK (scribble_expose_event), NULL);
      g_signal_connect (da,"configure-event",
                        G_CALLBACK (scribble_configure_event), NULL);

      /* Event signals */

      g_signal_connect (da, "motion-notify-event",
                        G_CALLBACK (scribble_motion_notify_event), NULL);
      g_signal_connect (da, "button-press-event",
                        G_CALLBACK (scribble_button_press_event), NULL);


      /* Ask to receive events the drawing area doesn't normally
       * subscribe to
       */
      gtk_widget_set_events (da, gtk_widget_get_events (da)
                             | GDK_LEAVE_NOTIFY_MASK
                             | GDK_BUTTON_PRESS_MASK
                             | GDK_POINTER_MOTION_MASK
                             | GDK_POINTER_MOTION_HINT_MASK);

    }

  if (!gtk_widget_get_visible (window))
      gtk_widget_show_all (window);
  else
      gtk_widget_destroy (window);

  return window;
}
Ejemplo n.º 9
0
void
gui_init (dt_lib_module_t *self)
{
  dt_lib_collect_t *d = (dt_lib_collect_t *)malloc(sizeof(dt_lib_collect_t));

  self->data = (void *)d;
  self->widget = gtk_vbox_new(FALSE, 5);
  gtk_widget_set_size_request(self->widget, 100, -1);
  d->active_rule = 0;
  d->params = (dt_lib_collect_params_t*)malloc(sizeof(dt_lib_collect_params_t));

  dt_control_signal_connect(darktable.signals,
                            DT_SIGNAL_COLLECTION_CHANGED,
                            G_CALLBACK(collection_updated),
                            self);

  GtkBox *box;
  GtkWidget *w;
  GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
  GtkTreeView *view = GTK_TREE_VIEW(gtk_tree_view_new());
  d->view = view;
  GtkListStore *liststore;

  for(int i=0; i<MAX_RULES; i++)
  {
    d->rule[i].num = i;
    box = GTK_BOX(gtk_hbox_new(FALSE, 5));
    d->rule[i].hbox = GTK_WIDGET(box);
    gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 0);
    w = gtk_combo_box_new_text();
    d->rule[i].combo = GTK_COMBO_BOX(w);
    for(int k=0; k<dt_lib_collect_string_cnt; k++)
      gtk_combo_box_append_text(GTK_COMBO_BOX(w), _(dt_lib_collect_string[k]));
    g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(combo_changed), d->rule + i);
    gtk_box_pack_start(box, w, FALSE, FALSE, 0);
    w = gtk_entry_new();
    dt_gui_key_accel_block_on_focus(w);
    d->rule[i].text = w;
    gtk_widget_add_events(w, GDK_FOCUS_CHANGE_MASK);
    g_signal_connect(G_OBJECT(w), "focus-in-event", G_CALLBACK(entry_focus_in_callback), d->rule + i);

    /* xgettext:no-c-format */
    g_object_set(G_OBJECT(w), "tooltip-text", _("type your query, use `%' as wildcard"), (char *)NULL);
    gtk_widget_add_events(w, GDK_KEY_PRESS_MASK);
    g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(changed_callback), d->rule + i);
    g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(entry_activated), d->rule + i);
    gtk_box_pack_start(box, w, TRUE, TRUE, 0);
    w = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER);
    d->rule[i].button = w;
    gtk_widget_set_events(w, GDK_BUTTON_PRESS_MASK);
    g_signal_connect(G_OBJECT(w), "button-press-event", G_CALLBACK(popup_button_callback), d->rule + i);
    gtk_box_pack_start(box, w, FALSE, FALSE, 0);
    gtk_widget_set_size_request(w, 13, 13);
  }

  d->scrolledwindow = GTK_SCROLLED_WINDOW(sw);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(view));
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(sw), TRUE, TRUE, 0);
  gtk_tree_view_set_headers_visible(view, FALSE);
  liststore = gtk_list_store_new(DT_LIB_COLLECT_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
  GtkTreeViewColumn *col = gtk_tree_view_column_new();
  gtk_tree_view_append_column(view, col);
  gtk_widget_set_size_request(GTK_WIDGET(view), -1, 300);
  GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
  gtk_tree_view_column_pack_start(col, renderer, TRUE);
  gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_COLLECT_COL_TEXT);
  gtk_tree_selection_set_mode(gtk_tree_view_get_selection(view), GTK_SELECTION_SINGLE);
  gtk_tree_view_set_model(view, GTK_TREE_MODEL(liststore));
  g_signal_connect(G_OBJECT (view), "row-activated", G_CALLBACK (row_activated), d);

  /* setup proxy */
  darktable.view_manager->proxy.module_collect.module = self;
  darktable.view_manager->proxy.module_collect.update = _lib_collect_gui_update;

  _lib_collect_gui_update(self);
}
Ejemplo n.º 10
0
void create_mainwindow (GooCanvasItem *rootitem)
{
  GtkWidget *wdrawareagrande;
  GtkWidget *wdrawareapetite;


  /* GCompris : suppression of all menus */
  g_assert(rootitem != NULL);

  wdrawareagrande = gtk_drawing_area_new ();
  gtk_widget_set_name (wdrawareagrande, "wdrawareagrande");
  //gtk_widget_set_size_request     (wdrawareagrande,
  //                               WIDTH_BIGAREA,
  //			   WIDTH_BIGAREA
  //			   );

  //gtk_container_add (GTK_CONTAINER (aspectframe1), wdrawareagrande);

  gtk_widget_set_events (wdrawareagrande, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK);

  /* Gcompris */
  goo_canvas_widget_new ( rootitem,
			wdrawareagrande,
			X_BASE_BIGAREA,
			Y_BASE_BIGAREA,
			WIDTH_BIGAREA,
			WIDTH_BIGAREA,
			NULL
			);

  gtk_widget_show (wdrawareagrande);

  wdrawareapetite = gtk_drawing_area_new ();
  gtk_widget_set_name (wdrawareapetite, "wdrawareapetite");

  gtk_widget_set_events (wdrawareapetite, GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);

  /* Gcompris */
  goo_canvas_widget_new ( rootitem,
			  wdrawareapetite,
			  X_BASE_SMALLAREA,
			  Y_BASE_SMALLAREA,
			  WIDTH_SMALLAREA,
			  WIDTH_SMALLAREA,
			  NULL
			  );

  gtk_widget_show (wdrawareapetite);

  g_signal_connect (GTK_OBJECT (wdrawareagrande), "expose_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_expose_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (wdrawareagrande), "configure_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_configure_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (wdrawareagrande), "button_press_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_button_press_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (wdrawareagrande), "button_release_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_button_release_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (wdrawareagrande), "motion_notify_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_motion_notify_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (wdrawareapetite), "configure_event",
                      GTK_SIGNAL_FUNC (on_wdrawareapetite_configure_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (wdrawareapetite), "expose_event",
                      GTK_SIGNAL_FUNC (on_wdrawareapetite_expose_event),
                      NULL);


  /* Gcompris */
  /* add here buttons */

  GdkPixbuf   *pixmap_show = NULL;
  GdkPixbuf   *pixmap_outline = NULL;
  GdkPixbuf   *pixmap_symetry = NULL;
  GooCanvasItem *previous_figure, *next_figure;
  GooCanvasItem *show_figure, *outline_figure, *symetry;

  previous_figure = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", "#PREVIOUS",
					NULL);
  SET_ITEM_LOCATION_CENTER(previous_figure,
			   X_BASE_SMALLAREA,
			   Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 30);

  next_figure = goo_canvas_svg_new (rootitem,
				    gc_skin_rsvg_get(),
				    "svg-id", "#NEXT",
				    NULL);
  SET_ITEM_LOCATION_CENTER(next_figure,
			   X_BASE_SMALLAREA + WIDTH_SMALLAREA,
			   Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 30);


  g_signal_connect(previous_figure, "button_press_event",
		     (GCallback) on_arrow_clicked,
		     (gpointer) FALSE);

  gc_item_focus_init(previous_figure, NULL);

  g_signal_connect(next_figure, "button_press_event",
		     (GCallback) on_arrow_clicked,
		     (gpointer) TRUE);

  gc_item_focus_init(next_figure, NULL);

  pixmap_show = gc_pixmap_load("tangram/gtans_show.png");

  pixmap_outline = gc_pixmap_load("tangram/gtans_outline.png");

  show_figure = goo_canvas_image_new (rootitem,
				      pixmap_show,
				      X_BASE_SMALLAREA,
				      Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 80,
				      NULL);

  outline_figure = goo_canvas_image_new (rootitem,
					 pixmap_outline,
					 X_BASE_SMALLAREA,
					 Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 130,
					 NULL);

  g_signal_connect(outline_figure, "button_press_event",
		     (GCallback) on_outline_clicked,
		     NULL);

  g_signal_connect(show_figure, "button_press_event",
		     (GCallback) on_show_clicked,
		     NULL);

  gc_item_focus_init(outline_figure, NULL);

  gc_item_focus_init(show_figure, NULL);

  pixmap_symetry = gc_pixmap_load("tangram/tool-flip.png");


  symetry = goo_canvas_image_new (rootitem,
				  pixmap_symetry,
				  X_BASE_SMALLAREA + WIDTH_SMALLAREA - 50,
				  Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 180,
				  NULL);

  g_signal_connect(symetry, "button_press_event",
		     (GCallback) on_symetry_clicked,
		     NULL);

  gc_item_focus_init(symetry, NULL);


  /* rotation buttons */
  GdkPixbuf   *right_rot = NULL;
  GdkPixbuf   *left_rot = NULL;
  GdkPixbuf   *right_rot_big = NULL;
  GdkPixbuf   *left_rot_big = NULL;
  GooCanvasItem *l_rot_s, *r_rot_s, *l_rot_b,  *r_rot_b;

  right_rot       = gc_pixmap_load("tangram/gtans_rotate.png");
  left_rot        = gc_pixmap_load("tangram/gtans_rotate-left.png");

  r_rot_s = goo_canvas_image_new (rootitem,
				  right_rot,
				  X_BASE_SMALLAREA + WIDTH_SMALLAREA,
				  Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60,
				   NULL);


  l_rot_s = goo_canvas_image_new (rootitem,
				  left_rot,
				  X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100,
				  Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60,
				  NULL);


#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(right_rot);
  gdk_pixbuf_unref(left_rot);
#else
  g_object_unref(right_rot);
  g_object_unref(left_rot);
#endif

  right_rot_big   = gc_pixmap_load("tangram/gtans_2x-rotate.png");
  left_rot_big    = gc_pixmap_load("tangram/gtans_2x-rotate-left.png");

  r_rot_b = goo_canvas_image_new (rootitem,
				  right_rot_big,
				  X_BASE_SMALLAREA + WIDTH_SMALLAREA,
				  Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120,
				   NULL);


  l_rot_b = goo_canvas_image_new (rootitem,
				  left_rot_big,
				  X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100,
				  Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120,
				   NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(right_rot_big);
  gdk_pixbuf_unref(left_rot_big);
#else
  g_object_unref(right_rot_big);
  g_object_unref(left_rot_big);
#endif


  g_signal_connect(r_rot_s, "button_press_event",
		     (GCallback) on_rotation_clicked,
		     (gpointer) 0);

  gc_item_focus_init(r_rot_s, NULL);

  g_signal_connect(l_rot_s, "button_press_event",
		     (GCallback) on_rotation_clicked,
		     (gpointer) 1);

  gc_item_focus_init(l_rot_s, NULL);

  g_signal_connect(r_rot_b, "button_press_event",
		     (GCallback) on_rotation_clicked,
		     (gpointer) 2);

  gc_item_focus_init(r_rot_b, NULL);

  g_signal_connect(l_rot_b, "button_press_event",
		     (GCallback) on_rotation_clicked,
		     (gpointer) 3);

  gc_item_focus_init(l_rot_b, NULL);
}
Ejemplo n.º 11
0
Archivo: ui.c Proyecto: barak/gtkboard
void gui_init ()
{
	GtkWidget *hbox = NULL, *vbox = NULL, *vbox1 = NULL, *frame = NULL;
	GtkWidget *separator;
	GtkAccelGroup *ag;
	GtkItemFactoryEntry game_items [num_games+1];
	GtkItemFactoryEntry items[] = 
	{
#if GTK_MAJOR_VERSION == 1
/*		{ "/_File", NULL, NULL, 0, "<Branch>" },
		{ "/File/_Load game", "<control>L", menu_load_file_dialog, 0, "" },
		{ "/File/_Save game", NULL, NULL, 0, "" },
		{ "/File/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, "" },
*/
		{ "/_Game", NULL, NULL, 0, "<Branch>" },
		{ "/Game/Select _Game", NULL, NULL, 0, "<LastBranch>" },
		{ "/Game/_Levels", NULL, NULL, 0, "<Branch>"},
		{ "/Game/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_New", "<control>N", menu_start_stop_game, MENU_RESET_GAME, "" },
		{ "/Game/_Start", "<control>G", menu_start_stop_game, MENU_START_GAME, "" },
		{ "/Game/_Pause", "<control>P", menu_start_stop_game, MENU_STOP_GAME, "" },
		{ "/Game/Sep2", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_Highscores", NULL, prefs_show_scores, 0, ""},
		{ "/Game/_Zap Highscores", NULL, prefs_zap_highscores, 0, ""},
		{ "/Game/Sep3", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, "" },
		{ "/_Move", NULL, NULL, 0, "<Branch>" },
		{ "/Move/_Back", "<control>B", menu_back_forw, MENU_BACK, "" },
		{ "/Move/_Forward", "<control>F", menu_back_forw, MENU_FORW, "" },
		{ "/Move/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Move/_Move Now", "<control>M", 
			(GtkItemFactoryCallback) ui_move_now_cb, 0, "" },
#else
/*		{ "/_File", NULL, NULL, 0, "<Branch>" },
		{ "/File/_Load game", "<control>L", menu_load_file_dialog, 0, 
				"<StockItem>", GTK_STOCK_OPEN },
		{ "/File/_Save game", NULL, menu_save_file_dialog, 0, 
				"<StockItem>", GTK_STOCK_SAVE },
		{ "/File/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, 
				"<StockItem>", GTK_STOCK_QUIT },
*/
		{ "/_Game", NULL, NULL, 0, "<Branch>" },
		{ "/Game/Select _Game", NULL, NULL, 0, "<LastBranch>" },
		{ "/Game/Levels", NULL, NULL, 0, "<Branch>"},
		{ "/Game/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_New", "<control>N", menu_start_stop_game, MENU_RESET_GAME, 
				"<StockItem>", GTK_STOCK_NEW },
		{ "/Game/_Start", "<control>G", menu_start_stop_game, MENU_START_GAME, 
				"<StockItem>", GTK_STOCK_YES  },
		{ "/Game/_Pause", "<control>P", menu_start_stop_game, MENU_STOP_GAME, 
				"<StockItem>", GTK_STOCK_STOP },
		{ "/Game/Sep2", NULL, NULL, 0, "<Separator>" },
		//FIXME: there's a scores stock item but I can't seem to find it
		{ "/Game/_Highscores", NULL, prefs_show_scores, 0, ""},
		{ "/Game/_Zap Highscores", NULL, prefs_zap_highscores, 0, ""},
		{ "/Game/Sep3", NULL, NULL, 0, "<Separator>" },
		{ "/Game/_Quit", "<control>Q", (GtkSignalFunc) ui_cleanup, 0, 
				"<StockItem>", GTK_STOCK_QUIT },
		{ "/_Move", NULL, NULL, 0, "<Branch>" },
		{ "/Move/_Back", "<control>B", menu_back_forw, 1, 
				"<StockItem>", GTK_STOCK_GO_BACK },
		{ "/Move/_Forward", "<control>F", menu_back_forw, 2, 
				"<StockItem>", GTK_STOCK_GO_FORWARD },
		{ "/Move/Sep1", NULL, NULL, 0, "<Separator>" },
		{ "/Move/_Move Now", "<control>M", 
			(GtkItemFactoryCallback) ui_move_now_cb, 0, "" },
#endif
		{ "/_Settings", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/_Player", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/Player/File", NULL, NULL, 0, "<RadioItem>" },
		{ "/Settings/Player/Human-Human", NULL, menu_set_player, 1, "/Settings/Player/File" },
		{ "/Settings/Player/Human-Machine", NULL, menu_set_player, 2, 
									"/Settings/Player/File" },
		{ "/Settings/Player/Machine-Human", NULL, menu_set_player, 3, 
									"/Settings/Player/File" },
		{ "/Settings/Player/Machine-Machine", NULL, menu_set_player, 4, 
									"/Settings/Player/File" },
//		{ "/Settings/_Eval function", NULL, NULL, 0, "<Branch>" },
//		{ "/Settings/_Eval function/_White", NULL, NULL, 0, "<Branch>" },
//		{ "/Settings/_Eval function/_Black", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/_Flip Board", "<control>T", menu_board_flip_cb, 0, "" },
		{ "/Settings/_Enable Sound", NULL, menu_enable_sound_cb, 1, ""},
		{ "/Settings/_Disable Sound", NULL, menu_enable_sound_cb, 0, ""},
		{ "/Settings/_Time per move", NULL, NULL, 0, "<Branch>" },
		{ "/Settings/_Time per move/Default", NULL, 
			menu_set_delay_cb, DEF_TIME_PER_MOVE, "<RadioItem>" },
		{ "/Settings/_Time per move/100 milliseconds", NULL, 
			menu_set_delay_cb, 100, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/200 milliseconds", NULL, 
			menu_set_delay_cb, 200, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/500 milliseconds", NULL, 
			menu_set_delay_cb, 500, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/1 second", NULL, 
			menu_set_delay_cb, 1000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/2 seconds", NULL, 
			menu_set_delay_cb, 2000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/5 seconds", NULL, 
			menu_set_delay_cb, 5000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/10 seconds", NULL, 
			menu_set_delay_cb, 10000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/30 seconds", NULL, 
			menu_set_delay_cb, 30000, "/Settings/Time per move/Default" },
		{ "/Settings/Time per move/1 minute", NULL, 
			menu_set_delay_cb, 600000, "/Settings/Time per move/Default" },
		{ "/_Help", NULL, NULL, 0, "<Branch>" },
		{ "/Help/_About", NULL, menu_show_about_dialog, 0, ""},
#ifdef HAVE_GNOME
		{ "/Help/_Home Page", NULL, menu_help_home_page, 0, "<StockItem>", GTK_STOCK_HOME},
#endif
		// TODO: implement context help
//		{ "/Help/_Context help", NULL, ui_set_context_help, 0, ""},
	};
	int i;
	gdk_rgb_init ();
	main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_policy (GTK_WINDOW (main_window), FALSE, FALSE, TRUE);
	gtk_signal_connect (GTK_OBJECT (main_window), "delete_event",
		GTK_SIGNAL_FUNC(ui_cleanup), NULL);
	gtk_window_set_title (GTK_WINDOW (main_window), "Gtkboard");

	ag = gtk_accel_group_new();
	menu_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", ag);
	gtk_window_add_accel_group (GTK_WINDOW (main_window), ag);
			
	gtk_item_factory_create_items (menu_factory, 
			sizeof (items) / sizeof (items[0]), items, NULL);
	for (i=0; i<=num_games; i++)
	{
		if (i==0) 
			game_items[i].path = "/Game/Select Game/none";
		else 
		{
			if (games[i-1]->group)
			{
				GtkItemFactoryEntry group_item = {NULL, NULL, NULL, 0, "<Branch>"};
				group_item.path = g_strdup_printf ("/Game/Select Game/%s",
						games[i-1]->group);
				// FIXME: this is O(N^2) where N is the number of games
				if (gtk_item_factory_get_widget (menu_factory, group_item.path) == NULL)
					gtk_item_factory_create_item (menu_factory, &group_item, NULL, 1);
				game_items[i].path = g_strdup_printf ("/Game/Select Game/%s/%s",
					games[i-1]->group ? games[i-1]->group : "", games[i-1]->name);
			}
			else
				game_items[i].path = g_strdup_printf ("/Game/Select Game/%s",
						games[i-1]->name);
		}
		game_items[i].accelerator = NULL;
		game_items[i].callback = menu_set_game;
		game_items[i].callback_action = i-1;
		game_items[i].item_type = (i == 0 ? "<RadioItem>": "/Game/Select Game/none");
	}
	gtk_item_factory_create_items (menu_factory, 
			num_games+1, game_items, NULL);
	// ugly hack to create a group of radio button with no button selected by default
	gtk_item_factory_delete_item (menu_factory, "/Game/Select Game/none");

	menu_main = gtk_item_factory_get_widget (menu_factory, "<main>");
	gtk_widget_set_state (gtk_item_factory_get_widget (menu_factory, 
				"/Settings/Player/File"), GTK_STATE_INSENSITIVE);

	for (i=1; i<=NUM_RECENT_GAMES; i++)
	{
		gchar *tmp;
		gchar *gamename;
		gamename = prefs_get_config_val (tmp = g_strdup_printf ("recent_game_%d", i));
		g_free (tmp);
		if (gamename && gamename[0] != '\0')
			menu_insert_game_item (gamename, i);
	}

	menu_set_eval_function ();
	vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX(vbox), menu_main, FALSE, FALSE, 0);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);

	{
	GtkWidget *innerframe;
	board_colbox = gtk_vbox_new (FALSE, 0);
	board_area = gtk_drawing_area_new ();
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), board_colbox, FALSE, FALSE, 0);
	vbox1 = gtk_vbox_new (FALSE, 0);
	board_rowbox = gtk_hbox_new (FALSE, 0);
	innerframe = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (innerframe), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (vbox1), innerframe);
	gtk_container_add (GTK_CONTAINER (innerframe), board_area);
	gtk_container_add (GTK_CONTAINER (vbox1), board_rowbox);
	gtk_box_pack_start (GTK_BOX (hbox), vbox1, TRUE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER (frame), hbox);

	gtk_signal_connect (GTK_OBJECT (board_area), "expose_event",
		GTK_SIGNAL_FUNC (board_redraw), NULL);

   	gtk_widget_set_events(board_area, 
			gtk_widget_get_events (board_area) 
			|   GDK_BUTTON_PRESS_MASK
			|   GDK_BUTTON_RELEASE_MASK
			|   GDK_POINTER_MOTION_MASK
			|   GDK_KEY_PRESS_MASK
			|	GDK_KEY_RELEASE_MASK
			|	GDK_LEAVE_NOTIFY_MASK
			);

	gtk_signal_connect (GTK_OBJECT (board_area), "leave_notify_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (board_area), "motion_notify_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (board_area), "button_release_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (board_area), "button_press_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (main_window), "key_press_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	gtk_signal_connect (GTK_OBJECT (main_window), "key_release_event",
		GTK_SIGNAL_FUNC (board_signal_handler), NULL);
	menu_info_bar = hbox = gtk_hbox_new (FALSE, 0);
	sb_game_label = gtk_label_new (opt_game ? opt_game->name : NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_game_label, FALSE, FALSE, 3);
	sb_game_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_game_separator, FALSE, FALSE, 0);
	sb_player_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_player_label, FALSE, FALSE, 3);
	sb_player_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_player_separator, FALSE, FALSE, 0);
	sb_who_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_who_label, FALSE, FALSE, 3);
	sb_who_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_who_separator, FALSE, FALSE, 0);
	sb_score_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (hbox), sb_score_label, FALSE, FALSE, 3);
	sb_score_separator = gtk_vseparator_new ();
	gtk_box_pack_start (GTK_BOX (hbox), sb_score_separator, FALSE, FALSE, 0);
#if GTK_MAJOR_VERSION == 2
	sb_turn_image = gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_MENU);
	gtk_box_pack_end (GTK_BOX (hbox), sb_turn_image, FALSE, FALSE, 0);
	sb_turn_separator = gtk_vseparator_new ();
	gtk_box_pack_end (GTK_BOX (hbox), sb_turn_separator, FALSE, FALSE, 0);
#endif
	sb_time_label = gtk_label_new (NULL);
	gtk_box_pack_end (GTK_BOX (hbox), sb_time_label, FALSE, FALSE, 0);
	sb_time_separator = gtk_vseparator_new ();
	gtk_box_pack_end (GTK_BOX (hbox), sb_time_separator, FALSE, FALSE, 0);
	}
			
	menu_info_separator = separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	menu_warning_bar = gtk_label_new ("Warning: this game has not yet been completely implemented.");
	gtk_box_pack_start (GTK_BOX (vbox), menu_warning_bar, FALSE, FALSE, 0);
	sb_warning_separator = separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
	separator = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
	sb_message_label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (sb_message_label), 0, 0.5);
	hbox = gtk_hbox_new (TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), sb_message_label, TRUE, TRUE, 3);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER (main_window), vbox);
	// FIXME: board_init() needs show() to be called to get a gc, but
	// leads to the whole window not popping up at once
	gtk_widget_show_all (main_window);
	
	if (!opt_game) board_init ();

	gtk_timeout_add (100, sb_update_periodic, NULL);

	// this should be called before setting state_gui_active = TRUE
	if (opt_game) menu_put_game (); 
	state_gui_active = TRUE;

	if (opt_game) menu_start_game ();
	menu_put_player (TRUE);
//	if (!opt_game) sb_message ("Select a game from the Game menu", FALSE);
	sb_update ();
}
Ejemplo n.º 12
0
void
gkrellm_panel_create(GtkWidget *vbox, GkrellmMonitor *mon, GkrellmPanel *p)
	{
	GtkWidget		*hbox;
	GkrellmPiximage	piximage;
	GtkWidget   	*top_win = gkrellm_get_top_window();

	if (!vbox || !mon || !p)
		return;
	p->monitor = (gpointer) mon;
	if (!p->style)	/* gkrellm_panel_configure() may not have been called. */
		setup_panel_style(p, mon->privat->panel_style);

	if (!p->bg_piximage_override)
		{
		if (mon->privat->style_type == CHART_PANEL_TYPE)
			p->bg_piximage = gkrellm_bg_panel_piximage(mon->privat->style_id);
		else
			p->bg_piximage = gkrellm_bg_meter_piximage(mon->privat->style_id);
		}
	p->bg_piximage_override = FALSE;

	/* If not being called from rebuild or after a panel destroy, then panel
	|  still has a height that must be accounted for.
	*/
	if (p->h && p->shown)
		gkrellm_monitor_height_adjust(- p->h);
	p->h = p->h_configure;
	p->w = _GK.chart_width;

	if (p->hbox == NULL)
		{
		hbox = gtk_hbox_new(FALSE, 0);
		gtk_container_add (GTK_CONTAINER(vbox), hbox);
		p->hbox = hbox;
		p->drawing_area = gtk_drawing_area_new();
		p->layout = gtk_widget_create_pango_layout(top_win, NULL);
		gtk_widget_set_events (p->drawing_area, GDK_EXPOSURE_MASK
				| GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK
				| GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK
				| GDK_POINTER_MOTION_MASK);
		gtk_box_pack_start(GTK_BOX(p->hbox), p->drawing_area,
				FALSE, FALSE, 0);
		gtk_widget_show(p->drawing_area);
		gtk_widget_show(hbox);
		p->shown = TRUE;
		gtk_widget_realize(hbox);
		gtk_widget_realize(p->drawing_area);
		panel_list = g_list_append(panel_list, p);
		p->y_mapped = -1;
		g_signal_connect(G_OBJECT (p->drawing_area), "size_allocate",
					G_CALLBACK(cb_panel_size_allocate), p);
		}
	gtk_widget_set_size_request(p->drawing_area, p->w, p->h);

	if (_GK.frame_left_panel_overlap > 0 || _GK.frame_right_panel_overlap > 0)
		{
		piximage.pixbuf = gdk_pixbuf_new_subpixbuf(p->bg_piximage->pixbuf,
				_GK.frame_left_panel_overlap, 0,
				gdk_pixbuf_get_width(p->bg_piximage->pixbuf)
							- _GK.frame_left_panel_overlap
							- _GK.frame_right_panel_overlap,
				gdk_pixbuf_get_height(p->bg_piximage->pixbuf));
		piximage.border = p->bg_piximage->border;
		gkrellm_border_adjust(&piximage.border,
				-_GK.frame_left_panel_overlap, -_GK.frame_right_panel_overlap,
				0, 0);
//		gkrellm_scale_piximage_to_pixmap(&piximage, &p->bg_clean_pixmap,
//				&p->bg_mask, p->w, p->h);
		gkrellm_scale_theme_background(&piximage, &p->bg_clean_pixmap,
				&p->bg_mask, p->w, p->h);
		g_object_unref(G_OBJECT(piximage.pixbuf));
		}
	else
		gkrellm_scale_theme_background(p->bg_piximage, &p->bg_clean_pixmap,
			&p->bg_mask, p->w, p->h);
//		gkrellm_scale_piximage_to_pixmap(p->bg_piximage, &p->bg_clean_pixmap,
//			&p->bg_mask, p->w, p->h);

	if (p->bg_text_layer_pixmap)
		g_object_unref(G_OBJECT(p->bg_text_layer_pixmap));
	p->bg_text_layer_pixmap = gdk_pixmap_new(top_win->window, p->w, p->h, -1);
	if (p->bg_pixmap)
		g_object_unref(G_OBJECT(p->bg_pixmap));
	p->bg_pixmap = gdk_pixmap_new(top_win->window, p->w, p->h, -1);
	if (p->pixmap)
		g_object_unref(G_OBJECT(p->pixmap));
	p->pixmap = gdk_pixmap_new(top_win->window, p->w, p->h, -1);

	if (p->shown)
		{
		gkrellm_monitor_height_adjust(p->h);
		gkrellm_pack_side_frames();
		}
	p->need_decal_overlap_check = TRUE;
	draw_panel(p, FALSE);
	gkrellm_panel_button_signals_connect(p);
	}
Ejemplo n.º 13
0
int  main(int argc, char *argv[])
{
	gnome_init(VERSION, VERSION, argc, argv);

	/* Set up to draw from card class */
	GtkWidget *vbox, *vbox1, *vbox2, *vbox3;
	GtkWidget *tbar;
	GtkWidget *setbutton, *nosetbutton;
	GdkColor white, black, blue;
	/* Done setting up */

	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), "Set Game");
	gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE);
	gtk_container_border_width(GTK_CONTAINER(window), 0);

	vbox= gtk_vbox_new(FALSE, 0);
	vbox1 = gtk_vbox_new(FALSE, 0);
	vbox2 = gtk_vbox_new(FALSE, 0);
	vbox3 = gtk_vbox_new(FALSE, 0);

	drawing_area = gtk_drawing_area_new();
  gtk_widget_set_events(drawing_area,
    GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK);
  gtk_widget_set_events(window, GDK_KEY_PRESS_MASK);
  gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
    GTK_SIGNAL_FUNC(expose_event), 0);
  gtk_signal_connect(GTK_OBJECT(drawing_area), "button_press_event",
    GTK_SIGNAL_FUNC(button_event), 0);
	GnomeUIInfo toolbar[ ] = {
GNOMEUIINFO_ITEM_STOCK ("New Game", "Start new Game", newgame, GNOME_STOCK_PIXMAP_NEW),
GNOMEUIINFO_ITEM_STOCK ("High Scores", "Shows High scores", gtk_main_quit, GNOME_STOCK_PIXMAP_SCORES),
GNOMEUIINFO_ITEM_STOCK ("End Game", "Ends Current Game", gtk_main_quit, GNOME_STOCK_PIXMAP_STOP),
GNOMEUIINFO_ITEM_STOCK ("Exit", "Exit the application", gtk_main_quit, GNOME_STOCK_PIXMAP_EXIT),
GNOMEUIINFO_END
};
	tbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
	gnome_app_fill_toolbar(GTK_TOOLBAR(tbar), toolbar, gtk_accel_group_new());
	gtk_box_pack_start(GTK_BOX(vbox1), tbar, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), vbox3, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox2), drawing_area, TRUE, TRUE, 5);
	gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), SPACE_INTER+CARD_WS*4, SPACE_INTER+CARD_HS*3);
	gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Player"), TRUE, TRUE, 1);
	playerscore = gtk_label_new("0");
	gtk_box_pack_start(GTK_BOX(vbox3), playerscore, TRUE, TRUE, 1);
	gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Computer"), TRUE, TRUE, 1);
	computerscore = gtk_label_new("0");
	gtk_box_pack_start(GTK_BOX(vbox3), computerscore, TRUE, TRUE, 1);
	gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Cards Remaining"), TRUE, TRUE, 1);
	cards_remain = gtk_label_new("81");
	gtk_box_pack_start(GTK_BOX(vbox3), cards_remain, TRUE, TRUE, 1);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	gtk_widget_show_all(window);

	gtk_idle_add( myidle, NULL);


/************************ Start Deck Setup *************************/
unsigned char *pixmap_data[] = {
    bean_e_bits,
    bean_s_bits,
    bean_f_bits,
    blob_e_bits,
    blob_s_bits,
    blob_f_bits,
    diamond_e_bits,
    diamond_s_bits,
    diamond_f_bits
  };
  int i, j;
  GdkWindow *wn = window->window;
  GdkColor col[4];
  GdkColormap *cmap = gdk_window_get_colormap(wn);
  GdkGC *gc;
  GtkStyle *style = gtk_widget_get_style(window);
  col[0].red = 54000; col[0].green = col[0].blue = 0;
  col[1].green = 40000; col[1].red = col[1].blue = 0;
  col[2].red = col[2].blue = 32000; col[2].green = 0;
  gdk_color_white(cmap, &white);
  gdk_color_black(cmap, &black);
  blue.red = blue.green = 0; blue.blue = 48000;
  gdk_color_alloc(cmap, &blue);
  for (i=0; i<3; i++)
    gdk_color_alloc(cmap, &col[i]);
  for (i=0; i<9; i++)
    for (j=0; j<3; j++)
      card_pixmap[i*3+j] = gdk_pixmap_create_from_data(wn, (gchar*) pixmap_data[i],
        SHAPE_W, SHAPE_H, -1, &col[j], &white);
  /* free colors? !! */

  gc = gdk_gc_new(wn);

  /*** cards in normal state ***/
  card_bkg = gdk_pixmap_new(wn, CARD_WIDTH, CARD_HEIGHT, -1);
  /* clear the card */
  gdk_gc_set_foreground(gc, &style->bg[GTK_STATE_NORMAL]);
  gdk_draw_rectangle(card_bkg, gc, 1, 0, 0, CARD_WIDTH, CARD_HEIGHT);
  /* draw corner arcs */
  gdk_gc_set_foreground(gc, &white);
  gdk_draw_arc(card_bkg, gc, 1, 0,                 0,
    2*ARC_SIZE, 2*ARC_SIZE, 90*64,  90*64);
  gdk_draw_arc(card_bkg, gc, 1, CARD_WIDTH-2*ARC_SIZE, 0,
    2*ARC_SIZE, 2*ARC_SIZE, 0,      90*64);
  gdk_draw_arc(card_bkg, gc, 1, 0,                 CARD_HEIGHT-2*ARC_SIZE,
    2*ARC_SIZE, 2*ARC_SIZE, 180*64, 90*64);
  gdk_draw_arc(card_bkg, gc, 1, CARD_WIDTH-2*ARC_SIZE,
    CARD_HEIGHT-2*ARC_SIZE, 2*ARC_SIZE, 2*ARC_SIZE, 270*64, 90*64);
  /* draw the rest */
  gdk_draw_rectangle(card_bkg, gc, 1, ARC_SIZE, 0, CARD_WIDTH-2*ARC_SIZE, CARD_HEIGHT);
  gdk_draw_rectangle(card_bkg, gc, 1, 0, ARC_SIZE, CARD_WIDTH, CARD_HEIGHT-2*ARC_SIZE);
	  gdk_gc_destroy(gc);

/************************ End Deck Setup *************************/



  /* done setting up for once 
	  to draw
	  wn = drawing_area->window;
	  gc-gdk_gc_new(wn);
	  card1.draw();
	  .............draw();
	  gdk_gc_destroy();
	  
	  
	  Card(int colr, int shp, int num, int shdng);
  */
 

		mytable.Draw();
	gtk_main();
	return 0;
}	
Ejemplo n.º 14
0
GtkWidget *ic_loading_panel_new()
{
	GtkWidget *window;
	GtkWidget *titlebar;
	GtkWidget *vbox;
	GtkWidget *cancel_button;
	GtkWidget *align;
	GtkWidget *label2;
	GtkWidget *image1, *image2, *image3;
	GdkPixbuf *pixbuf1, *pixbuf2, *new_pixbuf;
	GdkScreen *scr;
	gint pic_width, pic_height;
	gint new_width, new_height;
	gint scr_width;
	GdkScreen *screen;
	GdkVisual *visual;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_decorated (GTK_WINDOW(window), FALSE);
	gtk_window_set_default_size(GTK_WINDOW(window), 280, 580);
	gtk_window_set_keep_above (GTK_WINDOW(window), TRUE);
	
	screen = gtk_widget_get_screen(window);
	visual = gdk_screen_get_rgba_visual(screen);
	gtk_widget_set_visual(window, visual);
	GdkColor color = {0, 30313, 51153, 63408};
	gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color);
	
	scr = gdk_screen_get_default();
	scr_width = gdk_screen_get_width(scr);
	gtk_window_move(GTK_WINDOW(window), scr_width-350, 50);

	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	titlebar = ic_titlebar_new ();
	gtk_box_pack_start (GTK_BOX(vbox), titlebar, FALSE, FALSE, 0);
	
	/*label1 = gtk_label_new("\niChat");
	PangoFontDescription *font_desc = pango_font_description_from_string("Purisa Bold 25");
	gtk_widget_modify_font(label1, font_desc);
	pango_font_description_free(font_desc);

	gtk_widget_set_size_request(label1, 100, 25);
	gtk_box_pack_start(GTK_BOX(vbox), label1, FALSE, FALSE, 0);
    */
    image3 = gtk_image_new_from_file(RESDIR"images/ichat.png");
    gtk_box_pack_start(GTK_BOX(vbox), image3, FALSE, FALSE, 0);

	pixbuf1 = gdk_pixbuf_new_from_file(RESDIR"images/loading/loading-01.png", NULL);
	image1 = gtk_image_new_from_pixbuf(pixbuf1);
	gtk_box_pack_start(GTK_BOX(vbox), image1, FALSE, FALSE, 0);

	pixbuf2 = gdk_pixbuf_new_from_file(RESDIR"images/gtk.png", NULL);
	pic_width = gdk_pixbuf_get_width(pixbuf2);
	pic_height = gdk_pixbuf_get_height(pixbuf2);
	new_width = 150;
	new_height = ((float)new_width/pic_width)*pic_height;
	
	new_pixbuf = gdk_pixbuf_scale_simple (pixbuf2, new_width, new_height, GDK_INTERP_BILINEAR);
	image2 = gtk_image_new_from_pixbuf(new_pixbuf);
	gtk_box_pack_start(GTK_BOX(vbox), image2, FALSE, FALSE, 5);

	gchar str[30];
	memset(str, 0, sizeof(str));
	strcat(str, user_name);
	strcat(str, "正在登录");
	label2 = gtk_label_new(str);
	gtk_box_pack_start(GTK_BOX(vbox), label2, FALSE, FALSE, 5);
	
	align = gtk_alignment_new(0.5, 0.5, 0, 0);
	cancel_button = gtk_button_new_with_label("  取 消  ");
	gtk_container_add(GTK_CONTAINER(align), cancel_button);
	gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, FALSE, 5);

	gtk_widget_set_events(window, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK
			| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK
			| GDK_POINTER_MOTION_HINT_MASK);
	g_signal_connect(G_OBJECT(window), "button_press_event",
			G_CALLBACK(on_mouse_press_event), NULL);
	g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
	g_timeout_add(100, (GSourceFunc)timer, (gpointer)image1);

	gtk_container_add(GTK_CONTAINER(window), vbox);
	return window;
}
Ejemplo n.º 15
0
int main (int argc, char *argv[])
{
    GtkWidget *label;
    GdkPixbuf *icon_pixbuf;
    GError *err = NULL;
    
    bindtextdomain(PACKAGE, LOCALEDIR);
    bind_textdomain_codeset(PACKAGE, "UTF-8");
    textdomain(PACKAGE);

    srand (time(NULL));

    gnome_program_init (APPID, APPVERSION, LIBGNOMEUI_MODULE,
                        argc, argv, GNOME_PARAM_POPT_TABLE, options,
                        GNOME_PARAM_NONE);

    textbox_setup (); /* needs to be done before text boxes are created */
    
    /* Initialize the GConf library */
    if (!gconf_init (argc, argv, &err))
    {
      fprintf (stderr, _("Failed to init GConf: %s\n"), err->message);
      g_error_free (err); 
      err = NULL;
    }
  
    /* Start a GConf client */
    gconf_client = gconf_client_get_default ();
  
    /* Add the GTetrinet directories to the list of directories that GConf client must watch */
    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/sound",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
    
    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/themes",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
  
    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/keys",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/partyline",
                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

    /* Request notification of change for these gconf keys */
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/midi_player",
                             (GConfClientNotifyFunc) sound_midi_player_changed,
			     NULL, NULL, NULL);
                             
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/enable_sound",
                             (GConfClientNotifyFunc) sound_enable_sound_changed,
			     NULL, NULL, NULL);
                             
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/enable_midi",
                             (GConfClientNotifyFunc) sound_enable_midi_changed,
			     NULL, NULL, NULL);
                             
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/themes/theme_dir",
                             (GConfClientNotifyFunc) themes_theme_dir_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/down",
                             (GConfClientNotifyFunc) keys_down_changed, NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/left",
                             (GConfClientNotifyFunc) keys_left_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/right",
                             (GConfClientNotifyFunc) keys_right_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/rotate_left",
                             (GConfClientNotifyFunc) keys_rotate_left_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/rotate_right",
                             (GConfClientNotifyFunc) keys_rotate_right_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/drop",
                             (GConfClientNotifyFunc) keys_drop_changed, NULL,
			     NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message",
			     (GConfClientNotifyFunc) keys_message_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/discard",
			     (GConfClientNotifyFunc) keys_discard_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special1",
                             (GConfClientNotifyFunc) keys_special1_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special2",
                             (GConfClientNotifyFunc) keys_special2_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special3",
                             (GConfClientNotifyFunc) keys_special3_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special4",
                             (GConfClientNotifyFunc) keys_special4_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special5",
                             (GConfClientNotifyFunc) keys_special5_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special6",
                             (GConfClientNotifyFunc) keys_special6_changed,
			     NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special_self",
                             (GConfClientNotifyFunc) keys_special_self_changed,
                            NULL, NULL, NULL);

    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps",
                             (GConfClientNotifyFunc) partyline_enable_timestamps_changed,
			     NULL, NULL, NULL);
    
    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_channel_list",
                             (GConfClientNotifyFunc) partyline_enable_channel_list_changed,
			     NULL, NULL, NULL);

    /* load settings */
    config_loadconfig ();

    /* initialise some stuff */
    fields_init ();
    if (!g_thread_supported()) g_thread_init (NULL);

    /* first set up the display */

    /* create the main window */
    app = gnome_app_new (APPID, APPNAME);

    g_signal_connect (G_OBJECT(app), "destroy",
                        GTK_SIGNAL_FUNC(destroymain), NULL);
    keypress_signal = g_signal_connect (G_OBJECT(app), "key-press-event",
                                        GTK_SIGNAL_FUNC(keypress), NULL);
    g_signal_connect (G_OBJECT(app), "key-release-event",
                        GTK_SIGNAL_FUNC(keyrelease), NULL);
    gtk_widget_set_events (app, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);

    gtk_window_set_resizable (GTK_WINDOW (app), TRUE);
    
    /* create and set the window icon */
    icon_pixbuf = gdk_pixbuf_new_from_file (PIXMAPSDIR "/gtetrinet.png", NULL);
    if (icon_pixbuf)
    {
      gtk_window_set_icon (GTK_WINDOW (app), icon_pixbuf);
      gdk_pixbuf_unref (icon_pixbuf);
    }

    /* create the notebook */
    notebook = gtk_notebook_new ();
    gtk_notebook_set_tab_pos (GTK_NOTEBOOK(notebook), GTK_POS_TOP);

    /* put it in the main window */
    gnome_app_set_contents (GNOME_APP(app), notebook);

    /* make menus + toolbar */
    make_menus (GNOME_APP(app));

    /* create the pages in the notebook */
    fieldswidget = fields_page_new ();
    gtk_widget_set_sensitive (fieldswidget, TRUE);
    gtk_widget_show (fieldswidget);
    pfields = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER(pfields), 0);
    gtk_container_add (GTK_CONTAINER(pfields), fieldswidget);
    gtk_widget_show (pfields);
    g_object_set_data (G_OBJECT(fieldswidget), "title", "Playing Fields"); // FIXME
    label = pixmapdata_label (fields_xpm, _("Playing Fields"));
    gtk_widget_show (label);
    gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pfields, label);

    partywidget = partyline_page_new ();
    gtk_widget_show (partywidget);
    pparty = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER(pparty), 0);
    gtk_container_add (GTK_CONTAINER(pparty), partywidget);
    gtk_widget_show (pparty);
    g_object_set_data (G_OBJECT(partywidget), "title", "Partyline"); // FIXME
    label = pixmapdata_label (partyline_xpm, _("Partyline"));
    gtk_widget_show (label);
    gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pparty, label);

    winlistwidget = winlist_page_new ();
    gtk_widget_show (winlistwidget);
    pwinlist = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER(pwinlist), 0);
    gtk_container_add (GTK_CONTAINER(pwinlist), winlistwidget);
    gtk_widget_show (pwinlist);
    g_object_set_data (G_OBJECT(winlistwidget), "title", "Winlist"); // FIXME
    label = pixmapdata_label (winlist_xpm, _("Winlist"));
    gtk_widget_show (label);
    gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pwinlist, label);

    /* add signal to focus the text entry when switching to the partyline page*/
    g_signal_connect_after(G_OBJECT (notebook), "switch-page",
		           GTK_SIGNAL_FUNC (switch_focus),
		           NULL);

    gtk_widget_show (notebook);
    g_object_set (G_OBJECT (notebook), "can-focus", FALSE, NULL);

    partyline_show_channel_list (list_enabled);
    gtk_widget_show (app);

//    gtk_widget_set_size_request (partywidget, 480, 360);
//    gtk_widget_set_size_request (winlistwidget, 480, 360);

    /* initialise some stuff */
    commands_checkstate ();

    /* check command line params */
#ifdef DEBUG
    printf ("option_connect: %s\n"
            "option_nick: %s\n"
            "option_team: %s\n"
            "option_pass: %s\n"
            "option_spec: %i\n",
            option_connect, option_nick, option_team,
            option_pass, option_spec);
#endif
    if (option_nick) GTET_O_STRCPY(nick, option_nick);
    if (option_team) GTET_O_STRCPY(team, option_team);
    if (option_pass) GTET_O_STRCPY(specpassword, option_pass);
    if (option_spec) spectating = TRUE;
    if (option_connect) {
        client_init (option_connect, nick);
    }

    /* Don't schedule if data is ready, glib should do this itself,
     * but welcome to anything that works... */
    g_main_context_set_poll_func(NULL, gtetrinet_poll_func);

    /* gtk_main() */
    gtk_main ();

    client_disconnect ();
    /* cleanup */
    fields_cleanup ();
    sound_stopmidi ();

    return 0;
}
Ejemplo n.º 16
0
int display_init(GtkWindow *window)
{
  /* Retrieve widgets */
  display_window = window;
  display_label_mouse = GTK_LABEL(lookup_widget(GTK_WIDGET(window), "label_mouse"));
  gtk_label_set_use_markup(display_label_mouse, TRUE);
  display_label_pixel = GTK_LABEL(lookup_widget(GTK_WIDGET(window), "label_pixel"));
  display_label_selection = GTK_LABEL(lookup_widget(GTK_WIDGET(window), "label_selection"));
  gtk_label_set_use_markup(display_label_selection, TRUE);

  /* Display refresh management */
  display_refresh_init(window);

  /* Pattern display management */
  display_pattern_init();
  display_button_pattern = GTK_TOOL_BUTTON(lookup_widget(GTK_WIDGET(window), "button_pattern"));
  gtk_signal_connect_object(GTK_OBJECT(display_button_pattern), "clicked",
                            GTK_SIGNAL_FUNC(display_pattern_popup), NULL);

  /* Screenshot grab management */
  display_screenshot_init(window);

  /* Connect drawing area events */
  display_darea = GTK_DRAWING_AREA(lookup_widget(GTK_WIDGET(window), "drawing_area"));
  display_darea_scroll = -1;
  gtk_signal_connect(GTK_OBJECT(display_darea), "expose_event",
                     GTK_SIGNAL_FUNC(display_event_expose), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "enter_notify_event",
                     GTK_SIGNAL_FUNC(display_event_crossing), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "leave_notify_event",
                     GTK_SIGNAL_FUNC(display_event_crossing), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "motion_notify_event",
                     GTK_SIGNAL_FUNC(display_event_motion), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "button_press_event",
                     GTK_SIGNAL_FUNC(display_event_button), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "button_release_event",
                     GTK_SIGNAL_FUNC(display_event_button), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "key_press_event",
                     GTK_SIGNAL_FUNC(display_event_key), NULL);
  gtk_signal_connect(GTK_OBJECT(display_darea), "key_release_event",
                     GTK_SIGNAL_FUNC(display_event_key), NULL);
  gtk_widget_set_events(GTK_WIDGET(display_darea),
                        GDK_EXPOSURE_MASK |
			GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |	GDK_POINTER_MOTION_MASK |
			GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
			GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);

  /* Record/playback management */
  display_record_init(window);

  /* Setup selection box GC */
  gtk_widget_realize(GTK_WIDGET(display_darea));
  display_sel_init(display_darea);

  /* Init desktop selection */
  display_desktop_init(window);

  /* Setup mouse/keyboard input management */
  display_cursor_init(window, GTK_WIDGET(display_darea));

  display_input_enabled = 0;
  display_input_focus = 0;
  display_button_input = GTK_TOGGLE_TOOL_BUTTON(lookup_widget(GTK_WIDGET(window), "button_input"));
  gtk_signal_connect_object(GTK_OBJECT(display_button_input), "clicked",
                            GTK_SIGNAL_FUNC(display_input_clicked), NULL);
  gtk_toggle_tool_button_set_active(display_button_input, 0);
  gtk_widget_set_sensitive(GTK_WIDGET(display_button_input), 0);
  display_input_clicked();

  /* Manual command entry */
  display_command_init(window);

  return 0;
}
Ejemplo n.º 17
0
static GtkWidget *new_button(void){
    GtkWidget *ev=gtk_event_box_new();
    gtk_widget_set_events(ev, GDK_BUTTON_PRESS_MASK);
    gtk_widget_show_all(ev);
    return ev;
    }
Ejemplo n.º 18
0
GtkWidget * gw_window_box_about_create ( GtkWindow *window)
{
        /* This window must be single, this property shouldn't be changed */
        static GtkWidget *w = NULL;
        GdkColor transparent = {0};
        GtkWidget *vbox_about = NULL;
        GtkWidget *label = NULL;
        GtkWidget *event_box = NULL;
        GtkWidget *logo = NULL;
	GdkPixmap *pix_gw_logo = NULL;
	GdkBitmap *msk_gw_logo = NULL;
        gchar * text = NULL;
        gchar * text_utf8 = NULL;
        GdkCursor *cursor = NULL;
        gchar * os_version = NULL;


#ifdef GW_DEBUG_GUI_COMPONENT
        g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

        if ( !w )
        {
	        /* GWhere logo loading */
	        pix_gw_logo = gdk_pixmap_create_from_xpm_d ( GTK_WIDGET ( window)->window, &msk_gw_logo, &transparent, GWhere_logo_xpm);

                w = gtk_window_new ( GTK_WINDOW_TOPLEVEL);

                gtk_window_set_modal ( GTK_WINDOW ( w), TRUE);
                gtk_window_set_transient_for ( GTK_WINDOW ( w), window);
                gtk_window_set_position ( GTK_WINDOW ( w), GTK_WIN_POS_CENTER);
                g_strdup_to_gtk_text ( _( "About"), text_utf8);
                gtk_window_set_title ( GTK_WINDOW ( w), text_utf8);
                g_free ( text_utf8);

                gtk_signal_connect ( GTK_OBJECT ( w), "destroy", GTK_SIGNAL_FUNC ( gw_window_box_about_destroy), &w);
                gtk_signal_connect ( GTK_OBJECT ( w), "delete-event", GTK_SIGNAL_FUNC ( gtk_widget_destroy), NULL);

		/* See more bottom the call of gdk_pixmap_unref() and gdk_bitmap_unref().
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_WINDOW_ABOUT_LOGO_PIX, pix_gw_logo, ( GtkDestroyNotify)gdk_pixmap_unref);
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_WINDOW_ABOUT_LOGO_BIT, msk_gw_logo, ( GtkDestroyNotify)gdk_bitmap_unref);
		*/

                gtk_container_set_border_width ( GTK_CONTAINER ( w), 5);
                gtk_widget_set_usize ( w, 360, 340);

                event_box = gtk_event_box_new ( );
                gtk_container_add ( GTK_CONTAINER ( w), event_box);

                vbox_about = gtk_vbox_new ( FALSE, 0);
                gtk_container_add ( GTK_CONTAINER ( event_box), vbox_about);

                logo = gtk_pixmap_new ( pix_gw_logo, msk_gw_logo);
		gdk_pixmap_unref ( pix_gw_logo);
		gdk_bitmap_unref ( msk_gw_logo);
                gtk_container_add ( GTK_CONTAINER ( vbox_about), logo);

		/* Doesn't encode to UTF-8 substring because the result string will be encoded. */
		gw_os_get_version_str ( &os_version);
                text = g_strconcat ( PROJECT_NAME,
                                "-",
                                VERSION,
                                _( "\nRemovable media catalog management\nBy Sebastien LECACHEUR\n\[email protected]\nhttp://www.gwhere.org\n"),
                                _( "GWhere allows you to manage a database of your CDs and other removable media (hard disks, floppy drive, Zip drive, CD- ROM, etc...). With GWhere it's easy to browse your CDs or to make a quick search without needing to insert all of your CDs in the drive and search them one by one."),
                                _( "\n\nRuns under "),
                                os_version,
                                NULL);
                if ( os_version != NULL )
                {
                	g_free ( os_version);
                }

		g_strdup_to_gtk_text ( text, text_utf8);
                g_free ( text);

                label = gtk_label_new ( text_utf8);
                g_free ( text_utf8);
                gtk_label_set_justify ( GTK_LABEL ( label), GTK_JUSTIFY_FILL);
                gtk_label_set_line_wrap ( GTK_LABEL ( label), TRUE);
                gtk_container_add ( GTK_CONTAINER ( vbox_about), label);

		/* Should it be mandatory? Yes, in order to get the good window size
		   to displaying all informations. */
		gtk_widget_set_usize ( label, 330, 280);

		gtk_widget_set_events ( event_box, GDK_BUTTON_PRESS_MASK);
		gtk_signal_connect_object ( GTK_OBJECT ( event_box), "button_press_event", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w));

		if ( (cursor = gdk_cursor_new ( GDK_HAND2)) != NULL)
		{
	                /* Fix bug : event_box->window is NULL with GTK-2.0. */
			if ( GTK_WIDGET ( event_box)->window != NULL )
			{
                		gdk_window_set_cursor ( GTK_WIDGET ( event_box)->window, cursor);
#ifdef HAVE_GTK20
                		gdk_cursor_unref ( cursor);
#endif
                	}
                	else
                	{
#ifdef GW_DEBUG_GUI_COMPONENT
                		g_warning ( "gtk_event_box->window is NULL!!");
#endif
                		gdk_cursor_destroy ( cursor);
                	}
                }
        }

        if ( !GTK_WIDGET_VISIBLE ( w) )
        {
#ifdef GW_DEBUG_GUI_COMPONENT
                g_print ( "*** GW - %s (%d) :: %s() : show the window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

                gtk_widget_show_all ( w);
        }
        else
        {
#ifdef GW_DEBUG_GUI_COMPONENT
        g_print ( "*** GW - %s (%d) :: %s() : destroy the window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

		g_warning ( "gw_window_box_about is already displayed!! Destroying it...");

                gtk_widget_destroy ( w);
        }

        return w;
}
Ejemplo n.º 19
0
static void
create_layout (GtkWidget *vbox)
{
  GtkAdjustment *hadjustment, *vadjustment;
  GtkLayout *layout;
  GtkWidget *layout_widget;
  GtkWidget *scrolledwindow;
  GtkWidget *button;
  gchar buf[16];
  gint i, j;

  scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
				       GTK_SHADOW_IN);
  gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolledwindow),
				     GTK_CORNER_TOP_RIGHT);

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

  layout_widget = gtk_layout_new (NULL, NULL);
  layout = GTK_LAYOUT (layout_widget);
  gtk_container_add (GTK_CONTAINER (scrolledwindow), layout_widget);

  /* We set step sizes here since GtkLayout does not set
   * them itself.
   */
  hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout));
  vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (layout));
  gtk_adjustment_set_step_increment (hadjustment, 10.0);
  gtk_adjustment_set_step_increment (vadjustment, 10.0);
  gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (layout), hadjustment);
  gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (layout), vadjustment);

  gtk_widget_set_events (layout_widget, GDK_EXPOSURE_MASK);
  g_signal_connect (layout, "draw",
		    G_CALLBACK (layout_draw_handler),
                    NULL);

  gtk_layout_set_size (layout, 1600, 128000);

  for (i = 0 ; i < 16 ; i++)
    for (j = 0 ; j < 16 ; j++)
      {
	g_snprintf (buf, sizeof (buf), "Button %d, %d", i, j);

	if ((i + j) % 2)
	  button = gtk_button_new_with_label (buf);
	else
	  button = gtk_label_new (buf);

	gtk_layout_put (layout, button,	j * 100, i * 100);
      }

  for (i = 16; i < 1280; i++)
    {
      g_snprintf (buf, sizeof (buf), "Button %d, %d", i, 0);

      if (i % 2)
	button = gtk_button_new_with_label (buf);
      else
	button = gtk_label_new (buf);

      gtk_layout_put (layout, button, 0, i * 100);
    }

  layout_timeout = g_timeout_add (1000, scroll_layout, layout);
}
Ejemplo n.º 20
0
GtkWidget * create_FileSelect( void )
{
 GtkWidget     * vbox4;
 GtkWidget     * hbox4;
 GtkWidget     * vseparator1;
 GtkWidget     * hbox6;
 GtkWidget     * fsFNameListWindow;
 GtkWidget     * hbuttonbox3;

 GtkWidget     * uppixmapwid;
 GdkPixmap     * uppixmap;
 GdkBitmap     * upmask;
 GtkStyle      * upstyle;


 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL );
 gtk_widget_set_name( fsFileSelect,"fsFileSelect" );
 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect );
 gtk_widget_set_usize( fsFileSelect,512,300 );
 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT );
 gtk_widget_set_events( fsFileSelect,GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK );
 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect );
 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER );
 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE );
 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),"FileSelect","MPlayer" );
 fsColorMap=gdk_colormap_get_system();

 gtk_widget_realize( fsFileSelect );
 gtkAddIcon( fsFileSelect );

 style=gtk_widget_get_style( fsFileSelect );
 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm );
 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm );

 vbox4=AddVBox( AddDialogFrame( fsFileSelect ),0 );
 hbox4=AddHBox( vbox4,1 );

 fsCombo4=gtk_combo_new();
 gtk_widget_set_name( fsCombo4,"fsCombo4" );
 gtk_widget_show( fsCombo4 );
 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 );
 gtk_widget_set_usize( fsCombo4,-2,20 );

 fsPathCombo=GTK_COMBO( fsCombo4 )->entry;
 gtk_widget_set_name( fsPathCombo,"fsPathCombo" );
 gtk_widget_show( fsPathCombo );
 gtk_widget_set_usize( fsPathCombo,-2,20 );

 vseparator1=gtk_vseparator_new();
 gtk_widget_set_name( vseparator1,"vseparator1" );
 gtk_widget_show( vseparator1 );
 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 );
 gtk_widget_set_usize( vseparator1,7,20 );

 upstyle=gtk_widget_get_style( fsFileSelect );
 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm );
 uppixmapwid=gtk_pixmap_new( uppixmap,upmask );
 gtk_widget_show( uppixmapwid );

 fsUp=gtk_button_new();
 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid );
 gtk_widget_show( fsUp );
 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 );
 gtk_widget_set_usize( fsUp,65,15 );

 AddHSeparator( vbox4 );

 hbox6=AddHBox( NULL,0 );
   gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 );

 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL );
 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" );
 gtk_widget_show( fsFNameListWindow );
 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 );
 gtk_widget_set_usize( fsFNameListWindow,-2,145 );
 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC );

 fsFNameList=gtk_clist_new( 2 );
 gtk_widget_set_name( fsFNameList,"fsFNameList" );
 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList );
 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 );
 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE );
 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) );
 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT );

 AddHSeparator( vbox4 );

 List=gtk_combo_new();
 gtk_widget_set_name( List,"List" );
 gtk_widget_ref( List );
 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref );
 gtk_widget_show( List );
 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 );
 gtk_widget_set_usize( List,-2,20 );

 fsFilterCombo=GTK_COMBO( List )->entry;
 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" );
 gtk_widget_show( fsFilterCombo );
 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE );

 AddHSeparator( vbox4 );

 hbuttonbox3=AddHButtonBox( vbox4 );
   gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END );
   gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 );

 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 );
 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 );

 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&fsFileSelect );
 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL );

 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo );
 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo );
 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo );
 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo );
 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList );
 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 );
 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL );
 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL );

 gtk_widget_grab_focus( fsFNameList );

 return fsFileSelect;
}
Ejemplo n.º 21
0
/**
* @brief Build the GUI
*
* @return
*/
GtkWidget* buildVfoUI() {
    GtkWidget* label;

    vfoFixed=gtk_fixed_new();
    //gtk_widget_modify_bg(vfoFixed,GTK_STATE_NORMAL,&background);

    // vfoA
    vfoAFrame=gtk_frame_new("VFO A");
    label=gtk_frame_get_label_widget((GtkFrame*)vfoAFrame);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);

#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(vfoAFrame),258,40);
#else
    gtk_widget_set_size_request(GTK_WIDGET(vfoAFrame),300,80);
#endif
    vfoAFrequency=gtk_drawing_area_new();
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(vfoAFrequency),240,75);
#else
    //gtk_widget_set_size_request(GTK_WIDGET(vfoAFrequency),250,35);
#endif
    g_signal_connect(G_OBJECT (vfoAFrequency),"configure_event",G_CALLBACK(vfoAFrequency_configure_event),NULL);
    g_signal_connect(G_OBJECT (vfoAFrequency),"expose_event",G_CALLBACK(vfoAFrequency_expose_event),NULL);
    g_signal_connect(G_OBJECT(vfoAFrequency),"scroll_event",G_CALLBACK(frequency_scroll_event),NULL);
    gtk_widget_set_events(vfoAFrequency,GDK_EXPOSURE_MASK|GDK_SCROLL_MASK);
    gtk_widget_show(vfoAFrequency);
    gtk_widget_show(vfoAFrame);
    gtk_container_add((GtkContainer*)vfoAFrame,vfoAFrequency);
    gtk_fixed_put((GtkFixed*)vfoFixed,vfoAFrame,0,0);

    // vfoB
    vfoBFrame=gtk_frame_new("VFO B");
    label=gtk_frame_get_label_widget((GtkFrame*)vfoBFrame);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(vfoBFrame),258,40);
#else
    gtk_widget_set_size_request(GTK_WIDGET(vfoBFrame),300,80);
#endif
    vfoBFrequency=gtk_drawing_area_new();
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(vfoBFrequency),240,35);
#else
    //gtk_widget_set_size_request(GTK_WIDGET(vfoBFrequency),300,35);
#endif
    g_signal_connect(G_OBJECT (vfoBFrequency),"configure_event",G_CALLBACK(vfoBFrequency_configure_event),NULL);
    g_signal_connect(G_OBJECT (vfoBFrequency),"expose_event",G_CALLBACK(vfoBFrequency_expose_event),NULL);
    g_signal_connect(G_OBJECT(vfoBFrequency),"scroll_event",G_CALLBACK(frequency_scroll_event),NULL);
    gtk_widget_set_events(vfoBFrequency,GDK_EXPOSURE_MASK|GDK_SCROLL_MASK);
    gtk_widget_show(vfoBFrequency);
    gtk_widget_show(vfoBFrame);
    gtk_container_add((GtkContainer*)vfoBFrame,vfoBFrequency);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,vfoBFrame,456,0);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,vfoBFrame,500,0);
#endif

    // vfo control
    vfoControlFrame=gtk_frame_new(NULL);

    buttonAtoB = gtk_button_new_with_label ("A>B");
    //gtk_widget_modify_bg(buttonAtoB, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonAtoB);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonAtoB),50,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonAtoB),45,25);
#endif
    g_signal_connect(G_OBJECT(buttonAtoB),"clicked",G_CALLBACK(vfoCallback),NULL);
    gtk_widget_show(buttonAtoB);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonAtoB,258,0);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonAtoB,300,0);
#endif

    buttonAswapB = gtk_button_new_with_label ("A<>B");
    //gtk_widget_modify_bg(buttonAswapB, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonAswapB);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonAswapB),49,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonAswapB),60,25);
#endif
    g_signal_connect(G_OBJECT(buttonAswapB),"clicked",G_CALLBACK(vfoCallback),NULL);
    gtk_widget_show(buttonAswapB);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonAswapB,308,0);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonAswapB,345,0);
#endif

    buttonBtoA = gtk_button_new_with_label ("A<B");
    //gtk_widget_modify_bg(buttonBtoA, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonBtoA);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonBtoA),49,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonBtoA),45,25);
#endif
    g_signal_connect(G_OBJECT(buttonBtoA),"clicked",G_CALLBACK(vfoCallback),NULL);
    gtk_widget_show(buttonBtoA);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonBtoA,357,0);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonBtoA,405,0);
#endif

    buttonSplit = gtk_button_new_with_label ("Split");
    //gtk_widget_modify_bg(buttonSplit, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonSplit);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonSplit),50,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonSplit),50,25);
#endif
    g_signal_connect(G_OBJECT(buttonSplit),"clicked",G_CALLBACK(vfoCallback),NULL);
    gtk_widget_show(buttonSplit);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonSplit,406,0);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonSplit,450,0);
#endif

    buttonFrequencyUp = gtk_button_new_with_label ("^");
    //gtk_widget_modify_bg(buttonFrequencyUp, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonFrequencyUp);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonFrequencyUp),30,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonFrequencyUp),30,25);
#endif
    g_signal_connect(G_OBJECT(buttonFrequencyUp),"pressed",G_CALLBACK(frequencyUpCallback),NULL);
    g_signal_connect(G_OBJECT(buttonFrequencyUp),"released",G_CALLBACK(frequencyReleasedCallback),NULL);
    gtk_widget_show(buttonFrequencyUp);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonFrequencyUp,258,20);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonFrequencyUp,300,25);
#endif

    buttonIncrementPlus = gtk_button_new_with_label ("+");
    //gtk_widget_modify_bg(buttonIncrementPlus, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonIncrementPlus);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonIncrementPlus),20,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonIncrementPlus),20,25);
#endif
    g_signal_connect(G_OBJECT(buttonIncrementPlus),"clicked",G_CALLBACK(buttonIncrementPlusCallback),NULL);
    gtk_widget_show(buttonIncrementPlus);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonIncrementPlus,288,20);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonIncrementPlus,330,25);
#endif

    incrementDisplay=gtk_drawing_area_new();
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(incrementDisplay),98,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(incrementDisplay),100,25);
#endif
    gtk_widget_show(incrementDisplay);
    g_signal_connect(G_OBJECT (incrementDisplay),"configure_event",G_CALLBACK(incrementDisplay_configure_event),NULL);
    g_signal_connect(G_OBJECT (incrementDisplay),"expose_event",G_CALLBACK(incrementDisplay_expose_event),NULL);
    g_signal_connect(G_OBJECT(incrementDisplay),"scroll_event",G_CALLBACK(increment_scroll_event),NULL);
    gtk_widget_set_events(incrementDisplay,GDK_EXPOSURE_MASK|GDK_SCROLL_MASK);
    gtk_widget_show(incrementDisplay);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,incrementDisplay,308,20);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,incrementDisplay,350,25);
#endif

    buttonIncrementMinus = gtk_button_new_with_label ("-");
    //gtk_widget_modify_bg(buttonIncrementMinus, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonIncrementMinus);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonIncrementMinus),20,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonIncrementMinus),20,25);
#endif
    g_signal_connect(G_OBJECT(buttonIncrementMinus),"clicked",G_CALLBACK(buttonIncrementMinusCallback),NULL);
    gtk_widget_show(buttonIncrementMinus);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonIncrementMinus,406,20);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonIncrementMinus,450,25);
#endif

    buttonFrequencyDown = gtk_button_new_with_label ("v");
    //gtk_widget_modify_bg(buttonFrequencyDown, GTK_STATE_NORMAL, &buttonBackground);
    label=gtk_bin_get_child((GtkBin*)buttonFrequencyDown);
    //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(buttonFrequencyDown),30,20);
#else
    gtk_widget_set_size_request(GTK_WIDGET(buttonFrequencyDown),30,25);
#endif
    g_signal_connect(G_OBJECT(buttonFrequencyDown),"pressed",G_CALLBACK(frequencyDownCallback),NULL);
    g_signal_connect(G_OBJECT(buttonFrequencyDown),"released",G_CALLBACK(frequencyReleasedCallback),NULL);
    gtk_widget_show(buttonFrequencyDown);
#ifdef NETBOOK
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonFrequencyDown,426,20);
#else
    gtk_fixed_put((GtkFixed*)vfoFixed,buttonFrequencyDown,470,25);
#endif

#ifdef NETBOOK
    gtk_widget_set_size_request(GTK_WIDGET(vfoFixed),714,40);
#else
    gtk_widget_set_size_request(GTK_WIDGET(vfoFixed),800,50);
#endif
    gtk_widget_show(vfoFixed);

    return vfoFixed;

}
Ejemplo n.º 22
0
void
ags_note_edit_init(AgsNoteEdit *note_edit)
{
  GtkAdjustment *adjustment;
  
  note_edit->flags = 0;

  note_edit->ruler = ags_ruler_new();
  gtk_table_attach(GTK_TABLE(note_edit),
		   (GtkWidget *) note_edit->ruler,
		   0, 1,
		   0, 1,
		   GTK_FILL|GTK_EXPAND,
		   GTK_FILL,
		   0, 0);

  note_edit->drawing_area = (GtkDrawingArea *) gtk_drawing_area_new();
  gtk_widget_set_style((GtkWidget *) note_edit->drawing_area, note_edit_style);
  gtk_widget_set_events (GTK_WIDGET (note_edit->drawing_area), GDK_EXPOSURE_MASK
                         | GDK_LEAVE_NOTIFY_MASK
                         | GDK_BUTTON_PRESS_MASK
			 | GDK_BUTTON_RELEASE_MASK
                         | GDK_POINTER_MOTION_MASK
			 | GDK_POINTER_MOTION_HINT_MASK
			 );

  gtk_table_attach(GTK_TABLE(note_edit),
		   (GtkWidget *) note_edit->drawing_area,
		   0, 1,
		   1, 2,
		   GTK_FILL|GTK_EXPAND,
		   GTK_FILL|GTK_EXPAND,
		   0, 0);

  note_edit->control.note = ags_note_new();

  note_edit->width = 0;
  note_edit->height = 0;
  note_edit->map_width = AGS_NOTE_EDIT_MAX_CONTROLS * 64;
  note_edit->map_height = 78;

  note_edit->control_height = 14;
  note_edit->control_margin_y = 2;

  note_edit->control_width = 16;

  note_edit->y0 = 0;
  note_edit->y1 = 0;

  note_edit->nth_y = 0;
  note_edit->stop_y = 0;

  /* AgsNoteEditControlCurrent is used by ags_note_edit_draw_segment */
  note_edit->control_current.control_count = AGS_NOTE_EDIT_MAX_CONTROLS;
  note_edit->control_current.control_width = 64;

  note_edit->control_current.x0 = 0;
  note_edit->control_current.x1 = 0;

  note_edit->control_current.nth_x = 0;

  /* AgsNoteEditControlUnit is used by ags_note_edit_draw_notation */
  note_edit->control_unit.control_count = 16 * AGS_NOTE_EDIT_MAX_CONTROLS;
  note_edit->control_unit.control_width = 1 * 4;

  note_edit->control_unit.x0 = 0;
  note_edit->control_unit.x1 = 0;

  note_edit->control_unit.nth_x = 0;
  note_edit->control_unit.stop_x = 0;

  /* offset for pasting from clipboard */
  note_edit->selected_x = 0;
  note_edit->selected_y = 0;

  /* GtkScrollbars */
  adjustment = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 1.0, 1.0, 1.0, 1.0);
  note_edit->vscrollbar = (GtkVScrollbar *) gtk_vscrollbar_new(adjustment);
  gtk_table_attach(GTK_TABLE(note_edit),
		   (GtkWidget *) note_edit->vscrollbar,
		   1, 2,
		   1, 2,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  adjustment = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 1.0, 1.0, 1.0, 1.0);
  note_edit->hscrollbar = (GtkHScrollbar *) gtk_hscrollbar_new(adjustment);
  gtk_table_attach(GTK_TABLE(note_edit),
		   (GtkWidget *) note_edit->hscrollbar,
		   0, 1,
		   2, 3,
		   GTK_FILL, GTK_FILL,
		   0, 0);
}
Ejemplo n.º 23
0
void
CReciteWord::create ()
{
	init ();

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);


	gtk_widget_set_events(window,GDK_SCROLL_MASK);
	gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
	gtk_widget_set_app_paintable(window,TRUE);
	gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
	gtk_widget_set_size_request (window, Skin->reciteword.width, Skin->reciteword.height);
	gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (window), _("ReciteWord"));

	gtk_widget_realize(window);
	skin_load_reciteword (window);
	skin_load_face (window);

	gtk_window_set_icon (GTK_WINDOW(window),Skin->face.icon.p[0]);
	
	tooltips = gtk_tooltips_new ();
	
	fixed = gtk_fixed_new ();
	//gtk_fixed_set_has_window(GTK_FIXED(fixed),TRUE);
	gtk_container_add (GTK_CONTAINER (window), fixed);
	gtk_widget_show (fixed);
	SetBackPixmap (fixed, Skin->face.face.p[0]);

	help_button.create (fixed, Skin->face.help_button.x[0],
			    Skin->face.help_button.y[0], Skin->face.help_button.p[0],
			    Skin->face.help_button.p[1],
			    Skin->face.help_button.p[2], PopupHelp, NULL);
	record_button.create (fixed, Skin->face.record_button.x[0],
			      Skin->face.record_button.y[0],
			      Skin->face.record_button.p[0],
			      Skin->face.record_button.p[1],
			      Skin->face.record_button.p[2], PopupRecord, NULL);
	option_button.create (fixed, Skin->face.option_button.x[0],
			     Skin->face.option_button.y[0],
			     Skin->face.option_button.p[0],
			     Skin->face.option_button.p[1],
			     Skin->face.option_button.p[2], PopupOption, NULL);
	dict_button.create (fixed, Skin->face.dict_button.x[0],
			    Skin->face.dict_button.y[0], Skin->face.dict_button.p[0],
			    Skin->face.dict_button.p[1],
			    Skin->face.dict_button.p[2], PopupDict, NULL);
	about_button.create (fixed, Skin->face.about_button.x[0],
			     Skin->face.about_button.y[0],
			     Skin->face.about_button.p[0],
			     Skin->face.about_button.p[1],
			     Skin->face.about_button.p[2], PopupAbout, NULL);

	GtkWidget *event_box = gtk_event_box_new ();
	gtk_fixed_put (GTK_FIXED (fixed), event_box, Skin->face.menubar.x[0],
		       Skin->face.menubar.y[0]);
	GtkWidget *pixmap_widget = gtk_image_new_from_pixmap (Skin->face.menubar.p[0], NULL);
	gtk_container_add (GTK_CONTAINER (event_box), pixmap_widget);
	gtk_widget_show (pixmap_widget);
	gtk_widget_show (event_box);

	g_signal_connect (G_OBJECT (event_box), "enter_notify_event",
			  G_CALLBACK (on_menu_bar_enter_notify), this);
	g_signal_connect (G_OBJECT (window), "enter_notify_event",
			  G_CALLBACK (on_window_enter_notify), this);

	g_signal_connect (G_OBJECT (window), "button_press_event",
			  G_CALLBACK (on_mainwnd_button_press), this);
	g_signal_connect (G_OBJECT (window), "scroll_event",
			  G_CALLBACK (on_mainwnd_scroll), this);
	g_signal_connect (G_OBJECT (window), "delete_event",
			  G_CALLBACK (on_mainwnd_delete_event), this);
	gtk_widget_show (window);
	gdk_threads_enter();
	gtk_main ();
	gdk_threads_leave();
}
Ejemplo n.º 24
0
void gui_init (gui *g) {
  g->poly     = poly_new ();
  g->selected = NULL;
  g->hovered  = NULL;
  g->gc       = NULL;
  g->canvas   = NULL;
  g->pixmap   = NULL;
  g->ctrl     = false;
  g->pix_w    = 0;
  g->pix_h    = 0;

  /* Main window */
  g->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (g->window, "[:Polytool:]");

  /* Widget creation */
  g->vbox      = gtk_vbox_new         (false, 0);
  g->box       = gtk_hbox_new         (false, 4);
  g->status    = gtk_statusbar_new    ();
  g->draw_zone = gtk_drawing_area_new ();


  /* Context menu */
  g->menu = gtk_menu_new ();

  g->m_split = gtk_menu_item_new_with_label ("Split left/right chains");
  g->m_mtr   = gtk_menu_item_new_with_label ("Triangulate (monotone)");
  g->m_rtr   = gtk_menu_item_new_with_label ("Triangulate (generic)");
  g->m_hull  = gtk_menu_item_new_with_label ("Convex hull (Graham)");
  g->m_sep1  = gtk_separator_menu_item_new  ();
  g->m_clear = gtk_menu_item_new_with_label ("Clear");
  g->m_draw  = gtk_menu_item_new_with_label ("Redraw");
  g->m_sep2  = gtk_separator_menu_item_new  ();
  g->m_quit  = gtk_menu_item_new_with_label ("Quit");

  gtk_menu_append (g->menu, g->m_split);
  gtk_menu_append (g->menu, g->m_mtr);
  gtk_menu_append (g->menu, g->m_rtr);
  gtk_menu_append (g->menu, g->m_hull);
  gtk_menu_append (g->menu, g->m_sep1);
  gtk_menu_append (g->menu, g->m_clear);
  gtk_menu_append (g->menu, g->m_draw);
  gtk_menu_append (g->menu, g->m_sep2);
  gtk_menu_append (g->menu, g->m_quit);

  gtk_widget_show_all (g->menu);


  /* Drawing area */
  gtk_drawing_area_size (g->draw_zone, 200, 200);
  gtk_widget_set_events (g->draw_zone, GDK_EXPOSURE_MASK
                         | GDK_LEAVE_NOTIFY_MASK
                         | GDK_BUTTON_PRESS_MASK
                         | GDK_BUTTON_RELEASE_MASK
                         | GDK_POINTER_MOTION_MASK
                         | GDK_POINTER_MOTION_HINT_MASK);

  /* Packing */
  gtk_container_set_border_width (g->box, 4);

  gtk_box_pack_start (g->box,    g->draw_zone, true,  true,  0);
  gtk_box_pack_start (g->vbox,   g->box,       true,  true,  0);
  gtk_box_pack_start (g->vbox,   g->status,    false, false, 0);
  gtk_container_add  (g->window, g->vbox);

  g->cid = gtk_statusbar_get_context_id (g->status, "default");

  gui_connect_signals (g);
}
Ejemplo n.º 25
0
//---------------- [ Mo ta cac ham]  --------------------
GtkWidget* create_window(){
    GtkWidget *window;
    GtkWidget *vbox_main;
    GtkWidget *vbox_send;
    GtkWidget *vbox_rcv;
    GtkWidget *hbox;
    GtkWidget *hbox_bottom;

    GtkWidget *txt_pheptoan;
    GtkWidget *txt_ketqua;
    GtkWidget *scroll_pheptoan;
    GtkWidget *scroll_ketqua;

    GtkWidget *btn_send_msq;
    GtkWidget *btn_read_result;

    GtkWidget *img_top;
    GtkWidget *img_bottom;
    GtkWidget *img_left;

    // Tao nut thoat tu image + event_box
    GtkWidget *img_exit;
    GtkWidget *box_exit;

    // Tao nut goi thieu tu image + event_box
    GtkWidget *img_about;
    GtkWidget *box_about;

    // Thiet lap window
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(window), "Hàng đợi thông điệp");
        gtk_window_set_default_size(GTK_WINDOW(window), 640, 500);
        gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
        gtk_window_set_icon_from_file(GTK_WINDOW(window),"skin//icon.png",NULL);

    // Thiet lap Layout chinh
    vbox_main = gtk_vbox_new(FALSE, 5);
        gtk_container_add(GTK_CONTAINER(window), vbox_main);

    // Phan gioi thieu < TOP >
    img_top = gtk_image_new_from_file("skin//top.png");
        gtk_box_pack_start(GTK_BOX(vbox_main), img_top, TRUE, TRUE, 0);

    // Phan noi dung < CENTER >
    hbox = gtk_hbox_new(FALSE,3);
        gtk_box_pack_start(GTK_BOX(vbox_main), hbox, TRUE, TRUE, 0);

    // <LEFT>
    img_left = gtk_image_new_from_file("skin//left.png");
        gtk_box_pack_start(GTK_BOX(hbox), img_left, FALSE, FALSE, 0);

    // Thiet lap khung hien thi phep toan
    vbox_send = gtk_vbox_new(FALSE, 2);
        gtk_box_pack_start(GTK_BOX(hbox), vbox_send, TRUE, TRUE, 0);

    scroll_pheptoan = gtk_scrolled_window_new(NULL,NULL);
        gtk_box_pack_start(GTK_BOX(vbox_send), scroll_pheptoan, TRUE, TRUE, 0);

        txt_pheptoan = gtk_text_view_new();
            buf_pheptoan = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_pheptoan));
            gtk_widget_set_size_request(GTK_WIDGET(txt_pheptoan),205,300);
            gtk_container_add(GTK_CONTAINER(scroll_pheptoan), txt_pheptoan);


    btn_send_msq = gtk_button_new_with_label("Đọc các phép toán");
        g_signal_connect( G_OBJECT(btn_send_msq), "clicked", G_CALLBACK(send_and_cal), NULL);
        gtk_box_pack_start(GTK_BOX(vbox_send), btn_send_msq, TRUE, TRUE, 0);

    // Thiet lap khung hien thi ket qua
    vbox_rcv = gtk_vbox_new(FALSE,2);
        gtk_box_pack_start(GTK_BOX(hbox), vbox_rcv, TRUE, TRUE, 0);

    scroll_ketqua = gtk_scrolled_window_new(NULL,NULL);
        gtk_box_pack_start(GTK_BOX(vbox_rcv), scroll_ketqua, TRUE, TRUE, 0);

        txt_ketqua = gtk_text_view_new();
            buf_ketqua = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_ketqua));
            gtk_widget_set_size_request(GTK_WIDGET(txt_ketqua),205,300);
            gtk_container_add(GTK_CONTAINER(scroll_ketqua), txt_ketqua);

    btn_read_result = gtk_button_new_with_label("Xem file kết quả");
        g_signal_connect( G_OBJECT(btn_read_result), "clicked", G_CALLBACK(read_result), NULL);
        gtk_box_pack_start(GTK_BOX(vbox_rcv), btn_read_result, TRUE, TRUE, 0);
    // Ket thuc phan noi dung

    // Phan <BOTTOM>
    hbox_bottom = gtk_hbox_new(FALSE,0);
        gtk_box_pack_start(GTK_BOX(vbox_main), hbox_bottom, TRUE, TRUE, 0);

    img_bottom = gtk_image_new_from_file("skin//bottom.png");
        gtk_box_pack_start(GTK_BOX(hbox_bottom), img_bottom, TRUE, TRUE, 0);
    //Nut gioi thieu
    box_about = gtk_event_box_new();
        img_about = gtk_image_new_from_file("skin//about.png");
            gtk_container_add(GTK_CONTAINER(box_about), img_about);
        gtk_widget_set_events(box_about, GDK_BUTTON_PRESS_MASK);
        gtk_box_pack_start(GTK_BOX(hbox_bottom), box_about, TRUE, TRUE, 0);
        g_signal_connect( G_OBJECT(box_about), "button_press_event", G_CALLBACK(show_about), NULL);

    //Nut thoat
    box_exit = gtk_event_box_new();
        img_exit = gtk_image_new_from_file("skin//exit.png");
            gtk_container_add(GTK_CONTAINER(box_exit), img_exit);
        gtk_widget_set_events(box_exit, GDK_BUTTON_PRESS_MASK);
        gtk_box_pack_start(GTK_BOX(hbox_bottom), box_exit, TRUE, TRUE, 0);
        g_signal_connect( G_OBJECT(box_exit), "button_press_event", G_CALLBACK(gtk_main_quit), NULL);

    // ket thuc <BOTTOM>

    return window;

}
Ejemplo n.º 26
0
int main( int   argc, 
          char *argv[] )
{
  GtkWidget *window;
  GtkWidget *vbox;
  char buf[G_ASCII_DTOSTR_BUF_SIZE];

  GtkWidget *button;
  GtkWidget *entry;

  gtk_init (&argc, &argv);

  gdk_rgb_init();

  pos_x[0] = 100;
  pos_y[0] = 100;
  pos_x[1] = 300;
  pos_y[1] = 300;
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (window, "Test Input");

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  gtk_signal_connect (GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC (quit), NULL);

  /* Create the drawing area */

  drawing_area = gtk_drawing_area_new ();
  gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 512, 512);
  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /* Signals used to handle backing pixmap */

  gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
		      (GtkSignalFunc) expose_event, NULL);
  gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event",
		      (GtkSignalFunc) configure_event, NULL);

  /* Event signals */

  gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event",
		      (GtkSignalFunc) motion_notify_event, NULL);
  gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event",
		      (GtkSignalFunc) button_press_event, NULL);

  gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
			 | GDK_LEAVE_NOTIFY_MASK
			 | GDK_BUTTON_PRESS_MASK
			 | GDK_POINTER_MOTION_MASK
			 | GDK_POINTER_MOTION_HINT_MASK);

  
  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_gradient),
		      &a);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE,
				       1.0/a));
  gtk_widget_show (entry);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_gradient),
		      &b);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE,
				       1.0/b));
  gtk_widget_show (entry);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_gradient),
		      &c);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE,
				       1.0/c));
  gtk_widget_show (entry);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (entry), "activate",
		      GTK_SIGNAL_FUNC (change_spread),
		      &spread);
  gtk_entry_set_text  (GTK_ENTRY (entry),
		       g_strdup_printf ("%d", spread));
  gtk_widget_show (entry);

  
  /* .. And a quit button */
  button = gtk_button_new_with_label ("Quit");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (window));
  gtk_widget_show (button);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
Ejemplo n.º 27
0
static void
gtk_dateentry_init (GtkDateEntry * dateentry)
{
GtkWidget *widget;
GtkWidget *arrow;

	DB( g_print(" (dateentry) init\n") );

	widget=GTK_WIDGET(dateentry);

	GTK_BOX(widget)->homogeneous = FALSE;

	dateentry->date = g_date_new();
	/* today's date */
	g_date_set_time_t(dateentry->date, time(NULL));

	g_date_set_dmy(&dateentry->mindate, 1, 1, 1900);
	g_date_set_dmy(&dateentry->maxdate, 31, 12, 2200);
	
	dateentry->entry = gtk_entry_new ();
	gtk_widget_set_size_request(dateentry->entry, 90, -1);
	gtk_box_pack_start (GTK_BOX (dateentry), dateentry->entry, TRUE, TRUE, 0);

	dateentry->arrow = gtk_toggle_button_new ();
	arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (dateentry->arrow), arrow);
	gtk_box_pack_end (GTK_BOX (dateentry), dateentry->arrow, FALSE, FALSE, 0);

	gtk_widget_show (dateentry->entry);
	gtk_widget_show (dateentry->arrow);

	g_signal_connect (GTK_OBJECT (dateentry->arrow), "toggled",
				G_CALLBACK (gtk_dateentry_arrow_press), dateentry);

	g_signal_connect (GTK_OBJECT (dateentry->entry), "activate",
				G_CALLBACK (gtk_dateentry_entry_new), dateentry);

	g_signal_connect (GTK_OBJECT (dateentry->entry), "focus-out-event",
				G_CALLBACK (gtk_dateentry_focus), dateentry);


	g_signal_connect (GTK_OBJECT (dateentry->entry), "key_press_event",
				G_CALLBACK (gtk_dateentry_entry_key), dateentry);

    /* our popup window */
	dateentry->popwin = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_widget_set_events (dateentry->popwin,
				gtk_widget_get_events(dateentry->popwin) | GDK_KEY_PRESS_MASK);

	dateentry->frame = gtk_frame_new (NULL);
	gtk_container_add (GTK_CONTAINER (dateentry->popwin), dateentry->frame);
	gtk_frame_set_shadow_type (GTK_FRAME (dateentry->frame), GTK_SHADOW_OUT);
	gtk_widget_show (dateentry->frame);

	dateentry->calendar = gtk_calendar_new ();
	gtk_container_add (GTK_CONTAINER (dateentry->frame), dateentry->calendar);
	gtk_widget_show (dateentry->calendar);


	g_signal_connect (GTK_OBJECT (dateentry->popwin), "key_press_event",
				G_CALLBACK (key_press_popup), dateentry);


	g_signal_connect (GTK_OBJECT (dateentry->popwin), "button_press_event",
				G_CALLBACK (gtk_dateentry_button_press), dateentry);

	g_signal_connect (GTK_OBJECT (dateentry->calendar), "prev-year",
				G_CALLBACK (gtk_dateentry_calendar_year), dateentry);
	g_signal_connect (GTK_OBJECT (dateentry->calendar), "next-year",
				G_CALLBACK (gtk_dateentry_calendar_year), dateentry);
	g_signal_connect (GTK_OBJECT (dateentry->calendar), "prev-month",
				G_CALLBACK (gtk_dateentry_calendar_year), dateentry);
	g_signal_connect (GTK_OBJECT (dateentry->calendar), "next-month",
				G_CALLBACK (gtk_dateentry_calendar_year), dateentry);


	
	g_signal_connect (GTK_OBJECT (dateentry->calendar), "day-selected",
				G_CALLBACK (gtk_dateentry_calendar_getfrom), dateentry);

	g_signal_connect (GTK_OBJECT (dateentry->calendar), "day-selected-double-click",
				G_CALLBACK (gtk_dateentry_calendar_select), dateentry);

	gtk_dateentry_calendar_getfrom(NULL, dateentry);
}
Ejemplo n.º 28
0
void move_current_page_to_window (void)
{
    WidgetPageData *pageData;
    GtkWidget *page, *child, *newWindow;
    GList *dlist;
    gint pageNo;
    char *title;

    /* Extract current page's widget & it's parent from the notebook */
    pageNo = gtk_notebook_get_current_page (GTK_NOTEBOOK(notebook));
    page   = gtk_notebook_get_nth_page (GTK_NOTEBOOK(notebook), pageNo );
    dlist  = gtk_container_get_children (GTK_CONTAINER(page));
    if (!dlist ||  !(dlist->data))
    {
        /* Must already be a window */
        if (dlist)
           g_list_free (dlist);
        return;
    }
    child = (GtkWidget *)dlist->data;
    g_list_free (dlist);

    /* Create new window for widget, plus container, etc. */
    newWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    title = g_object_get_data (G_OBJECT(child), "title");
    if (!title)
        title = "GTetrinet";
    gtk_window_set_title (GTK_WINDOW (newWindow), title);
    gtk_container_set_border_width (GTK_CONTAINER (newWindow), 0);

    /* Attach key events to window */
    g_signal_connect (G_OBJECT(newWindow), "key-press-event",
                        GTK_SIGNAL_FUNC(keypress), NULL);
    g_signal_connect (G_OBJECT(newWindow), "key-release-event",
                        GTK_SIGNAL_FUNC(keyrelease), NULL);
    gtk_widget_set_events (newWindow, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
    gtk_window_set_resizable (GTK_WINDOW(newWindow), TRUE);

    /* Create store to point us back to page for later */
    pageData = g_new( WidgetPageData, 1 );
    pageData->parent = page;
    pageData->widget = child;
    pageData->pageNo = pageNo;

    /* Move main widget to window */
    gtk_widget_reparent (child, newWindow);

    /* Pass ID of parent (to put widget back) to window's destroy */
    g_signal_connect (G_OBJECT(newWindow), "destroy",
                        GTK_SIGNAL_FUNC(destroy_page_window),
                        (gpointer)(pageData));

    gtk_widget_show_all( newWindow );

    /* cure annoying side effect */
    if (gmsgstate)
        fields_gmsginput(TRUE);
    else
        fields_gmsginput(FALSE);

}
Ejemplo n.º 29
0
int main(int argc, char *argv[])
{
    int fd;

    GtkWidget *window;
    GtkWidget *drawing_area;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *button;
    
    /* Block SIGALRM in the main thread */
    sigset_t sigset;
    sigemptyset(&sigset);
    sigaddset(&sigset, SIGALRM);
    pthread_sigmask(SIG_BLOCK, &sigset, NULL);
    
    if (!g_thread_supported()) {
        g_thread_init(NULL);
    }

    gdk_threads_init();
    gdk_threads_enter();
    
    gtk_init(&argc, &argv);

    /* Framebuffer */
    
    /* Open framebuffer */
    if (0 > (fd = open("/dev/fb0", O_RDWR))) {
        printf("Failed to open fb\n");
        return -1;
    }

    /* Get fixed information */
    if(0 > ioctl(fd, FBIOGET_FSCREENINFO, &fi)) {
        printf("Failed to get fixed info\n");
        return -1;
    }

    /* Get variable information */
    if(0 > ioctl(fd, FBIOGET_VSCREENINFO, &vi)) {
        printf("Failed to get variable info\n");
        return -1;
    }

    /* Get raw bits buffer */
    if(MAP_FAILED == (bits = mmap(0, fi.smem_len,
                              PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0))) {
        printf("Failed to mmap fb\n");
        return -1;
    }

    printf("Framebuffer resolution: %d x %d\n", vi.xres, vi.yres);

    /* Calculate useful information */
    bpp = vi.bits_per_pixel >> 3;
    stride = fi.line_length / bpp;

    /* Do GTK stuff */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title((GtkWindow*)window, "ParallelDroid");
    g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);
    gtk_widget_show(vbox);

    drawing_area = gtk_drawing_area_new();
    gtk_widget_set_size_request(GTK_WIDGET(drawing_area), vi.xres, vi.yres);
    gtk_box_pack_start(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 0);
    gtk_widget_show(drawing_area);
    
    init_input_device();

    /* Events */
    gtk_widget_set_events(drawing_area, GDK_EXPOSURE_MASK
                          | GDK_LEAVE_NOTIFY_MASK
                          | GDK_BUTTON_PRESS_MASK
                          | GDK_BUTTON_RELEASE_MASK
                          | GDK_POINTER_MOTION_MASK
                          | GDK_POINTER_MOTION_HINT_MASK);

    g_signal_connect(drawing_area, "motion-notify-event",
                     G_CALLBACK (motion_notify_event), NULL);
    g_signal_connect(drawing_area, "button-press-event",
                     G_CALLBACK(button_press_event), NULL);
    g_signal_connect(drawing_area, "button-release-event",
                     G_CALLBACK(button_release_event), NULL);
    g_signal_connect(drawing_area, "expose-event",
                     G_CALLBACK(expose_event), NULL);
    g_signal_connect(drawing_area, "configure-event",
                     G_CALLBACK(configure_event), NULL);
                     
    /* Create and add buttons */
    hbox = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
    gtk_widget_show(hbox);
                     
    button = gtk_button_new_with_label("Back");
    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
    g_signal_connect(button, "clicked",
                     G_CALLBACK(back_button_clicked), NULL);
    gtk_widget_show(button);
    
    button = gtk_button_new_with_label("Home");
    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped(button, "clicked",
                             G_CALLBACK(home_button_clicked), NULL);
    gtk_widget_show(button);
    
    button = gtk_button_new_with_label("Menu");
    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped(button, "clicked",
                             G_CALLBACK(menu_button_clicked), NULL);
    gtk_widget_show(button);

    gtk_widget_show_all(window);

    pixmap = gdk_pixmap_new(drawing_area->window, IMAGE_WIDTH, 
                            IMAGE_HEIGHT, -1);

    (void)g_timeout_add(33, (GSourceFunc)timer_exe, drawing_area);

    gtk_main();
    gdk_threads_leave();
    
    return 0;
}
Ejemplo n.º 30
0
static GtkWidget *
show_view_create_widget (PlannerShowView *view)
{
	PlannerShowViewPriv  *priv;
	GtkWidget        *pertlayout;
	GtkWidget        *tree;
	GtkWidget        *sw;
	GtkWidget        *frame;
	GtkWidget        *layout;
	GtkWidget        *vpaned;
	GtkAdjustment    *hadj, *vadj;
	GtkTreeModel     *model;
	MrpTaskManager   *task_manager;
	GtkLabel         *label;
	GtkEntry         *entry;
	GtkButton        *button;
	GtkWidget        *hbox,*vbox,*vbox2;
	GtkWidget		   *progressbar;

	GtkWidget *randomtogglebutton;
	GtkWidget *deleteresourcetogglebutton;
	GtkWidget *ganttcharttogglebutton;
	GtkWidget *manulsettogglebutton;
	GtkWidget *table;

	MrpProject *project;
	GtkTreeSelection *selection;
	GList *task_list;

	project = planner_window_get_project (PLANNER_VIEW (view)->main_window);

	task_manager = imrp_project_get_task_manager(project);
	priv = view->priv;

	g_signal_connect (project,
			  "loaded",
			  G_CALLBACK (show_view_project_loaded_cb),
			  view);

	model = GTK_TREE_MODEL (planner_gantt_model_new (project));

	tree = planner_task_tree_new (PLANNER_VIEW (view)->main_window,
				      PLANNER_GANTT_MODEL (model),
				      FALSE,
				      TRUE,

				      COL_WBS, _("WBS"),
				      COL_NAME, _("Name"),
				      COL_START, _("Start"),
				      COL_FINISH, _("Finish"),
				      COL_WORK, _("Work"),
				      COL_DURATION, _("Duration"),
				      COL_SLACK, _("Slack"),
				      COL_COST, _("Cost"),
				      COL_ASSIGNED_TO, _("Assigned to"),

				      COL_COMPLETE, _("% Complete"),
				      -1);
	priv->tree = tree;


	priv->gantt = planner_gantt_chart_new_with_model (model);
	g_object_set (priv->gantt,
				  "header_height", 50,
			      NULL);
	planner_gantt_chart_set_view (PLANNER_GANTT_CHART (priv->gantt),
				      PLANNER_TASK_TREE (tree));

	//*********************
	//events sensitive on gantt widget
	gtk_widget_set_events (GTK_WIDGET (priv->gantt), GDK_SCROLL_MASK);

	g_signal_connect (priv->gantt, "scroll-event",
                    G_CALLBACK (show_view_chart_scroll_event), view);

	g_object_unref (model);

	g_signal_connect (priv->gantt,
			  "status_updated",
			  G_CALLBACK (show_view_gantt_status_updated_cb),
			  view);

	g_signal_connect (priv->gantt,
			  "resource_clicked",
			  G_CALLBACK (show_view_gantt_resource_clicked_cb),
			  view);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);

	//g_signal_connect (tree,
			  //"style_set",
			  //G_CALLBACK (show_view_tree_style_set_cb),
			  //view);

	//*********************
	//interface design
	//GtkVPaned
	//  GtkFrame -> GtkScrollWindow ->GtkLayout (pert view showed here)A
	//  GtkHBox
	//    GtkVBox -> GtkHBox (show run-in-time data showed here)B
	//                 GtkLabel
	//                 GtkEntry
	//    GtkScrollWindow  (gantt view showed here)C

	//interface design in A
	//GtkScrollWindow, let its scrollbar displayed if needed, put the pert view inside
	layout = gtk_layout_new(NULL,NULL);
	priv->pertlayout = layout;

	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (sw),
			        priv->pertlayout);

	//GtkFrame, put the GtkScrollWindow in the GtkFrame
	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (frame), sw);

	//GtkVPaned, add the GtkFrame in the GtkVPaned
	vpaned = gtk_vpaned_new ();
	gtk_paned_add1 (GTK_PANED (vpaned), frame);

	//interface design in B
    //GtkVBox, holds labels and entry and buttons
    vbox = gtk_vbox_new(FALSE, 0);
    vbox2 = gtk_vbox_new(FALSE,0);
    progressbar = gtk_progress_bar_new();
	//GtkLabel, "The Current Task Is: "
    label = gtk_label_new("当前执行审计任务: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, holds task name
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->currenttaskentry = entry;

    //GtkLabel, "The Current Delay Is:: "
    label = gtk_label_new("当前审计延迟时间: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, holds task delay
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->currentdelayentry = entry;

    //GtkLabel, "The Current duration is "
    label = gtk_label_new("当前审计总时间: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, holds total duration
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->currentdurationentry = entry;

    //GtkLabel, "The Duration has changed :: "
    label = gtk_label_new("延迟后审计总时间: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, The Duration has changed to
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->lastdurationentry = entry;

    lastdurationentry = entry;

	//GtkLabel, "delete resource"
	label = gtk_label_new("调整的审计人员: ");
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

	//GtkEntry, delete resource
	entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
	priv->deleteresourceentry = entry;



	GtkWidget *labelChild;
	PangoFontDescription *font1;
	short fontSize = 8;


    //GtkButton, delete resource
    button = gtk_button_new_with_label("重大事项显示");
    GdkColor color;
       color.red = 50000;
       color.green = 20000;
       color.blue = 15000;
       gtk_widget_modify_bg(button, GTK_STATE_INSENSITIVE, &color);

      // font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       //pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
      // labelChild = gtk_bin_get_child(GTK_BIN(button));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了

    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (button),	FALSE,FALSE, 0);
    g_signal_connect (button,
       			  "clicked",
       			  G_CALLBACK (show_view_delete_resource_cb),
       			 view);
    priv->deleteresourcebutton = button;

    //total duration display
	button = gtk_button_new_with_label("审计总时间无延迟");
	GdkColor color1;
	color1.red = 50000;
	color1.green = 20000;
	color1.blue = 15000;
	gtk_widget_modify_bg(button, GTK_STATE_INSENSITIVE, &color1);

	 // font1 = pango_font_description_from_string("Sans");//"Sans"字体名
	     //  pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
	     //  labelChild = gtk_bin_get_child(GTK_BIN(button));//取出GtkButton里的label
	       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (button), FALSE,FALSE, 0);
	g_signal_connect(button, "clicked",
			G_CALLBACK (show_view_delete_resource_cb), view);
	priv->displaytotaldurationbutton = button;

    //GtkButton, go to next task
    button = gtk_button_new_with_label("执行下一审计任务");
    GdkColor color2;
    color2.red = 50000;
    color2.green = 10000;
    color2.blue = 10000;
    gtk_widget_modify_bg(button, GTK_STATE_INSENSITIVE, &color2);

   // font1 = pango_font_description_from_string("Sans");//"Sans"字体名
        // pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
        // labelChild = gtk_bin_get_child(GTK_BIN(button));//取出GtkButton里的label
         gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (button), FALSE,FALSE, 0);
    g_signal_connect (button,
    			  "clicked",
    			  G_CALLBACK (show_view_next_task_cb),
    			 view);
    priv->nextstepbutton = button;


    table = gtk_table_new(2, 2, FALSE);
    manulsettogglebutton = gtk_toggle_button_new_with_label("手动设置审计任务延迟");
    gtk_widget_set_size_request(manulsettogglebutton,5,7);



    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
    pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
    labelChild = gtk_bin_get_child(GTK_BIN( manulsettogglebutton));//取出GtkButton里的label
    gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了






    randomtogglebutton = gtk_toggle_button_new_with_label("随机设置审计任务延迟");

    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
       labelChild = gtk_bin_get_child(GTK_BIN( randomtogglebutton));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了

    deleteresourcetogglebutton = gtk_toggle_button_new_with_label("参审人员随机调整");
    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
       labelChild = gtk_bin_get_child(GTK_BIN(  deleteresourcetogglebutton));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了

    ganttcharttogglebutton = gtk_toggle_button_new_with_label("干特图路径选择");
    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
       labelChild = gtk_bin_get_child(GTK_BIN( ganttcharttogglebutton));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了


	gtk_table_set_row_spacings(GTK_TABLE(table), 2);
	gtk_table_set_col_spacings(GTK_TABLE(table), 2);
	gtk_table_attach_defaults(GTK_TABLE(table), manulsettogglebutton, 0, 1, 0,1);
	gtk_table_attach_defaults(GTK_TABLE(table), randomtogglebutton, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(table), deleteresourcetogglebutton, 1,
			2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(table), ganttcharttogglebutton, 1, 2, 1,
			2);
	gtk_signal_connect(GTK_OBJECT(randomtogglebutton), "toggle",
				GTK_SIGNAL_FUNC(select_random_task), view);
	gtk_signal_connect(GTK_OBJECT(deleteresourcetogglebutton), "toggle",
			GTK_SIGNAL_FUNC(select_deleteresource), view);
	priv->manulsettogglebutton = manulsettogglebutton;
	priv->randomtogglebutton = randomtogglebutton;
	priv->deleteresourcetogglebutton = deleteresourcetogglebutton;
	priv->ganttcharttogglebutton = ganttcharttogglebutton;
	//gtk_table_attach_defaults(GTK_TABLE(table), labelprobability,1,2,2,3);
//   		   gtk_table_attach_defaults(GTK_TABLE(table), togglebutton,0,2,3,4);
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (table), FALSE, FALSE, 0);
	//GtkButton, auto optimization
	button = gtk_button_new_with_label("Auto Optimization");



    sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (sw),
				    priv->gantt);
	gtk_box_pack_start(GTK_BOX (vbox2), GTK_WIDGET (sw), TRUE, TRUE,0);
	gtk_widget_set_size_request(progressbar,150,36);
	gtk_box_pack_start(GTK_BOX (vbox2), GTK_WIDGET (progressbar), FALSE, FALSE, 0);
	priv->progressbar = progressbar;
	//put the GtkHBox in the GtkFrame, put the GtkVBox and GtkScrollWindow in the GtkHBox
	hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX (hbox), GTK_WIDGET (vbox), FALSE,TRUE, 0);
	gtk_box_pack_end(GTK_BOX (hbox), GTK_WIDGET (vbox2), TRUE, TRUE, 10);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (hbox));

	//add the GtkFrame in the GtkVPaned
	gtk_paned_add2 (GTK_PANED (vpaned), frame);

	gtk_paned_set_position (GTK_PANED (vpaned), 250);

	g_signal_connect (tree,
			  "row_expanded",
			  G_CALLBACK (show_view_row_expanded),
			  priv->gantt);

	g_signal_connect (tree,
			  "row_collapsed",
			  G_CALLBACK (show_view_row_collapsed),
			  priv->gantt);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (tree));





	return vpaned;

}