示例#1
0
static GtkWidget *
create_window (int confirm_mode)
{
  GtkWidget *w;
  GtkWidget *win, *box, *ebox;
  GtkWidget *sbox, *bbox;
  GtkAccelGroup *acc;

  /* fixme: check the grabbing code against the one we used with the
     old gpg-agent */
  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  acc = gtk_accel_group_new ();

  gtk_signal_connect (GTK_OBJECT (win), "delete_event",
                      GTK_SIGNAL_FUNC (delete_event), NULL);

#if 0
  gtk_signal_connect (GTK_OBJECT(win), "destroy", gtk_main_quit, NULL);
#endif
  gtk_signal_connect (GTK_OBJECT(win), "size-request", constrain_size, NULL);
  if (!confirm_mode)
    {
      gtk_signal_connect (GTK_OBJECT(win),
                          pinentry->grab ? "map-event" : "focus-in-event",
                          grab_keyboard, NULL);
      gtk_signal_connect (GTK_OBJECT(win),
                          pinentry->grab ? "unmap-event" : "focus-out-event",
                          ungrab_keyboard, NULL);
    }
  gtk_accel_group_attach(acc, GTK_OBJECT(win));

  box = gtk_vbox_new (FALSE, 5);
  gtk_container_add (GTK_CONTAINER(win), box);
  gtk_container_set_border_width (GTK_CONTAINER (box), 5);

  if (pinentry->description)
    {
      w = create_utf8_label (pinentry->description);
      gtk_box_pack_start (GTK_BOX(box), w, TRUE, FALSE, 0);
    }
  if (pinentry->error && !confirm_mode)
    {
      GtkStyle *style;
      GdkColormap *cmap;
      GdkColor color[1] = {{0, 0xffff, 0, 0}};
      gboolean success[1];

      w = create_utf8_label (pinentry->error);
      gtk_box_pack_start (GTK_BOX(box), w, TRUE, FALSE, 5);

      /* fixme: Do we need to release something, or is there a more
         easy way to set a text color? */
      gtk_widget_realize (win);
      cmap = gdk_window_get_colormap (win->window);
      assert (cmap);
      gdk_colormap_alloc_colors (cmap, color, 1, FALSE, TRUE, success);
      if (success[0])
        {
          gtk_widget_ensure_style(w);
          style = gtk_style_copy(gtk_widget_get_style(w));
          style->fg[GTK_STATE_NORMAL] = color[0];
          gtk_widget_set_style(w, style);
        } 
    }

  ebox = gtk_hbox_new (FALSE, 5);
  gtk_box_pack_start (GTK_BOX(box), ebox, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (ebox), 5);


  if (!confirm_mode)
    {
      if (pinentry->prompt)
        {
          w = create_utf8_label (pinentry->prompt);
          gtk_box_pack_start (GTK_BOX(ebox), w, FALSE, FALSE, 0);
        }
      entry = gtk_secure_entry_new ();
      gtk_signal_connect (GTK_OBJECT (entry), "activate",
                          GTK_SIGNAL_FUNC (enter_callback), entry);
      gtk_box_pack_start (GTK_BOX(ebox), entry, TRUE, TRUE, 0);
      gtk_secure_entry_set_visibility (GTK_SECURE_ENTRY(entry), FALSE);
      gtk_signal_connect_after (GTK_OBJECT(entry), "button_press_event",
                                unselect, NULL);
      gtk_widget_grab_focus (entry);
      gtk_widget_show (entry);

      if (pinentry->enhanced)
        {
          sbox = gtk_hbox_new(FALSE, 5);
          gtk_box_pack_start(GTK_BOX(box), sbox, FALSE, FALSE, 0);
          
          w = gtk_label_new ("Forget secret after");
          gtk_box_pack_start(GTK_BOX(sbox), w, FALSE, FALSE, 0);
          gtk_widget_show(w);
          
          time_out = gtk_spin_button_new
            (GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, HUGE_VAL,
                                               1, 60, 60)),2,0);
          gtk_box_pack_start (GTK_BOX(sbox), time_out, FALSE, FALSE, 0);
          gtk_widget_show (time_out);
	
          w = gtk_label_new ("seconds");
          gtk_box_pack_start (GTK_BOX(sbox), w, FALSE, FALSE, 0); 
          gtk_widget_show (w);
          gtk_widget_show (sbox);
          
          insure = gtk_check_button_new_with_label
            ("ask before giving out secret");
          gtk_box_pack_start (GTK_BOX(box), insure, FALSE, FALSE, 0);
          gtk_widget_show (insure);
        }
    }


  bbox = gtk_hbutton_box_new();
  gtk_box_pack_start (GTK_BOX(box), bbox, TRUE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
  
  w = gtk_button_new_with_label (pinentry->ok ? pinentry->ok : "OK");
  gtk_container_add (GTK_CONTAINER(bbox), w);
  if (!confirm_mode)
    {
      gtk_signal_connect (GTK_OBJECT(w), "clicked", button_clicked, "ok");
      GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
      gtk_widget_grab_default (w);
      gtk_signal_connect_object (GTK_OBJECT (entry), "focus_in_event",
                                 GTK_SIGNAL_FUNC (gtk_widget_grab_default),
                                 GTK_OBJECT (w));
    }
  else
    {
      gtk_signal_connect (GTK_OBJECT(w), "clicked",
                          confirm_button_clicked, "ok");
      GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
    }

  gtk_widget_show (w);
  
  if (!pinentry->one_button)
    {
      w = gtk_button_new_with_label (pinentry->cancel 
                                     ? pinentry->cancel : "Cancel");
      gtk_container_add (GTK_CONTAINER(bbox), w);
      gtk_accel_group_add (acc, GDK_Escape, 0, 0, GTK_OBJECT(w), "clicked");
      gtk_signal_connect (GTK_OBJECT(w), "clicked", 
                          confirm_mode? confirm_button_clicked: button_clicked,
                          NULL);
      GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
    }

  gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);

  gtk_widget_show_all (win);

  return win;
}
示例#2
0
static void
popup_create_auth(gtk_ui_t *gu, prop_t *p)
{
  GtkWidget *vbox, *hbox;
  GtkWidget *win;
  GtkWidget *l, *e, *w;
  prop_sub_t *s;

  popup_t *pop = calloc(1, sizeof(popup_t));

  pop->p = prop_ref_inc(p);
  LIST_INSERT_HEAD(&gu->popups, pop, link);

  /* The window */

  pop->win = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
  gtk_window_set_title(GTK_WINDOW(win), "Authentication request");
  gtk_window_set_default_size(GTK_WINDOW(win), 400, 180);
  gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
  gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT);
  //  gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(gu->gu_window));


  /* Vbox */

  vbox = gtk_vbox_new(FALSE, 1);
  gtk_container_set_border_width(GTK_CONTAINER(vbox), 1);
  gtk_container_add(GTK_CONTAINER(win), vbox);

  /* ID label */
  l = gtk_label_new("");
  gtk_box_pack_start(GTK_BOX(vbox), l, FALSE, TRUE, 0);

  s = prop_subscribe(0,
		     PROP_TAG_NAME("self", "id"),
		     PROP_TAG_CALLBACK_STRING, gu_subscription_set_label, l,
		     PROP_TAG_COURIER, glibcourier, 
		     PROP_TAG_NAMED_ROOT, p, "self",
		     NULL);
  gu_unsubscribe_on_destroy(GTK_OBJECT(l), s);

  /* Reason label */
  l = gtk_label_new("");
  gtk_box_pack_start(GTK_BOX(vbox), l, FALSE, TRUE, 0);

  s = prop_subscribe(0,
		     PROP_TAG_NAME("self", "reason"),
		     PROP_TAG_CALLBACK_STRING, gu_subscription_set_label, l,
		     PROP_TAG_COURIER, glibcourier,
		     PROP_TAG_NAMED_ROOT, p, "self",
		     NULL);

  gu_unsubscribe_on_destroy(GTK_OBJECT(l), s);

  /* Username */

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

  l = gtk_label_new("Username:"******"activate", G_CALLBACK(auth_ok), pop);

  /* Password */

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

  l = gtk_label_new("Password:"******"activate", G_CALLBACK(auth_ok), pop);


  /* Separator */

  w = gtk_hseparator_new();
  gtk_box_pack_start(GTK_BOX(vbox), w, FALSE, TRUE, 0);

  /* Action buttons */

  hbox = gtk_hbutton_box_new();
  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);

  w = gtk_button_new_from_stock(GTK_STOCK_OK);
  gtk_container_add(GTK_CONTAINER(hbox), w);
  g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(auth_ok), pop);

  w = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
  gtk_container_add(GTK_CONTAINER(hbox), w);
  g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(auth_cancel), pop);

  gtk_widget_show_all(win);
}
示例#3
0
文件: calendar.c 项目: omork/mythryl
void create_calendar()
{
  GtkWidget *window;
  GtkWidget *vbox, *vbox2, *vbox3;
  GtkWidget *hbox;
  GtkWidget *hbbox;
  GtkWidget *calendar;
  GtkWidget *toggle;
  GtkWidget *button;
  GtkWidget *frame;
  GtkWidget *separator;
  GtkWidget *label;
  GtkWidget *bbox;
  static CalendarData calendar_data;
  gint i;
  
  struct {
    char *label;
  } flags[] =
    {
      { "Show Heading" },
      { "Show Day Names" },
      { "No Month Change" },
      { "Show Week Numbers" },
      { "Week Start Monday" }
    };

  
  calendar_data.window = NULL;
  calendar_data.font = NULL;
  calendar_data.font_dialog = NULL;

  for (i=0; i<5; i++) {
    calendar_data.settings[i]=0;
  }

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "GtkCalendar Example");
  gtk_container_border_width (GTK_CONTAINER (window), 5);
  gtk_signal_connect(GTK_OBJECT(window), "destroy",
		     GTK_SIGNAL_FUNC(gtk_main_quit),
		     NULL);
  gtk_signal_connect(GTK_OBJECT(window), "delete-event",
		     GTK_SIGNAL_FUNC(gtk_false),
		     NULL);

  gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE);

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

  /*
   * The top part of the window, Calendar, flags and fontsel.
   */

  hbox = gtk_hbox_new(FALSE, DEF_PAD);
  gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, DEF_PAD);
  hbbox = gtk_hbutton_box_new();
  gtk_box_pack_start(GTK_BOX(hbox), hbbox, FALSE, FALSE, DEF_PAD);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_SPREAD);
  gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 5);

  /* Calendar widget */
  frame = gtk_frame_new("Calendar");
  gtk_box_pack_start(GTK_BOX(hbbox), frame, FALSE, TRUE, DEF_PAD);
  calendar=gtk_calendar_new();
  calendar_data.window = calendar;
  calendar_set_flags(&calendar_data);
  gtk_calendar_mark_day ( GTK_CALENDAR(calendar), 19);	
  gtk_container_add( GTK_CONTAINER( frame), calendar);
  gtk_signal_connect (GTK_OBJECT (calendar), "month_changed", 
                      GTK_SIGNAL_FUNC (calendar_month_changed),
		      &calendar_data);
  gtk_signal_connect (GTK_OBJECT (calendar), "day_selected", 
                      GTK_SIGNAL_FUNC (calendar_day_selected),
		      &calendar_data);
  gtk_signal_connect (GTK_OBJECT (calendar), "day_selected_double_click", 
                      GTK_SIGNAL_FUNC (calendar_day_selected_double_click),
		      &calendar_data);
  gtk_signal_connect (GTK_OBJECT (calendar), "prev_month", 
                      GTK_SIGNAL_FUNC (calendar_prev_month),
		      &calendar_data);
  gtk_signal_connect (GTK_OBJECT (calendar), "next_month", 
                      GTK_SIGNAL_FUNC (calendar_next_month),
		      &calendar_data);
  gtk_signal_connect (GTK_OBJECT (calendar), "prev_year", 
                      GTK_SIGNAL_FUNC (calendar_prev_year),
		      &calendar_data);
  gtk_signal_connect (GTK_OBJECT (calendar), "next_year", 
                      GTK_SIGNAL_FUNC (calendar_next_year),
		      &calendar_data);


  separator = gtk_vseparator_new ();
  gtk_box_pack_start (GTK_BOX (hbox), separator, FALSE, TRUE, 0);

  vbox2 = gtk_vbox_new(FALSE, DEF_PAD);
  gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, DEF_PAD);
  
  /* Build the Right frame with the flags in */ 

  frame = gtk_frame_new("Flags");
  gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, DEF_PAD);
  vbox3 = gtk_vbox_new(TRUE, DEF_PAD_SMALL);
  gtk_container_add(GTK_CONTAINER(frame), vbox3);

  for (i = 0; i < 5; i++)
    {
      toggle = gtk_check_button_new_with_label(flags[i].label);
      gtk_signal_connect (GTK_OBJECT (toggle),
			    "toggled",
			    GTK_SIGNAL_FUNC(calendar_toggle_flag),
			    &calendar_data);
      gtk_box_pack_start (GTK_BOX (vbox3), toggle, TRUE, TRUE, 0);
      calendar_data.flag_checkboxes[i]=toggle;
    }
  /* Build the right font-button */ 
  button = gtk_button_new_with_label("Font...");
  gtk_signal_connect (GTK_OBJECT (button),
		      "clicked",
		      GTK_SIGNAL_FUNC(calendar_select_font),
		      &calendar_data);
  gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);

  /*
   *  Build the Signal-event part.
   */

  frame = gtk_frame_new("Signal events");
  gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, DEF_PAD);

  vbox2 = gtk_vbox_new(TRUE, DEF_PAD_SMALL);
  gtk_container_add(GTK_CONTAINER(frame), vbox2);
  
  hbox = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0);
  label = gtk_label_new ("Signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  calendar_data.last_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.last_sig, FALSE, TRUE, 0);

  hbox = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0);
  label = gtk_label_new ("Previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  calendar_data.prev_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev_sig, FALSE, TRUE, 0);

  hbox = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0);
  label = gtk_label_new ("Second previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  calendar_data.prev2_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev2_sig, FALSE, TRUE, 0);

  bbox = gtk_hbutton_box_new ();
  gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);

  button = gtk_button_new_with_label ("Close");
  gtk_signal_connect (GTK_OBJECT (button), "clicked", 
		      GTK_SIGNAL_FUNC (gtk_main_quit), 
		      NULL);
  gtk_container_add (GTK_CONTAINER (bbox), button);
  gtk_widget_set_flags (button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button);

  gtk_widget_show_all(window);
}
示例#4
0
/* compare */
static int _compare(char const * string1, char const * string2)
{
	Compare compare;
	GtkWidget * window;
	GtkWidget * vbox;
	GtkWidget * bbox;
	GtkWidget * widget;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(window), 4);
	gtk_window_set_title(GTK_WINDOW(window), _("Compare strings"));
	g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(
				_compare_on_closex), window);
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
#else
	vbox = gtk_vbox_new(FALSE, 4);
#endif
	compare.entry1 = gtk_entry_new();
	if(string1 != NULL)
		gtk_entry_set_text(GTK_ENTRY(compare.entry1), string1);
	g_signal_connect_swapped(compare.entry1, "changed", G_CALLBACK(
				_compare_on_changed), &compare);
	gtk_box_pack_start(GTK_BOX(vbox), compare.entry1, FALSE, TRUE, 0);
	compare.entry2 = gtk_entry_new();
	if(string2 != NULL)
		gtk_entry_set_text(GTK_ENTRY(compare.entry2), string2);
	g_signal_connect_swapped(compare.entry2, "changed", G_CALLBACK(
				_compare_on_changed), &compare);
	gtk_box_pack_start(GTK_BOX(vbox), compare.entry2, FALSE, TRUE, 0);
	compare.label = gtk_label_new(NULL);
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(compare.label, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(compare.label), 0.0, 0.5);
#endif
#if GTK_CHECK_VERSION(2, 18, 0)
	compare.infobar = gtk_info_bar_new();
	widget = gtk_info_bar_get_content_area(GTK_INFO_BAR(compare.infobar));
	gtk_info_bar_set_message_type(GTK_INFO_BAR(compare.infobar),
			GTK_MESSAGE_OTHER);
	gtk_container_add(GTK_CONTAINER(widget), compare.label);
	gtk_box_pack_start(GTK_BOX(vbox), compare.infobar, FALSE, TRUE, 0);
#else
	gtk_box_pack_start(GTK_BOX(vbox), compare.label, FALSE, TRUE, 0);
#endif
#if GTK_CHECK_VERSION(3, 0, 0)
	bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
	bbox = gtk_hbutton_box_new();
#endif
	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
#if GTK_CHECK_VERSION(3, 10, 0)
	widget = gtk_button_new_with_label(_("Close"));
	gtk_button_set_image(GTK_BUTTON(widget),
			gtk_image_new_from_icon_name(GTK_STOCK_CLOSE,
				GTK_ICON_SIZE_BUTTON));
#else
	widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
#endif
	g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
				_compare_on_close), window);
	gtk_container_add(GTK_CONTAINER(bbox), widget);
	gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	gtk_widget_show_all(window);
	gtk_main();
	return 0;
}
GtkWindow * gw_categories_edit_box_create ( GtkWindow *window, GWDBCatalog *catalog) {
	/* This window must be single, this property may be changed */
	static GtkWidget *w = NULL;
	GtkWidget *vb, *hb, *scr, *list, *bt, *hsp, *ent, *lbl, *frm, *txt;
	guint bt_key;
	GtkAccelGroup *accel;
	GtkTooltips *tips;
	gchar *text_utf8 = NULL;


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

	/* Init an accel group for shortcuts */
	accel = gtk_accel_group_new ( );

	/* Init tooltips */
	tips = gtk_tooltips_new ( );

	if ( !w ) {
		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);
		gtk_window_set_policy ( GTK_WINDOW ( w), FALSE, FALSE, FALSE);
		g_strdup_to_gtk_text ( _( "Edit categories"), text_utf8);
		gtk_window_set_title ( GTK_WINDOW ( w), text_utf8);
		g_free ( text_utf8);
		gtk_container_set_border_width ( GTK_CONTAINER ( w), 5);

		gtk_object_set_data ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_MAIN_WINDOW, window);

		gtk_signal_connect ( GTK_OBJECT ( w), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &w);

		/* Vertical box */
		vb = gtk_vbox_new ( FALSE, 10);
		gtk_container_add ( GTK_CONTAINER ( w), vb);

		/* Frame category description */
		g_strdup_to_gtk_text ( _( "Categories list : "), text_utf8);
		frm = gtk_frame_new ( text_utf8);
		g_free ( text_utf8);
		gtk_box_pack_start ( GTK_BOX ( vb), frm, TRUE, TRUE, 0);

		/* 1st horizontal box*/
		hb = gtk_hbox_new ( TRUE, 0);
		gtk_container_set_border_width ( GTK_CONTAINER ( hb), 5);
		gtk_container_add ( GTK_CONTAINER ( frm), hb);

		/* Scrolled panel */
		scr = gtk_scrolled_window_new ( NULL, NULL);
		gtk_box_pack_start ( GTK_BOX ( hb), scr, TRUE, TRUE, 0);

		/* Categories list */
		list = gtk_clist_new ( 2);
		gtk_widget_set_usize ( list, 100, 100);
		/*gtk_widget_ref ( list);*/
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_CATEGORIES_LIST, list, /*(GtkDestroyNotify)gtk_widget_unref*/NULL);
		/*gtk_signal_connect ( GTK_OBJECT ( list), "click_column", GTK_SIGNAL_FUNC ( gw_categories_edit_box_list_click_column), w);*/
		gtk_signal_connect ( GTK_OBJECT ( list), "select_row", GTK_SIGNAL_FUNC ( gw_categories_edit_box_list_select_row), w);
		gtk_container_add ( GTK_CONTAINER ( scr), list);
		gtk_clist_set_column_width ( GTK_CLIST ( list), 0, 80);
		gtk_clist_set_column_width ( GTK_CLIST ( list), 1, 20);
		gtk_clist_column_titles_show ( GTK_CLIST ( list));

		/* 1st column label */
		g_strdup_to_gtk_text ( _( "Name"), text_utf8);
		lbl = gtk_label_new ( text_utf8);
		g_free ( text_utf8);
		gtk_clist_set_column_widget ( GTK_CLIST ( list), 0, lbl);

		/* 2nd column label */
		g_strdup_to_gtk_text ( _( "Description"), text_utf8);
		lbl = gtk_label_new ( text_utf8);
		g_free ( text_utf8);
		gtk_clist_set_column_widget ( GTK_CLIST ( list), 1, lbl);

		/* 2nd horizontal box */
		hb = gtk_hbox_new ( TRUE, 0);
		gtk_box_pack_start ( GTK_BOX ( vb), hb, TRUE, TRUE, 0);

		/* Update button */
		bt = gtk_button_new_with_label ( "");
		g_strdup_to_gtk_text ( _( "_Update"), text_utf8);
		bt_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( bt)->child), text_utf8);
		g_free ( text_utf8);
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_UPDATE_BUTTON, bt, /*(GtkDestroyNotify)gtk_widget_unref*/NULL);
		gtk_widget_add_accelerator ( bt, "clicked", accel, bt_key, GDK_MOD1_MASK, 0);
		gtk_signal_connect ( GTK_OBJECT ( bt), "clicked", GTK_SIGNAL_FUNC ( gw_categories_edit_box_update_click), GTK_WINDOW ( w));
		gtk_object_set_user_data ( GTK_OBJECT ( bt), w);
		gtk_box_pack_start ( GTK_BOX ( hb), bt, FALSE, TRUE, 5);
		g_strdup_to_gtk_text ( _( "Allows to update category properties of the selected category. Clicks on Add / Update button to save updates."), text_utf8);
		gtk_tooltips_set_tip ( tips, bt, text_utf8, GW_REF_CATEGORIES_EDIT_BOX_UPDATE_BUTTON_TOOLTIPS);
		g_free ( text_utf8);
		gtk_widget_set_sensitive ( GTK_WIDGET ( bt), FALSE);

		/* Remove button */
		bt = gtk_button_new_with_label ( "");
		g_strdup_to_gtk_text ( _( "_Remove"), text_utf8);
		bt_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( bt)->child), text_utf8);
		g_free ( text_utf8);
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_REMOVE_BUTTON, bt, /*(GtkDestroyNotify) gtk_widget_unref)*/NULL);
		gtk_widget_add_accelerator ( bt, "clicked", accel, bt_key, GDK_MOD1_MASK, 0);
		gtk_signal_connect ( GTK_OBJECT ( bt), "clicked", GTK_SIGNAL_FUNC ( gw_categories_edit_box_remove_click), GTK_WINDOW ( w));
		gtk_object_set_user_data ( GTK_OBJECT ( bt), w);
		gtk_box_pack_start ( GTK_BOX ( hb), bt, FALSE, TRUE, 5);
		g_strdup_to_gtk_text ( _( "Remove the selected category from categories list. This categories may removed only if there's not any item which uses this category."), text_utf8);
		gtk_tooltips_set_tip ( tips, bt, text_utf8, GW_REF_CATEGORIES_EDIT_BOX_REMOVE_BUTTON_TOOLTIPS);
		g_free ( text_utf8);
		gtk_widget_set_sensitive ( GTK_WIDGET ( bt), FALSE);

		/* 1st horizontal separator */
		hsp = gtk_hseparator_new ( );
		gtk_box_pack_start ( GTK_BOX ( vb), hsp, TRUE, TRUE, 0);

		/* 3rd horizontal box */
		hb = gtk_hbox_new ( FALSE, 0);
		gtk_box_pack_start ( GTK_BOX ( vb), hb, TRUE, TRUE, 0);

		/* Label for category name */
		g_strdup_to_gtk_text ( _( "Category name : "), text_utf8);
		lbl = gtk_label_new ( text_utf8);
		g_free ( text_utf8);
		gtk_box_pack_start ( GTK_BOX ( hb), lbl, FALSE, FALSE, 5);

		/* Field text for category name */
		ent = gtk_entry_new ( );
		/*gtk_widget_ref ( ent);*/
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_CATEGORY_NAME_ENTRY, ent, /*(GtkDestroyNotify)gtk_widget_unref*/NULL);
		gtk_signal_connect ( GTK_OBJECT ( ent), "changed", GTK_SIGNAL_FUNC ( gw_categories_edit_box_category_name_changed), w);
		gtk_box_pack_start ( GTK_BOX ( hb), ent, TRUE, TRUE, 5);
		g_strdup_to_gtk_text ( _( "Enter the name of the category."), text_utf8);
		gtk_tooltips_set_tip ( tips, ent, text_utf8, GW_REF_CATEGORIES_EDIT_BOX_CATEGORY_NAME_ENTRY_TOOLTIPS);
		g_free ( text_utf8);

		/* Frame category description */
		g_strdup_to_gtk_text ( _( "Description : "), text_utf8);
		frm = gtk_frame_new ( text_utf8);
		g_free ( text_utf8);
		gtk_box_pack_start ( GTK_BOX ( vb), frm, TRUE, TRUE, 0);

		/* 4th horizontal box */
		hb = gtk_hbox_new ( TRUE, 0);
		gtk_container_set_border_width ( GTK_CONTAINER ( hb), 5);
		gtk_container_add ( GTK_CONTAINER ( frm), hb);

		/* Text scrollbar */
		scr = gtk_scrolled_window_new ( NULL, NULL);
		gtk_box_pack_start ( GTK_BOX ( hb), scr, TRUE, TRUE, 0);
		gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scr), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

		/* Text area for category description */
		txt = gtk_text_area_new ( );
		gtk_text_area_set_editable ( GTK_TEXT_AREA ( txt), TRUE);
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_CATEGORY_DESCRIPTION_TEXT, txt, /*(GtkDestroyNotify)gtk_widget_unref*/NULL);
#if defined ( HAVE_GTK12)
 		gtk_signal_connect ( GTK_OBJECT ( txt), "changed", GTK_SIGNAL_FUNC ( gw_categories_edit_box_category_description_changed), w);
#elif defined ( HAVE_GTK20)
		g_signal_connect ( G_OBJECT ( gtk_text_view_get_buffer ( GTK_TEXT_VIEW ( txt))), "changed", GTK_SIGNAL_FUNC ( gw_categories_edit_box_category_description_changed), w);
#endif
		gtk_container_add ( GTK_CONTAINER ( scr), txt);
		g_strdup_to_gtk_text ( _( "Enter the description of the category."), text_utf8);
		gtk_tooltips_set_tip ( tips, txt, text_utf8, GW_REF_CATEGORIES_EDIT_BOX_CATEGORY_DESCRIPTION_TEXT_TOOLTIPS);
		g_free ( text_utf8);

		/* The Add/Update/Close button area */
		hb = gtk_hbutton_box_new ( );
		gtk_button_box_set_layout ( GTK_BUTTON_BOX ( hb), GTK_BUTTONBOX_END);
		gtk_button_box_set_spacing ( GTK_BUTTON_BOX ( hb), 5);
		gtk_box_pack_end ( GTK_BOX ( vb), hb, FALSE, FALSE, 0);

		/* Add/Update button */
		bt = gtk_button_new_with_label ( "");
		/* Is it not mandatory? */
		/*g_strdup_to_gtk_text ( _( "Add"), text_utf8);
		gtk_label_set_text ( GTK_LABEL ( GTK_BIN ( bt)->child), text_utf8);
		g_free ( text_utf8);
		*/
		/*gtk_widget_ref ( bt);*/
		gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_ADD_UPDATE_BUTTON, bt, /*(GtkDestroyNotify)gtk_widget_unref*/NULL);
		g_strdup_to_gtk_text ( _( "Add / Update"), text_utf8);
		bt_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( bt)->child), text_utf8);
		g_free ( text_utf8);
		gtk_widget_add_accelerator ( bt, "clicked", accel, bt_key, GDK_MOD1_MASK, 0);
		gtk_signal_connect ( GTK_OBJECT ( bt), "clicked", GTK_SIGNAL_FUNC ( gw_categories_edit_box_add_update_click), w);
		gtk_object_set_user_data ( GTK_OBJECT ( bt), w);
		gtk_box_pack_start ( GTK_BOX ( hb), bt, TRUE, TRUE, 5);
		g_strdup_to_gtk_text ( _( "Save properties changes of category."), text_utf8);
		gtk_tooltips_set_tip ( tips, bt, text_utf8, GW_REF_CATEGORIES_EDIT_BOX_ADD_UPDATE_BUTTON_TOOLTIPS);
		g_free ( text_utf8);
		gtk_widget_set_sensitive ( GTK_WIDGET ( bt), FALSE);
		GTK_WIDGET_SET_FLAGS ( bt, GTK_CAN_FOCUS);
		GTK_WIDGET_SET_FLAGS ( bt, GTK_CAN_DEFAULT);
		gtk_widget_grab_default ( bt);

		/* Close button */
		bt = gtk_button_new_with_label ( "");
		g_strdup_to_gtk_text ( _( "Close"), text_utf8);
		bt_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( bt)->child), text_utf8);
		g_free ( text_utf8);
		gtk_widget_add_accelerator ( bt, "clicked", accel, bt_key, GDK_MOD1_MASK, 0);
		gtk_signal_connect_object ( GTK_OBJECT ( bt), "clicked", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w));
		gtk_object_set_user_data ( GTK_OBJECT ( bt), w);
		gtk_box_pack_start ( GTK_BOX ( hb), bt, TRUE, TRUE, 5);
		g_strdup_to_gtk_text ( _( "Close the categories properties edit window."), text_utf8);
		gtk_tooltips_set_tip ( tips, bt, text_utf8, GW_REF_CATEGORIES_EDIT_BOX_CLOSE_BUTTON_TOOLTIPS);
		g_free ( text_utf8);
		GTK_WIDGET_SET_FLAGS ( bt, GTK_CAN_FOCUS);

		gtk_window_add_accel_group ( GTK_WINDOW ( w), accel);
	}

	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

		gtk_widget_destroy ( w);
	}

	gw_categories_edit_box_load_categories_list ( GTK_WINDOW ( w));

	return GTK_WINDOW ( w);
}
示例#6
0
GtkWidget *
dnj_koj_frame_blender (struct drqm_jobs_info *info) {
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *hbox,*hbox2;
  GtkWidget *label;
  GtkWidget *entry;
  GtkWidget *button;
  GtkWidget *bbox;
  GtkWidget *rt_menu;
  GtkWidget *rt_omenu;
  GtkWidget *rt_menuitem1;
  const gchar *rt_menuitem1_text;
  GtkWidget *rt_menuitem2;
  const gchar *rt_menuitem2_text;
  GtkTooltips *tooltips;

  tooltips = TooltipsNew ();

  /* Frame */
  frame = gtk_frame_new ("Blender job information");

  /* Main vbox */
  vbox = gtk_vbox_new (FALSE,2);
  gtk_container_add (GTK_CONTAINER(frame),vbox);

  /* Scene file */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Scene file:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  info->dnj.koji_blender.escene = entry;
  gtk_tooltips_set_tip(tooltips,entry,"File name of the blender scene file that should be rendered",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the blender scene file",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_blender_scene_search),&info->dnj.koji_blender);

  /* View command */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("View command:");
  gtk_box_pack_start (GTK_BOX(hbox),label,FALSE,FALSE,2);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Command that will be executed when you select 'Watch image' "
                       "in the frames list (inside the detailed job view)",NULL);
  info->dnj.koji_blender.eviewcmd = entry;
  gtk_entry_set_text(GTK_ENTRY(entry),KOJ_BLENDER_DFLT_VIEWCMD);
  gtk_box_pack_start (GTK_BOX(hbox),entry,TRUE,TRUE,2);

  /* Script directory */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Script directory:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Directory in which, in case of using the automatic "
                       "script generator, the command script will be saved.",NULL);
  info->dnj.koji_blender.escript = entry;
  gtk_entry_set_text (GTK_ENTRY(entry),blendersg_default_script_path());
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the script directory",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_blender_script_search),&info->dnj.koji_blender);

  /* Render type */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Render type:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  
  rt_omenu = gtk_option_menu_new ();
  rt_menu = gtk_menu_new ();
  rt_menuitem1_text = "animation";
  rt_menuitem1 = gtk_menu_item_new_with_label (rt_menuitem1_text);
  gtk_menu_append (GTK_MENU(rt_menu), rt_menuitem1);
  rt_menuitem2_text = "single image";
  rt_menuitem2 = gtk_menu_item_new_with_label (rt_menuitem2_text);
  gtk_menu_append (GTK_MENU(rt_menu), rt_menuitem2);
  gtk_option_menu_set_menu (GTK_OPTION_MENU(rt_omenu), rt_menu);
  
  gtk_tooltips_set_tip(tooltips,rt_omenu,"Choose 'animation' for computing whole frames each task. "
  							"Choose 'single image' for distributed computing of single images.",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),rt_omenu,TRUE,TRUE,0);
  g_signal_connect (G_OBJECT(rt_menuitem1),"activate",
                    GTK_SIGNAL_FUNC (dnj_koj_frame_blender_menuitem_response), &info->dnj.koji_blender);
  g_signal_connect (G_OBJECT(rt_menuitem2),"activate",
                    GTK_SIGNAL_FUNC (dnj_koj_frame_blender_menuitem_response), &info->dnj.koji_blender);
  

  /* Buttons */
  /* Create script */
  bbox = gtk_hbutton_box_new ();
  gtk_box_pack_start (GTK_BOX(vbox),bbox,TRUE,TRUE,5);
  gtk_widget_show (bbox);
  button = gtk_button_new_with_label ("Create Script");
  gtk_tooltips_set_tip(tooltips,button,"Create automagically the script based on the given information",NULL);
  gtk_box_pack_start (GTK_BOX(bbox),button,TRUE,TRUE,2);
  switch (info->dnj.koj) {
  case KOJ_BLENDER:
    g_signal_connect (G_OBJECT(button),"clicked",
                      G_CALLBACK(dnj_koj_frame_blender_bcreate_pressed),&info->dnj);
    break;
  default:
    fprintf (stderr,"What ?!\n");
    break;
  }

  gtk_widget_show_all(frame);

  return frame;
}
示例#7
0
GtkWidget *gui_create_about_trans(void)
{
	GtkWidget *dialog_about_trans;
	GtkWidget *dialog_vbox;
	GtkWidget *vbox;
	GtkWidget *pixmap;
	GtkWidget *scrolledwindow;
	GtkWidget *label;
	GtkWidget *textview;
	GtkWidget *href;
	GtkWidget *dialog_action_area;
	GtkWidget *hbuttonbox;
	GtkWidget *button;
	gchar *about =
	    _("Do you like using Xiphos to study the Bible? "
	      "Would you like to see its user interface in your native language? "
	      "You could translate Xiphos! "
	      "\n\n"
	      "We are always looking for contributions of new "
	      "translations of Xiphos into other languages. "
	      "If you are able to translate for us, please see the link "
	      "below, contact us, and get involved with our efforts. Your help will "
	      "be much appreciated!");

	dialog_about_trans = gtk_dialog_new();
	g_object_set_data(G_OBJECT(dialog_about_trans),
			  "dialog_about_trans", dialog_about_trans);
	gtk_window_set_title(GTK_WINDOW(dialog_about_trans),
			     _("About Xiphos Translation"));
	set_window_icon(GTK_WINDOW(dialog_about_trans));
	gtk_window_set_resizable(GTK_WINDOW(dialog_about_trans), FALSE);

	dialog_vbox =
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans));
	g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_vbox",
			  dialog_vbox);
	gtk_widget_show(dialog_vbox);

	UI_VBOX(vbox, FALSE, 0);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(dialog_vbox), vbox, TRUE, TRUE, 0);

	pixmap = pixmap_finder("logo.png");
	gtk_widget_show(pixmap);
	gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 4);

	scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolledwindow);
	gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 4);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
				       GTK_POLICY_NEVER,
				       GTK_POLICY_AUTOMATIC);
	gtk_widget_set_size_request(scrolledwindow, 400, 150);
	gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow), 4);
	gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)
					    scrolledwindow,
					    settings.shadow_type);

	textview = gtk_text_view_new();
	gtk_widget_show(textview);
	gtk_container_add(GTK_CONTAINER(scrolledwindow), textview);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview),
				    GTK_WRAP_WORD);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
	gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)), about, -1);
	gtk_widget_set_sensitive(textview, FALSE);

	label = gtk_label_new(_("See TRANSLATION-HOWTO in Xiphos source"));
	gtk_widget_show(label);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
	gtk_widget_set_size_request(label, -2, 24);

	href =
	    gtk_link_button_new_with_label("http://xiphos.org/development/", _("Xiphos development"));
	gtk_widget_show(href);
	gtk_box_pack_start(GTK_BOX(vbox), href, FALSE, FALSE, 0);

	dialog_action_area =
#ifdef HAVE_GTK_312
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans));
#else
	    gtk_dialog_get_action_area(GTK_DIALOG(dialog_about_trans));
#endif
	g_object_set_data(G_OBJECT(dialog_about_trans),
			  "dialog_action_area", dialog_action_area);
	gtk_widget_show(dialog_action_area);
	gtk_container_set_border_width(GTK_CONTAINER(dialog_action_area), 10);

#ifdef USE_GTK_3
	hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
	hbuttonbox = gtk_hbutton_box_new();
#endif
	gtk_widget_show(hbuttonbox);
	gtk_box_pack_start(GTK_BOX(dialog_action_area), hbuttonbox,
			   TRUE, TRUE, 0);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox),
				  GTK_BUTTONBOX_END);
	button =
#ifdef HAVE_GTK_310
	    gtk_button_new_with_mnemonic(_("Close"));
#else
	    gtk_button_new_from_stock(GTK_STOCK_CLOSE);
#endif
	gtk_widget_show(button);
	gtk_container_add(GTK_CONTAINER(hbuttonbox), button);
#ifdef HAVE_GTK_218
	gtk_widget_set_can_default(button, TRUE);
#elif defined(USE_GTK_3)
	gtk_widget_set_can_default(button, 1);
#else
	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
#endif
	g_signal_connect(G_OBJECT(button), "clicked",
			 G_CALLBACK(about_trans_ok), NULL);
	return dialog_about_trans;
}
示例#8
0
void bscope_configure (void)
{
	gdouble color[3];
	if(configure_win)
		return;

	bscope_read_config();
	color[0]=((gdouble)(bscope_cfg.color /0x10000))/256;
	color[1]=((gdouble)((bscope_cfg.color %0x10000)/0x100))/256;
	color[2]=((gdouble)(bscope_cfg.color %0x100))/256;
	
	configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10);
	gtk_window_set_title(GTK_WINDOW(configure_win), _("Color Entry"));
	gtk_window_set_policy(GTK_WINDOW(configure_win), FALSE, FALSE, FALSE);
	gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE);
	gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed),
			   &configure_win);

	vbox = gtk_vbox_new(FALSE, 5);

	options_frame = gtk_frame_new(_("Options:"));
	gtk_container_set_border_width(GTK_CONTAINER(options_frame), 5);

	options_vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_set_border_width(GTK_CONTAINER(options_vbox), 5);

	options_colorpicker = gtk_color_selection_new();
	gtk_color_selection_set_color(GTK_COLOR_SELECTION(options_colorpicker), color);
	gtk_signal_connect(GTK_OBJECT(options_colorpicker), "color_changed", GTK_SIGNAL_FUNC(color_changed), NULL);

	gtk_box_pack_start(GTK_BOX(options_vbox), options_colorpicker, FALSE, FALSE, 0);
        gtk_widget_show(options_colorpicker);
	
	
	gtk_container_add(GTK_CONTAINER(options_frame), options_vbox);
	gtk_widget_show(options_vbox);

	gtk_box_pack_start(GTK_BOX(vbox), options_frame, TRUE, TRUE, 0);
	gtk_widget_show(options_frame);

	bbox = gtk_hbutton_box_new();
	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
	gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);

	ok = gtk_button_new_with_label(_("OK"));
	gtk_signal_connect(GTK_OBJECT(ok), "clicked",
			   GTK_SIGNAL_FUNC(configure_ok), NULL);
	GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
	gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
	gtk_widget_show(ok);
	

	cancel = gtk_button_new_with_label(_("Cancel"));
	gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
			   GTK_SIGNAL_FUNC(configure_cancel),
			   GUINT_TO_POINTER(bscope_cfg.color));
	GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
	gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
	gtk_widget_show(cancel);
	gtk_widget_show(bbox);
	
	gtk_container_add(GTK_CONTAINER(configure_win), vbox);
	gtk_widget_show(vbox);
	gtk_widget_show(configure_win);
	gtk_widget_grab_default(ok);
}
示例#9
0
static int dialog_install_user(GtkWindow *main_window, 
                               char *user, int user_len, 
                               unsigned long *user_id)
{
   GtkWidget *button, *label;
   GtkWidget *user_entry, *ID_entry;
   GtkWidget *install_user_dialog;
   GtkWidget *vbox;
   GtkWidget *hbox;
   /* object data */
   struct install_dialog_data data;
   unsigned long id;
   char s_id[32];
   char *whoami;

   data.button_hit=0;

   install_user_dialog = gtk_widget_new(GTK_TYPE_WINDOW,
                                        "type", GTK_WINDOW_TOPLEVEL,
                                        "window_position", GTK_WIN_POS_MOUSE,
                                        "title", _("Install User"),
                                        NULL);
   gtk_window_set_modal(GTK_WINDOW(install_user_dialog), TRUE);
   if (main_window) {
      gtk_window_set_transient_for(GTK_WINDOW(install_user_dialog), GTK_WINDOW(main_window));
   }

   gtk_signal_connect(GTK_OBJECT(install_user_dialog), "destroy",
                      GTK_SIGNAL_FUNC(cb_destroy_dialog), install_user_dialog);

   gtk_object_set_data(GTK_OBJECT(install_user_dialog),
                       "install_dialog_data", &data);

   vbox = gtk_vbox_new(FALSE, 5);

   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);

   gtk_container_add(GTK_CONTAINER(install_user_dialog), vbox);

   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
   label = gtk_label_new(_("A PalmOS(c) device needs a user name and a user ID in order to sync properly."));
   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
   gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);

   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
   label = gtk_label_new(_("If you want to sync more than 1 PalmOS(c) device each one should have a different ID and preferably a different user name."));
   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
   gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);

   srandom(time(NULL));
   /* RAND_MAX is 32768 on Solaris machines for some reason.
    * If someone knows how to fix this, let me know.
    */
   if (RAND_MAX==32768) {
      id = 1+(2000000000.0*random()/(2147483647+1.0));
   } else {
      id = 1+(2000000000.0*random()/(RAND_MAX+1.0));
   }
   g_snprintf(s_id, 30, "%ld", id);

   /* User Name entry */
   
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

   /* Instruction label */
   label = gtk_label_new(_("Most people choose their name or nickname for the user name."));
   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
   gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);

   /* User Name */
   hbox = gtk_hbox_new(FALSE, 5);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
   label = gtk_label_new(_("User Name"));
   user_entry = gtk_entry_new_with_max_length(128);
   entry_set_multiline_truncate(GTK_ENTRY(user_entry), TRUE);
   data.user_entry = user_entry;
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
   gtk_box_pack_start(GTK_BOX(hbox), user_entry, TRUE, TRUE, 2);

   /* Instruction label */
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
   label = gtk_label_new(_("The ID should be a random number."));
   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
   gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);

   /* User ID */
   hbox = gtk_hbox_new(FALSE, 5);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
   label = gtk_label_new(_("User ID"));
   ID_entry = gtk_entry_new_with_max_length(32);
   entry_set_multiline_truncate(GTK_ENTRY(ID_entry), TRUE);
   data.ID_entry = ID_entry;
   gtk_entry_set_text(GTK_ENTRY(ID_entry), s_id);
   whoami = jp_user_or_whoami();
   if (whoami) {
      gtk_entry_set_text(GTK_ENTRY(user_entry), whoami);
      free(whoami);
   }
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
   gtk_box_pack_start(GTK_BOX(hbox), ID_entry, TRUE, TRUE, 2);

   /* Cancel/Install buttons */
   hbox = gtk_hbutton_box_new();
   gtk_button_box_set_layout(GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
   gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 6);
   gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 2);

   button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(cb_install_user_button),
                      GINT_TO_POINTER(DIALOG_SAID_2));
   gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 1);

   button = gtk_button_new_with_label(_("Install User"));
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(cb_install_user_button),
                      GINT_TO_POINTER(DIALOG_SAID_1));
   gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 1);
   GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
   gtk_widget_grab_default(button);
   gtk_widget_grab_focus(button);

   gtk_widget_show_all(install_user_dialog);

   gtk_main();
   
   g_strlcpy(user, data.user, user_len);
   *user_id = data.id;
   
   return data.button_hit;
}
示例#10
0
文件: tasks_items.c 项目: rosedu/osmo
void
tasks_add_edit_dialog_show (gboolean tasks_edit_mode) {

GtkWidget *vbox1;
GtkWidget *vbox2;
GtkWidget *label;
GtkWidget *select_date_button;
GtkWidget *scrolledwindow;
GtkWidget *hseparator;
GtkWidget *hbuttonbox;
GtkWidget *table;
GtkWidget *cancel_button;
gint win_xpos, win_ypos;


	tasks_add_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width (GTK_CONTAINER (tasks_add_window), 6);

    if(tasks_edit_mode == TRUE) {
        gtk_window_set_title (GTK_WINDOW (tasks_add_window), _("Edit task"));
    } else {
        gtk_window_set_title (GTK_WINDOW (tasks_add_window), _("Add task"));
    }

    gtk_window_set_default_size (GTK_WINDOW(tasks_add_window), TASKS_ADD_EDIT_WINDOW_SIZE_X, TASKS_ADD_EDIT_WINDOW_SIZE_Y);
    gtk_window_set_position(GTK_WINDOW(tasks_add_window), GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_window_set_transient_for(GTK_WINDOW(tasks_add_window), GTK_WINDOW(main_window));
	gtk_window_set_modal(GTK_WINDOW(tasks_add_window), TRUE);

    g_signal_connect (G_OBJECT (tasks_add_window), "key_press_event",
					  G_CALLBACK (tasks_add_edit_key_press_cb), NULL);

    g_signal_connect (G_OBJECT (tasks_add_window), "delete_event",
                      G_CALLBACK(tasks_add_edit_window_close_cb), NULL);

    vbox1 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox1);
	gtk_container_add (GTK_CONTAINER (tasks_add_window), vbox1);

	vbox2 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox2);
	gtk_box_pack_start (GTK_BOX (vbox1), vbox2, TRUE, TRUE, 0);

    table = gtk_table_new (4, 4, FALSE);
    gtk_widget_show (table);
    gtk_table_set_row_spacings (GTK_TABLE (table), 6);
    gtk_table_set_col_spacings (GTK_TABLE (table), 4);

	gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 4);

    sprintf(tmpbuf, "<b>%s:</b>", _("Summary"));
	label = gtk_label_new (tmpbuf);
	gtk_widget_show (label);
	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);

    sprintf(tmpbuf, "<b>%s:</b>", _("Due date"));
    label = gtk_label_new (tmpbuf);
	gtk_widget_show (label);
	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);

    summary_entry = gtk_entry_new ();
	gtk_widget_show (summary_entry);

    gtk_table_attach (GTK_TABLE (table), summary_entry, 1, 4, 0, 1,
                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);

	due_date_entry = gtk_entry_new ();
	gtk_widget_show (due_date_entry);
    GTK_WIDGET_UNSET_FLAGS(due_date_entry, GTK_CAN_FOCUS);
	gtk_editable_set_editable (GTK_EDITABLE (due_date_entry), FALSE);

    gtk_table_attach (GTK_TABLE (table), due_date_entry, 1, 2, 1, 2,
                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);

	select_date_button = gtk_button_new_from_stock (OSMO_STOCK_BUTTON_SELECT_DATE);
	gtk_widget_show (select_date_button);
    GTK_WIDGET_UNSET_FLAGS(select_date_button, GTK_CAN_FOCUS);
	g_signal_connect(select_date_button, "clicked", 
                     G_CALLBACK(select_date_cb), NULL);

    gtk_table_attach (GTK_TABLE (table), select_date_button, 2, 4, 1, 2,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);

    sprintf(tmpbuf, "<b>%s:</b>", _("Category"));
    label = gtk_label_new (tmpbuf);
    gtk_widget_show (label);
    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);

    category_combobox = gtk_combo_box_new_text ();
    gtk_widget_show (category_combobox);
    gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (category_combobox), FALSE);

    gtk_table_attach (GTK_TABLE (table), category_combobox, 1, 2, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    create_category_combobox (GTK_COMBO_BOX (category_combobox), tasks_category_store, TRUE);
    gtk_combo_box_set_active(GTK_COMBO_BOX(category_combobox), 
            gui_list_store_get_text_index (tasks_category_store, gtk_combo_box_get_active_text(GTK_COMBO_BOX(cf_combobox))));

    sprintf(tmpbuf, "<b>%s:</b>", _("Priority"));
    label = gtk_label_new (tmpbuf);
    gtk_widget_show (label);
    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

    gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);

    priority_combobox = gtk_combo_box_new_text ();
    gtk_widget_show (priority_combobox);
    gtk_combo_box_append_text (GTK_COMBO_BOX (priority_combobox), _("Low"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (priority_combobox), _("Medium"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (priority_combobox), _("High"));
    gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (priority_combobox), FALSE);

    gtk_table_attach (GTK_TABLE (table), priority_combobox, 3, 4, 2, 3,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);

    gtk_combo_box_set_active (GTK_COMBO_BOX(priority_combobox), 0);

    sprintf(tmpbuf, "<b>%s:</b>", _("Description"));
	label = gtk_label_new (tmpbuf);
	gtk_widget_show (label);
	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);

    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);

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

	desc_textview = gtk_text_view_new ();
    gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (desc_textview), GTK_WRAP_WORD);
    gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(desc_textview), 4);
    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(desc_textview), 4);
    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(desc_textview), 4);
	gtk_widget_show (desc_textview);
	gtk_container_add (GTK_CONTAINER (scrolledwindow), desc_textview);

	hseparator = gtk_hseparator_new ();
	gtk_widget_show (hseparator);
	gtk_box_pack_start (GTK_BOX (vbox1), hseparator, FALSE, TRUE, 4);

	hbuttonbox = gtk_hbutton_box_new ();
	gtk_widget_show (hbuttonbox);
	gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox), 2);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX (hbuttonbox), 16);

    if (config.default_stock_icons) {
	    cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
    } else {
	    cancel_button = gtk_button_new_from_stock (OSMO_STOCK_BUTTON_CANCEL);
    }
	gtk_widget_show (cancel_button);
	gtk_container_add (GTK_CONTAINER (hbuttonbox), cancel_button);
	g_signal_connect(cancel_button, "clicked", 
                     G_CALLBACK(tasks_add_edit_window_close_cb), NULL);

    if (config.default_stock_icons) {
	    tasks_ok_button = gtk_button_new_from_stock (GTK_STOCK_OK);
    } else {
	    tasks_ok_button = gtk_button_new_from_stock (OSMO_STOCK_BUTTON_OK);
    }
	gtk_widget_show (tasks_ok_button);
	gtk_container_add (GTK_CONTAINER (hbuttonbox), tasks_ok_button);
	g_signal_connect(tasks_ok_button, "clicked", 
                     G_CALLBACK(tasks_item_entered_cb), NULL);

    tasks_edit_state = tasks_edit_mode;
    tasks_accept_state = FALSE;
    gtk_entry_set_text (GTK_ENTRY(due_date_entry), _("No date"));

    if (tasks_edit_mode == TRUE) {
        tasks_accept_state = TRUE;
        fill_fields (due_date_entry, summary_entry, desc_textview);
    }

    gtk_widget_set_sensitive(tasks_ok_button, tasks_accept_state);

    gtk_window_get_position (GTK_WINDOW(tasks_add_window), &win_xpos, &win_ypos);
    gtk_window_move (GTK_WINDOW (tasks_add_window), win_xpos-TASKS_ADD_EDIT_WINDOW_SIZE_X/2, win_ypos-10);
    gtk_widget_show(tasks_add_window);
}
示例#11
0
/**
 * dialog_create_action_areav:
 * @dialog: The #GtkDialog you want to create the action_area for.
 * @args: A @va_list as obtained with va_start() describing the action_area
 *        buttons.
 *
 */
static void
dialog_create_action_areav (GtkDialog *dialog,
			    va_list    args)
{
  GtkWidget *hbbox = NULL;
  GtkWidget *button;

  /*  action area variables  */
  const gchar    *label;
  GtkSignalFunc   callback;
  gpointer        data;
  GObject        *slot_object;
  GtkWidget     **widget_ptr;
  gboolean        default_action;
  gboolean        connect_delete;

  gboolean delete_connected = FALSE;

  g_return_if_fail (dialog != NULL);
  g_return_if_fail (GTK_IS_DIALOG (dialog));

  /*  prepare the action_area  */
  label = va_arg (args, const gchar *);

  if (label)
    {
      gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 2);
      gtk_box_set_homogeneous (GTK_BOX (dialog->action_area), FALSE);

      hbbox = gtk_hbutton_box_new ();
      gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
      gtk_box_pack_end (GTK_BOX (dialog->action_area), hbbox, FALSE, FALSE, 0);
      gtk_widget_show (hbbox);
    }

  /*  the action_area buttons  */
  while (label)
    {
      callback       = va_arg (args, GtkSignalFunc);
      data           = va_arg (args, gpointer);
      slot_object    = va_arg (args, GObject *);
      widget_ptr     = va_arg (args, GtkWidget **);
      default_action = va_arg (args, gboolean);
      connect_delete = va_arg (args, gboolean);

      button = gtk_button_new_with_label (label);
      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
      gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);

      if (slot_object == (GObject *) 1)
	slot_object = G_OBJECT (dialog);

      if (data == NULL)
	data = dialog;

      if (callback)
	{
	  if (slot_object)
	    g_signal_connect_object (G_OBJECT (button), "clicked",
				     G_CALLBACK (callback),
				     slot_object, G_CONNECT_SWAPPED);
	  else
	    g_signal_connect (G_OBJECT (button), "clicked",
			      G_CALLBACK (callback),
			      data);
	}

      if (widget_ptr)
	*widget_ptr = button;

      if (connect_delete && callback && !delete_connected)
	{
	  gtk_object_set_data (G_OBJECT (dialog),
			       "dialog_cancel_callback",
			       (gpointer) callback);
	  gtk_object_set_data (G_OBJECT (dialog),
			       "dialog_cancel_widget",
			       slot_object ? slot_object : G_OBJECT (button));

	  /*  catch the WM delete event  */
	  g_signal_connect (G_OBJECT (dialog), "delete_event",
			    G_CALLBACK (dialog_delete_callback),
			    data);

	  delete_connected = TRUE;
	}

      if (default_action)
	gtk_widget_grab_default (button);
      gtk_widget_show (button);

      label = va_arg (args, gchar *);
    }
}
int
main (int argc, char **argv)
{
  GtkWidget       *window;
  GtkWidget       *vbox;
  GtkWidget       *menubar;
  IgeMacMenuGroup *group;
  IgeMacDock      *dock;
  GtkWidget       *bbox;
  GtkWidget       *button;

  gtk_init (&argc, &argv);

  dock = ige_mac_dock_get_default ();

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

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

  menubar = test_setup_menu ();
  gtk_box_pack_start (GTK_BOX (vbox), 
                      menubar,
                      FALSE, TRUE, 0);
  
  gtk_box_pack_start (GTK_BOX (vbox), 
                      gtk_label_new ("Some window content here"), 
                      FALSE, FALSE, 12);

  bbox = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_CENTER);
  gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), 12);

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

  button = gtk_button_new_with_label ("Bounce");
  g_signal_connect (button, "clicked", G_CALLBACK (bounce_cb), dock);
  gtk_box_pack_start (GTK_BOX (bbox), 
                      button,
                      FALSE, FALSE, 0);

  button = gtk_button_new_with_label ("Change Icon");
  g_signal_connect (button, "clicked", G_CALLBACK (change_icon_cb), dock);
  gtk_box_pack_start (GTK_BOX (bbox), 
                      button,
                      FALSE, FALSE, 0);

  button = gtk_button_new_with_label ("Change Menu");
  g_signal_connect (button, "clicked", G_CALLBACK (change_menu_cb), NULL);
  gtk_box_pack_start (GTK_BOX (bbox),
                      button,
                      FALSE, FALSE, 0);

  gtk_widget_show_all (window);

  gtk_widget_hide (menubar);

  ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (menubar));
  ige_mac_menu_set_quit_menu_item (GTK_MENU_ITEM (quit_item));

  group = ige_mac_menu_add_app_menu_group ();
  ige_mac_menu_add_app_menu_item  (group,
                                   GTK_MENU_ITEM (about_item), 
                                   NULL);

  group = ige_mac_menu_add_app_menu_group ();
  ige_mac_menu_add_app_menu_item  (group,
                                   GTK_MENU_ITEM (preferences_item), 
                                   NULL);
  
  dock = ige_mac_dock_new ();
  g_signal_connect (dock,
                    "clicked",
                    G_CALLBACK (dock_clicked_cb),
                    window);
  g_signal_connect (dock,
                    "quit-activate",
                    G_CALLBACK (gtk_main_quit),
                    window);

  gtk_main ();

  return 0;
}
示例#13
0
void
gevo_add_buddy_dialog_show(PurpleAccount *account, const char *username,
						   const char *group, const char *alias)
{
	GevoAddBuddyDialog *dialog;
	GtkWidget *button;
	GtkWidget *sw;
	GtkWidget *label;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *bbox;
	GtkWidget *sep;
	GtkTreeSelection *selection;
	GtkCellRenderer *cell;

	dialog = g_new0(GevoAddBuddyDialog, 1);

	dialog->account =
		(account != NULL
		 ? account
		 : purple_connection_get_account(purple_connections_get_all()->data));

	if (username != NULL)
		dialog->username = g_strdup(username);

	dialog->win = pidgin_create_window(_("Add Buddy"), PIDGIN_HIG_BORDER, "add_buddy", TRUE);
	gtk_widget_set_size_request(dialog->win, -1, 400);

	g_signal_connect(G_OBJECT(dialog->win), "delete_event",
					 G_CALLBACK(delete_win_cb), dialog);

	/* Setup the vbox */
	vbox = gtk_vbox_new(FALSE, 12);
	gtk_container_add(GTK_CONTAINER(dialog->win), vbox);
	gtk_widget_show(vbox);

	/* Add the label. */
	label = gtk_label_new(_("Select a person from your address book below, "
							"or add a new person."));
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
	gtk_widget_show(label);

	/* Add the search hbox */
	hbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	gtk_widget_show(hbox);

	/* "Search" */
	label = gtk_label_new(_("Search"));
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_widget_show(label);

	/* Addressbooks */
	dialog->addrbooks = gevo_addrbooks_model_new();

	dialog->addrbooks_combo = gtk_combo_box_new_with_model(
			dialog->addrbooks);
	cell = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
							   cell, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
								   cell,
								   "text", ADDRBOOK_COLUMN_NAME,
								   NULL);
	gtk_box_pack_start(GTK_BOX(hbox), dialog->addrbooks_combo, FALSE,
					   FALSE, 0);
	gtk_widget_show(dialog->addrbooks_combo);

	/* Search field */
	dialog->search_field = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox), dialog->search_field, TRUE, TRUE, 0);
	gtk_widget_show(dialog->search_field);

	g_signal_connect(G_OBJECT(dialog->search_field), "changed",
					 G_CALLBACK(search_changed_cb), dialog);

	/* Clear button */
	button = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(clear_cb), dialog);

	/* Scrolled Window */
	sw = gtk_scrolled_window_new(0, 0);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
								   GTK_POLICY_AUTOMATIC,
								   GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
										GTK_SHADOW_IN);
	gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
	gtk_widget_show(sw);

	/* Create the list model for the treeview. */
	dialog->model = gtk_list_store_new(NUM_COLUMNS,
									   G_TYPE_STRING, GDK_TYPE_PIXBUF,
									   G_TYPE_STRING, G_TYPE_POINTER);

	/* Now for the treeview */
	dialog->treeview =
		gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
	gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
	gtk_widget_show(dialog->treeview);

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));

	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

	g_signal_connect(G_OBJECT(selection), "changed",
					 G_CALLBACK(selected_cb), dialog);

	add_columns(dialog);

	/*
	 * Catch addressbook selection and populate treeview with the first
	 * addressbook
	 */
	gevo_addrbooks_model_populate(dialog->addrbooks);
	g_signal_connect(G_OBJECT(dialog->addrbooks_combo), "changed",
							  G_CALLBACK(addrbook_change_cb), dialog);
	gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->addrbooks_combo), 0);

	/* Group box */
	dialog->group_combo =
		pidgin_text_combo_box_entry_new(group, gevo_get_groups());
	pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Group:"), NULL,
							  dialog->group_combo, TRUE, NULL);
	gtk_widget_show_all(dialog->group_combo);

	/* Cool. Now we only have a little left... */

	/* Separator. */
	sep = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
	gtk_widget_show(sep);

	/* Button box */
	bbox = gtk_hbutton_box_new();
	gtk_box_set_spacing(GTK_BOX(bbox), 6);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
	gtk_widget_show(bbox);

	/* "New Person" button */
	button = pidgin_pixbuf_button_from_stock(_("New Person"), GTK_STOCK_NEW,
										   PIDGIN_BUTTON_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(new_person_cb), dialog);

	/* "Cancel" button */
	button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(cancel_cb), dialog);

	/* "Select Buddy" button */
	button = pidgin_pixbuf_button_from_stock(_("Select Buddy"), GTK_STOCK_APPLY,
										   PIDGIN_BUTTON_HORIZONTAL);
	dialog->select_button = button;
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_set_sensitive(button, FALSE);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(select_buddy_cb), dialog);

	/* Show it. */
	gtk_widget_show(dialog->win);
}
示例#14
0
GtkWidget *
dnj_koj_frame_lightwave (struct drqm_jobs_info *info) {
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *hbox,*hbox2;
  GtkWidget *label;
  GtkWidget *entry;
  GtkWidget *button;
  GtkWidget *bbox;
  GtkTooltips *tooltips;
  struct passwd *pw;

  tooltips = TooltipsNew ();

  /* Frame */
  frame = gtk_frame_new ("Lightwave job information");

  /* Main vbox */
  vbox = gtk_vbox_new (FALSE,2);
  gtk_container_add (GTK_CONTAINER(frame),vbox);

  /* Scene file */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Scene file:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  info->dnj.koji_lightwave.escene = entry;
  gtk_tooltips_set_tip(tooltips,entry,"File name of the lightwave scene file that should be rendered",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the lightwave scene file",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_lightwave_scene_search),&info->dnj.koji_lightwave);

  /* Project directory */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Project directory:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Directory where the project is stored",NULL);
  info->dnj.koji_lightwave.eprojectdir = entry;
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the lightwave project directory",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_lightwave_projectdir_search),&info->dnj.koji_lightwave);

  /* Config directory */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Config directory:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Directory where the configuration is stored",NULL);
  info->dnj.koji_lightwave.econfigdir = entry;
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the lightwave config directory",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_lightwave_configdir_search),&info->dnj.koji_lightwave);

  /* File Owner */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Owner of rendered files:");
  gtk_box_pack_start (GTK_BOX(hbox),label,FALSE,FALSE,2);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"After rendering the ownership of the "
                       "rendered files will be changed to this. By default it "
                       "is the same as the owner of the job",NULL);
  info->dnj.koji_lightwave.efile_owner = entry;
  if (!(pw = getpwuid(geteuid()))) {
    gtk_entry_set_text(GTK_ENTRY(entry),"ERROR");
  } else {
    gtk_entry_set_text(GTK_ENTRY(entry),pw->pw_name);
  }
  gtk_box_pack_start (GTK_BOX(hbox),entry,TRUE,TRUE,2);


  /* View command */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("View command:");
  gtk_box_pack_start (GTK_BOX(hbox),label,FALSE,FALSE,2);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Command that will be executed when you select 'Watch image' "
                       "in the frames list (inside the detailed job view)",NULL);
  info->dnj.koji_lightwave.eviewcmd = entry;
  gtk_entry_set_text(GTK_ENTRY(entry),KOJ_LIGHTWAVE_DFLT_VIEWCMD);
  gtk_box_pack_start (GTK_BOX(hbox),entry,TRUE,TRUE,2);

  /* Script directory */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Script directory:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Directory in which, in case of using the automatic "
                       "script generator, the command script will be saved.",NULL);
  info->dnj.koji_lightwave.escript = entry;
  gtk_entry_set_text (GTK_ENTRY(entry),lightwavesg_default_script_path());
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the script directory",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_lightwave_script_search),&info->dnj.koji_lightwave);

  /* Buttons */
  /* Create script */
  bbox = gtk_hbutton_box_new ();
  gtk_box_pack_start (GTK_BOX(vbox),bbox,TRUE,TRUE,5);
  gtk_widget_show (bbox);
  button = gtk_button_new_with_label ("Create Script");
  gtk_tooltips_set_tip(tooltips,button,"Create automagically the script based on the given information",NULL);
  gtk_box_pack_start (GTK_BOX(bbox),button,TRUE,TRUE,2);
  switch (info->dnj.koj) {
  case KOJ_LIGHTWAVE:
    g_signal_connect (G_OBJECT(button),"clicked",
                      G_CALLBACK(dnj_koj_frame_lightwave_bcreate_pressed),&info->dnj);
    break;
  default:
    fprintf (stderr,"What ?!\n");
    break;
  }

  gtk_widget_show_all(frame);

  return frame;
}
示例#15
0
void
ghid_netlist_window_create (GHidPort * out)
{
  GtkWidget *vbox, *hbox, *button, *label, *sep;
  GtkTreeView *treeview;
  GtkTreeModel *model;
  GtkTreeSelection *selection;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  /* No point in putting up the window if no netlist is loaded.
   */
  if (!PCB->NetlistLib.MenuN)
    return;

  if (netlist_window)
    return;

  netlist_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (netlist_window), "destroy",
		    G_CALLBACK (netlist_destroy_cb), out);
  gtk_window_set_title (GTK_WINDOW (netlist_window), _("PCB Netlist"));
  gtk_window_set_wmclass (GTK_WINDOW (netlist_window), "PCB_Netlist", "PCB");
  g_signal_connect (G_OBJECT (netlist_window), "configure_event",
		    G_CALLBACK (netlist_window_configure_event_cb), NULL);
  gtk_window_set_default_size (GTK_WINDOW (netlist_window),
			       -1, ghidgui->netlist_window_height);

  gtk_container_set_border_width (GTK_CONTAINER (netlist_window), 2);

  vbox = gtk_vbox_new (FALSE, 4);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
  gtk_container_add (GTK_CONTAINER (netlist_window), vbox);
  hbox = gtk_hbox_new (FALSE, 8);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 4);


  model = net_model_create ();
  treeview = GTK_TREE_VIEW (gtk_tree_view_new_with_model (model));
  net_model = model;
  net_treeview = treeview;
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (net_model),
					NET_NAME_COLUMN, GTK_SORT_ASCENDING);

  gtk_tree_view_set_rules_hint (treeview, FALSE);
  g_object_set (treeview, "enable-tree-lines", TRUE, NULL);

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (treeview, -1, _(" "),
					       renderer,
					       "text", NET_ENABLED_COLUMN,
					       NULL);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes (_("Net Name"),
						     renderer,
						     "text", NET_NAME_COLUMN, NULL);
  gtk_tree_view_insert_column (treeview, column, -1);
  gtk_tree_view_set_expander_column (treeview, column);

  /* TODO: dont expand all, but record expanded states when window is
     |  destroyed and restore state here.
   */
  gtk_tree_view_expand_all (treeview);

  selection = ghid_scrolled_selection (treeview, hbox,
				       GTK_SELECTION_SINGLE,
				       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC,
				       net_selection_changed_cb, NULL);

  /* Connect to the double click event.
   */
  g_signal_connect (G_OBJECT (treeview), "row-activated",
		    G_CALLBACK (net_selection_double_click_cb), NULL);



  /* Create the elements treeview and wait for a callback to populate it.
   */
  treeview = GTK_TREE_VIEW (gtk_tree_view_new ());
  node_treeview = treeview;

  gtk_tree_view_set_rules_hint (treeview, FALSE);

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (treeview, -1, _("Nodes"),
					       renderer,
					       "text", NODE_NAME_COLUMN,
					       NULL);

  selection = ghid_scrolled_selection (treeview, hbox,
				       GTK_SELECTION_SINGLE,
				       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC,
				       node_selection_changed_cb, NULL);
  node_selection = selection;

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  label = gtk_label_new (_("Operations on selected 'Net Name':"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

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

  button = gtk_button_new_with_label (_("Select"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_select_cb), GINT_TO_POINTER (1));

  button = gtk_button_new_with_label (_("Unselect"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_select_cb), GINT_TO_POINTER (0));

  button = gtk_button_new_with_label (_("Find"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_find_cb), GINT_TO_POINTER (0));

  button = gtk_button_new_with_label (_("Rip Up"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_rip_up_cb), GINT_TO_POINTER (0));
  
  ghid_check_button_connected (vbox, &disable_all_button, FALSE, TRUE, FALSE,
			       FALSE, 0, netlist_disable_all_cb, NULL,
			       _("Disable all nets for adding rats"));

  sep = gtk_hseparator_new ();
  gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 3);

  hbox = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
  button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (netlist_close_cb), NULL);
  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);


  gtk_widget_realize (netlist_window);
  if (Settings.AutoPlace)
    gtk_widget_set_uposition (GTK_WIDGET (netlist_window), 10, 10);

}
示例#16
0
static void create_dialog(void)
{
        GtkWidget *vbox, *hbox, *vbox2, *notebook, *w;

        if (options_dialog)
                return;
        vbox = gtk_vbox_new(FALSE, 0);

        /* Buttons box */
        hbox = gtk_hbutton_box_new();
        gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);

#if GTK_CHECK_VERSION(2, 14, 0)
        /* Help button */
        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
        w = gtk_button_new_from_stock(GTK_STOCK_HELP);
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        g_signal_connect(G_OBJECT(w), "clicked",
                         G_CALLBACK(help_clicked), NULL);
        gtk_tooltips_set_tip(tooltips, w, "Launch program website", NULL);
#endif

        /* Close button */
        w = gtk_button_new_with_label("Close");
        gtk_button_set_image(GTK_BUTTON(w),
                             gtk_image_new_from_stock(GTK_STOCK_CLOSE,
                                                      GTK_ICON_SIZE_BUTTON));
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        g_signal_connect(G_OBJECT(w), "clicked",
                         G_CALLBACK(close_dialog), NULL);

        gtk_box_pack_end(GTK_BOX(vbox), spacer_new(-1, 8), FALSE, TRUE, 0);

        /* Create notebook */
        notebook = gtk_notebook_new();
        gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);

        /* View page */
        vbox2 = gtk_vbox_new(FALSE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), 8);
        w = gtk_label_new("Interface");
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, w);

        /* View -> Dimensions */
        w = label_new_markup("<b>Dimensions</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* View -> Dimensions -> Cell size */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = label_new_markup("Cells: ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        cell_width_spin = spin_button_new_int(CELL_WIDTH_MIN, cell_height,
                                              &cell_width, TRUE);
        g_signal_connect(G_OBJECT(cell_width_spin), "value-changed",
                         G_CALLBACK(cell_width_value_changed), NULL);
        gtk_box_pack_start(GTK_BOX(hbox), cell_width_spin, FALSE, FALSE, 0);
        w = label_new_markup(" by ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        cell_height_spin = spin_button_new_int(cell_width, CELL_HEIGHT_MAX,
                                               &cell_height, TRUE);
        cell_width_value_changed();
        g_signal_connect(G_OBJECT(cell_height_spin), "value-changed",
                         G_CALLBACK(cell_height_value_changed), NULL);
        gtk_box_pack_start(GTK_BOX(hbox), cell_height_spin, FALSE, FALSE, 0);
        w = label_new_markup(" pixels");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* View -> Dimensions -> Grid */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = label_new_markup("Grid: ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = spin_button_new_int(6, 48, &cell_cols_pref, TRUE);
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = label_new_markup(" by ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = spin_button_new_int(1, 8, &cell_rows_pref, TRUE);
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = label_new_markup(" cells");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* View -> Dimensions -> Keyboard size */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = label_new_markup("Keyboard: ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = spin_button_new_int(KEYBOARD_SIZE_MIN, 1400, &keyboard_size, TRUE);
        gtk_spin_button_set_increments(GTK_SPIN_BUTTON(w), 16, 4);
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = label_new_markup(" pixels wide");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* View -> Window */
        gtk_box_pack_start(GTK_BOX(vbox2), spacer_new(-1, 8), FALSE, FALSE, 0);
        w = label_new_markup("<b>Window</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* View -> Window -> Button labels */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Show button labels", &window_button_labels, TRUE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* View -> Window -> On-screen keyboard */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Show on-screen keyboard",
                             &keyboard_enabled, TRUE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* View -> Window -> Enable */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Enable extended input events",
                             &xinput_enabled, FALSE);
        g_signal_connect(G_OBJECT(w), "toggled",
                         G_CALLBACK(xinput_enabled_toggled), NULL);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "If you cannot write in the cells or the ink "
                             "does not appear where it should, you can try "
                             "disabling extended input events. Note that this "
                             "will disable the pen eraser.", NULL);

        /* View -> Window -> Docking */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = label_new_markup("Window docking: ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = gtk_combo_box_new_text();
        gtk_combo_box_append_text(GTK_COMBO_BOX(w), "Disabled");
        gtk_combo_box_append_text(GTK_COMBO_BOX(w), "Top");
        gtk_combo_box_append_text(GTK_COMBO_BOX(w), "Bottom");
        gtk_combo_box_set_active(GTK_COMBO_BOX(w), window_docked);
        g_signal_connect(G_OBJECT(w), "changed",
                         G_CALLBACK(window_docking_changed), NULL);
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* View -> Status icon */
        gtk_box_pack_start(GTK_BOX(vbox2), spacer_new(-1, 8), FALSE, FALSE, 0);
        w = label_new_markup("<b>Status icon</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* View -> Status icon -> Enable */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Open menu on left click",
                             &status_menu_left_click, FALSE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* Colors page */
        vbox2 = gtk_vbox_new(FALSE, 0);
        w = gtk_label_new("Colors");
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, w);
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), 8);

        /* Colors -> Use style */
        w = check_button_new("Use default theme colors", &style_colors, FALSE);
        g_signal_connect(G_OBJECT(w), "toggled",
                         G_CALLBACK(style_colors_changed), NULL);
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* Colors -> Custom colors */
        gtk_box_pack_start(GTK_BOX(vbox2), spacer_new(-1, 8), FALSE, FALSE, 0);
        color_table = create_color_table();
        gtk_box_pack_start(GTK_BOX(vbox2), color_table, FALSE, FALSE, 0);
        style_colors_changed();

        /* Unicode page */
        vbox2 = gtk_vbox_new(FALSE, 0);
        w = gtk_label_new("Languages");
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, w);
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), 8);

        /* Unicode -> Displayed blocks */
        w = label_new_markup("<b>Enabled Unicode blocks</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(-1, 4), FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);

        /* Unicode -> Blocks list */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = create_blocks_list();
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);

        /* Recognition -> Duplicate glyphs */
        gtk_box_pack_start(GTK_BOX(vbox2), spacer_new(-1, 8), FALSE, FALSE, 0);
        w = label_new_markup("<b>Language options</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* Unicode -> Disable Latin letters */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Disable Basic Latin letters",
                             &no_latin_alpha, TRUE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "If you have trained both the Basic Latin block "
                             "and a block with characters similar to Latin "
                             "letters (for instance, Cyrillic) you can disable "
                             "the Basic Latin letters in order to use only "
                             "numbers and symbols from Basic Latin.", NULL);

        /* Unicode -> Right-to-left */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Enable right-to-left mode",
                             &right_to_left, TRUE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             PACKAGE_NAME " will expect you to write from "
                             "the rightmost cell to the left and will pad "
                             "cells and create new lines accordingly.", NULL);

        /* Recognition page */
        vbox2 = gtk_vbox_new(FALSE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), 8);
        w = gtk_label_new("Recognition");
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, w);

        /* Recognition -> Samples */
        w = label_new_markup("<b>Training samples</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* Recognition -> Samples -> Train on input */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Train on input when entering",
                             &train_on_input, FALSE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "When enabled, input characters will be used as "
                             "training samples when 'Enter' is pressed. This "
                             "is a good way to quickly build up many samples, "
                             "but can generate poor samples if your writing "
                             "gets sloppy.", NULL);

        /* Recognition -> Samples -> Maximum */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = label_new_markup("Samples per character: ");
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        w = spin_button_new_int(2, SAMPLES_MAX, &samples_max, FALSE);
        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "The maximum number of training samples kept per "
                             "character. Lower this value if recognition is "
                             "too slow or the program uses too much memory.",
                             NULL);

        /* Recognition -> Word context */
        gtk_box_pack_start(GTK_BOX(vbox2), spacer_new(-1, 8), FALSE, FALSE, 0);
        w = label_new_markup("<b>Word context</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* Recognition -> Word context -> English */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Enable English word context",
                             &wordfreq_enable, FALSE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "Use a dictionary of the most frequent English "
                             "words to assist recognition. Also aids in "
                             "consistent recognition of numbers and "
                             "capitalization.", NULL);

        /* Recognition -> Preprocessor */
        gtk_box_pack_start(GTK_BOX(vbox2), spacer_new(-1, 8), FALSE, FALSE, 0);
        w = label_new_markup("<b>Preprocessor</b>");
        gtk_box_pack_start(GTK_BOX(vbox2), w, FALSE, FALSE, 0);

        /* Recognition -> Preprocessor -> Ignore stroke direction */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Ignore stroke direction",
                             &ignore_stroke_dir, FALSE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "Match input strokes with training sample strokes "
                             "that were drawn in the opposite direction. "
                             "Disabling this can boost recognition speed.",
                             NULL);

        /* Recognition -> Preprocessor -> Ignore stroke number */
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1), FALSE, FALSE, 0);
        w = check_button_new("Match differing stroke numbers",
                             &ignore_stroke_num, FALSE);
        gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, w,
                             "Match inputs to training samples that do not "
                             "have the same number of strokes. Disabling this "
                             "can boost recognition speed.", NULL);

        /* Create dialog window */
        options_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        g_signal_connect(G_OBJECT(options_dialog), "delete_event",
                         G_CALLBACK(gtk_widget_hide_on_delete), NULL);
        gtk_window_set_destroy_with_parent(GTK_WINDOW(options_dialog), TRUE);
        gtk_window_set_resizable(GTK_WINDOW(options_dialog), TRUE);
        gtk_window_set_title(GTK_WINDOW(options_dialog), "CellWriter Setup");
        gtk_container_set_border_width(GTK_CONTAINER(options_dialog), 8);
        gtk_container_add(GTK_CONTAINER(options_dialog), vbox);
        if (!window_embedded)
                gtk_window_set_transient_for(GTK_WINDOW(options_dialog),
                                             GTK_WINDOW(window));
}
示例#17
0
文件: loginpanel.c 项目: jayivy/gtkqq
static void qq_loginpanel_init(QQLoginPanel *obj)
{
    login_users = gqq_config_get_all_login_user(cfg);
    //Put the last login user at the first of the array
    gint i;
    GQQLoginUser *usr, *tmp;
    for(i = 0; i < login_users -> len; ++i){
        usr = (GQQLoginUser*)g_ptr_array_index(login_users, i);
        if(usr == NULL){
            continue;
        }
        if(usr -> last == 1){
            break;
        }
    }
    if(i < login_users -> len){
        tmp = login_users -> pdata[0];
        login_users -> pdata[0] = login_users -> pdata[i];
        login_users -> pdata[i] = tmp;
    }

    obj -> uin_label = gtk_label_new("QQ Number:");
    obj -> uin_entry = gtk_combo_box_entry_new_text();

    for(i = 0; i < login_users -> len; ++i){
        usr = (GQQLoginUser*)g_ptr_array_index(login_users, i);
        gtk_combo_box_append_text(GTK_COMBO_BOX(obj -> uin_entry)
                                  , usr -> qqnumber);
    }
    gtk_combo_box_set_active(GTK_COMBO_BOX(obj -> uin_entry), 0);

    obj -> passwd_label = gtk_label_new("Password:"******"changed"
                     , G_CALLBACK(qqnumber_combox_changed), obj);
    //not visibily 
    gtk_entry_set_visibility(GTK_ENTRY(obj -> passwd_entry), FALSE);
    gtk_widget_set_size_request(obj -> uin_entry, 200, -1);
    gtk_widget_set_size_request(obj -> passwd_entry, 220, -1);
    
    GtkWidget *vbox = gtk_vbox_new(FALSE, 10);

    //uin label and entry
    GtkWidget *uin_hbox = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(uin_hbox), obj -> uin_label, FALSE, FALSE, 0);
    GtkWidget *uin_vbox = gtk_vbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(uin_vbox), uin_hbox, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(uin_vbox), obj -> uin_entry, FALSE, FALSE, 0);

    //password label and entry
    GtkWidget *passwd_hbox = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(passwd_hbox), obj -> passwd_label
                       , FALSE, FALSE, 0);
    GtkWidget *passwd_vbox = gtk_vbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(passwd_vbox), passwd_hbox, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(passwd_vbox), obj -> passwd_entry, FALSE, FALSE, 0);
    
    //put uin and password in a vbox
    gtk_box_pack_start(GTK_BOX(vbox), uin_vbox, FALSE, FALSE, 2);
    gtk_box_pack_start(GTK_BOX(vbox), passwd_vbox, FALSE, FALSE, 2);

    //rember password check box
    obj -> rempwcb = gtk_check_button_new_with_label("Remeber Password");
	if(login_users -> len > 0){
        usr = (GQQLoginUser*)g_ptr_array_index(login_users, 0);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(obj -> rempwcb), usr->rempw);
    }
    /* g_signal_connect(G_OBJECT(obj -> rempwcb), "toggled" */
    /*                     , G_CALLBACK(qqnumber_combox_changed), obj); */
    GtkWidget *hbox4 = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox4), obj -> rempwcb, TRUE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox4, FALSE, TRUE, 2);

    //login button
    obj -> login_btn = gtk_button_new_with_label("Login");
    gtk_widget_set_size_request(obj -> login_btn, 90, -1);
    g_signal_connect(G_OBJECT(obj -> login_btn), "clicked"
                     , G_CALLBACK(login_btn_cb), (gpointer)obj);
    //status combo box
    obj -> status_comb = qq_statusbutton_new();
    if(login_users -> len > 0){
        usr = (GQQLoginUser*)g_ptr_array_index(login_users, 0);
        qq_statusbutton_set_status_string(obj -> status_comb, usr -> status);
    }
#ifdef USE_PROXY
    //proxy setting
    obj -> set_proxy_btn = gtk_button_new_with_label("Network");
    gtk_widget_set_size_request(obj -> set_proxy_btn, 100, -1);
    g_signal_connect(G_OBJECT(obj -> set_proxy_btn), "clicked"
                     , G_CALLBACK(set_proxy_btn_cb), (gpointer)obj);
#endif	/* USE_PROXY */
    
    GtkWidget *hbox1 = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox1), vbox, TRUE, FALSE, 0);

    GtkWidget *hbox2 = gtk_hbox_new(FALSE, 0);
    GtkWidget *hbox3 = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox2), obj -> status_comb, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox2), obj -> login_btn, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox3), hbox2, TRUE, FALSE, 0);

#ifdef USE_PROXY
    GtkWidget *hbox_proxy_setting = gtk_hbutton_box_new();
    gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox_proxy_setting), GTK_BUTTONBOX_CENTER);
    gtk_box_pack_start(GTK_BOX(hbox_proxy_setting), obj -> set_proxy_btn, FALSE, FALSE, 0);
#endif	/* USE_PROXY */
	
    //error informatin label
    obj -> err_label = gtk_label_new("");
    GdkColor color;
    GdkColormap *cmap = gdk_colormap_get_system();
    gdk_colormap_alloc_color(cmap, &color, TRUE, TRUE);
    gdk_color_parse("#fff000000", &color);    //red
    //change text color to red
    //MUST modify fb, not text
    gtk_widget_modify_fg(obj -> err_label, GTK_STATE_NORMAL, &color);
    hbox2 = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox2), obj -> err_label, TRUE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, FALSE, 0);

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

#ifdef USE_PROXY
    gtk_box_pack_start(GTK_BOX(vbox), hbox_proxy_setting, TRUE, TRUE, 10);
#endif	/* USE_PROXY */
    
    gtk_box_set_homogeneous(GTK_BOX(obj), FALSE);
    GtkWidget *logo = gtk_image_new_from_file(IMGDIR"webqq_icon.png");
    gtk_widget_set_size_request(logo, -1, 150);    
    gtk_box_pack_start(GTK_BOX(obj), logo, FALSE, FALSE, 5);
    gtk_box_pack_start(GTK_BOX(obj), hbox1, FALSE, FALSE, 15);
}
示例#18
0
GtkWidget*
create_TextPlotDialog (void)
{
  GtkWidget *TextPlotDialog;
  GtkWidget *dialog_vbox1;
  GtkWidget *table1;
  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *label3;
  GtkWidget *label4;
  GtkObject *size_sb_adj;
  GtkWidget *size_sb;
  GtkObject *spacing_sb_adj;
  GtkWidget *spacing_sb;
  GtkObject *fontx_sb_adj;
  GtkWidget *fontx_sb;
  GtkObject *fonty_sb_adj;
  GtkWidget *fonty_sb;
  GtkWidget *Color;
  GtkWidget *label5;
  GtkWidget *textplot_variables;
  GtkWidget *textplot_variables_menu;
  GtkWidget *dialog_action_area1;
  GtkWidget *hbuttonbox1;
  GtkWidget *tpclose;

  TextPlotDialog = gtk_dialog_new ();
  gtk_widget_set_name (TextPlotDialog, "TextPlotDialog");
  gtk_object_set_data (GTK_OBJECT (TextPlotDialog), "TextPlotDialog", TextPlotDialog);
  gtk_window_set_title (GTK_WINDOW (TextPlotDialog), _("Text Plot Dialog"));
  GTK_WINDOW (TextPlotDialog)->type = GTK_WINDOW_DIALOG;
  gtk_window_set_policy (GTK_WINDOW (TextPlotDialog), TRUE, TRUE, FALSE);

  dialog_vbox1 = GTK_DIALOG (TextPlotDialog)->vbox;
  gtk_widget_set_name (dialog_vbox1, "dialog_vbox1");
  gtk_object_set_data (GTK_OBJECT (TextPlotDialog), "dialog_vbox1", dialog_vbox1);
  gtk_widget_show (dialog_vbox1);

  table1 = gtk_table_new (6, 2, FALSE);
  gtk_widget_set_name (table1, "table1");
  gtk_widget_ref (table1);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "table1", table1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (table1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0);
  gtk_table_set_row_spacings (GTK_TABLE (table1), 3);

  label1 = gtk_label_new (_("Size:"));
  gtk_widget_set_name (label1, "label1");
  gtk_widget_ref (label1);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "label1", label1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label1);
  gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label1), 5, 0);

  label2 = gtk_label_new (_("Spacing:"));
  gtk_widget_set_name (label2, "label2");
  gtk_widget_ref (label2);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "label2", label2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label2);
  gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label2), 5, 0);

  label3 = gtk_label_new (_("Font Width:"));
  gtk_widget_set_name (label3, "label3");
  gtk_widget_ref (label3);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "label3", label3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label3);
  gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label3), 5, 0);

  label4 = gtk_label_new (_("Font Height:"));
  gtk_widget_set_name (label4, "label4");
  gtk_widget_ref (label4);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "label4", label4,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label4);
  gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label4), 5, 0);

  size_sb_adj = gtk_adjustment_new (1, 0.01, 100, 1, 10, 10);
  size_sb = gtk_spin_button_new (GTK_ADJUSTMENT (size_sb_adj), 1, 2);
  gtk_widget_set_name (size_sb, "size_sb");
  gtk_widget_ref (size_sb);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "size_sb", size_sb,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (size_sb);
  gtk_table_attach (GTK_TABLE (table1), size_sb, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (size_sb), TRUE);

  spacing_sb_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 10);
  spacing_sb = gtk_spin_button_new (GTK_ADJUSTMENT (spacing_sb_adj), 1, 0);
  gtk_widget_set_name (spacing_sb, "spacing_sb");
  gtk_widget_ref (spacing_sb);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "spacing_sb", spacing_sb,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (spacing_sb);
  gtk_table_attach (GTK_TABLE (table1), spacing_sb, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  fontx_sb_adj = gtk_adjustment_new (10, 0, 100, 1, 10, 10);
  fontx_sb = gtk_spin_button_new (GTK_ADJUSTMENT (fontx_sb_adj), 1, 0);
  gtk_widget_set_name (fontx_sb, "fontx_sb");
  gtk_widget_ref (fontx_sb);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "fontx_sb", fontx_sb,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fontx_sb);
  gtk_table_attach (GTK_TABLE (table1), fontx_sb, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  fonty_sb_adj = gtk_adjustment_new (10, 0, 100, 1, 10, 10);
  fonty_sb = gtk_spin_button_new (GTK_ADJUSTMENT (fonty_sb_adj), 1, 0);
  gtk_widget_set_name (fonty_sb, "fonty_sb");
  gtk_widget_ref (fonty_sb);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "fonty_sb", fonty_sb,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fonty_sb);
  gtk_table_attach (GTK_TABLE (table1), fonty_sb, 1, 2, 4, 5,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  Color = gtk_button_new_with_label (_("Color"));
  gtk_widget_set_name (Color, "Color");
  gtk_widget_ref (Color);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "Color", Color,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (Color);
  gtk_table_attach (GTK_TABLE (table1), Color, 0, 2, 5, 6,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  label5 = gtk_label_new (_("Variable:"));
  gtk_widget_set_name (label5, "label5");
  gtk_widget_ref (label5);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "label5", label5,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label5);
  gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label5), 5, 0);

  textplot_variables = gtk_option_menu_new ();
  gtk_widget_set_name (textplot_variables, "textplot_variables");
  gtk_widget_ref (textplot_variables);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "textplot_variables", textplot_variables,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (textplot_variables);
  gtk_table_attach (GTK_TABLE (table1), textplot_variables, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_widget_set_usize (textplot_variables, 150, 40);
  gtk_container_set_border_width (GTK_CONTAINER (textplot_variables), 5);
  textplot_variables_menu = gtk_menu_new ();
  gtk_option_menu_set_menu (GTK_OPTION_MENU (textplot_variables), textplot_variables_menu);

  dialog_action_area1 = GTK_DIALOG (TextPlotDialog)->action_area;
  gtk_widget_set_name (dialog_action_area1, "dialog_action_area1");
  gtk_object_set_data (GTK_OBJECT (TextPlotDialog), "dialog_action_area1", dialog_action_area1);
  gtk_widget_show (dialog_action_area1);
  gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 10);

  hbuttonbox1 = gtk_hbutton_box_new ();
  gtk_widget_set_name (hbuttonbox1, "hbuttonbox1");
  gtk_widget_ref (hbuttonbox1);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "hbuttonbox1", hbuttonbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbuttonbox1);
  gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbuttonbox1, TRUE, TRUE, 0);

  tpclose = gtk_button_new_with_label (_("Close"));
  gtk_widget_set_name (tpclose, "tpclose");
  gtk_widget_ref (tpclose);
  gtk_object_set_data_full (GTK_OBJECT (TextPlotDialog), "tpclose", tpclose,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (tpclose);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), tpclose);
  GTK_WIDGET_SET_FLAGS (tpclose, GTK_CAN_DEFAULT);

  gtk_signal_connect (GTK_OBJECT (size_sb), "changed",
                      GTK_SIGNAL_FUNC (on_tp_sb_changed),
                      GINT_TO_POINTER(0));
  gtk_signal_connect (GTK_OBJECT (spacing_sb), "changed",
                      GTK_SIGNAL_FUNC (on_tp_sb_changed),
                      GINT_TO_POINTER(1));
  gtk_signal_connect (GTK_OBJECT (fontx_sb), "changed",
                      GTK_SIGNAL_FUNC (on_tp_sb_changed),
                      GINT_TO_POINTER(2));
  gtk_signal_connect (GTK_OBJECT (fonty_sb), "changed",
                      GTK_SIGNAL_FUNC (on_tp_sb_changed),
                      GINT_TO_POINTER(3));
  gtk_signal_connect (GTK_OBJECT (Color), "clicked",
                      GTK_SIGNAL_FUNC (on_Color_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (tpclose), "clicked",
                      GTK_SIGNAL_FUNC (on_tpclose_clicked),
                      NULL);

  return TextPlotDialog;
}
示例#19
0
int
main (int argc, char *argv[]){
	GtkWidget *button = NULL,
			*win = NULL,
			*vbox = NULL,
			*vbox2 = NULL,
			*halign = NULL,
			*buttonbox = NULL,
			*scrl1 = NULL,
			*scrl2 = NULL,
			*sourceview = NULL;
	GtkSourceLanguageManager *gsv_lm = NULL;
	GtkSourceLanguage *gsv_lang = NULL;

	gchar *searchpaths[] =
			{"./","/usr/share/gtksourceview-2.0/language-specs/",0};

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

	/* Create the main window */
	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width (GTK_CONTAINER (win), 8);
	gtk_window_set_title (GTK_WINDOW (win), TITLE);
	gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(win), 600, 0);
	gtk_widget_realize (win);
	g_signal_connect (G_OBJECT(win), "destroy", G_CALLBACK(destroy_wnd), NULL);
	g_signal_connect (G_OBJECT(win), "delete_event", G_CALLBACK(delete_event),NULL);

	/* Create a vertical box with buttons */
	vbox = gtk_vbox_new(FALSE, 5);
	vbox2 = gtk_vbox_new(TRUE, 5);
	halign = gtk_alignment_new(1, 0, 0, 0);
	scrl1 = gtk_scrolled_window_new(0,0);
	scrl2 = gtk_scrolled_window_new(0,0);
	buttonbox = gtk_hbutton_box_new();

	gtk_container_add(GTK_CONTAINER(halign), buttonbox);
	gtk_box_pack_start(GTK_BOX(vbox2), GTK_WIDGET(scrl1), FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox2), GTK_WIDGET(scrl2), FALSE, TRUE, 0);
	gtk_widget_set_size_request(GTK_WIDGET(vbox2), 0, 400);

	gtk_container_add(GTK_CONTAINER(vbox), vbox2);
	gtk_container_add(GTK_CONTAINER(win), vbox);
	gtk_box_pack_start(GTK_BOX(vbox), halign, FALSE, FALSE, 0);

	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrl1),
								GTK_POLICY_AUTOMATIC,
								GTK_POLICY_AUTOMATIC);

	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrl2),
								GTK_POLICY_AUTOMATIC,
								GTK_POLICY_AUTOMATIC);


	/* Build the C buffer */
	if (!(gsv_lm = gtk_source_language_manager_new())) exit(1);
	gtk_source_language_manager_set_search_path(gsv_lm, searchpaths);
	if (!(gsv_lang = gtk_source_language_manager_get_language(gsv_lm, "c"))) exit(2);
	if (!(gsv_buffer_c = gtk_source_buffer_new_with_language(gsv_lang))) exit(3);
	gtk_source_buffer_set_highlight_syntax(gsv_buffer_c, TRUE);
	if (!(sourceview = gtk_source_view_new_with_buffer(gsv_buffer_c))) exit(4);
	gtk_container_add(GTK_CONTAINER(scrl1), sourceview);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(sourceview), FALSE);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(sourceview), FALSE);


	/* Build the ASM buffer */
	if (!(gsv_lm = gtk_source_language_manager_new())) exit(1);
	gtk_source_language_manager_set_search_path(gsv_lm, searchpaths);
	if (!(gsv_lang = gtk_source_language_manager_get_language(gsv_lm, "nasm"))) exit(2);
	if (!(gsv_buffer_asm = gtk_source_buffer_new_with_language(gsv_lang))) exit(3);
	gtk_source_buffer_set_highlight_syntax(gsv_buffer_asm, TRUE);
	if (!(sourceview = gtk_source_view_new_with_buffer(gsv_buffer_asm))) exit(4);
	gtk_container_add(GTK_CONTAINER(scrl2), sourceview);

	/* Set the text of the buffers */
	gtk_text_buffer_set_text(GTK_TEXT_BUFFER(gsv_buffer_c), question, strlen(question));
	gtk_text_buffer_set_text(GTK_TEXT_BUFFER(gsv_buffer_asm), answer, strlen(answer));

	/* Buttons */
	button = gtk_button_new_from_stock (GTK_STOCK_DIALOG_INFO);
	g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK(info_dialog), (gpointer) win);
	gtk_box_pack_start (GTK_BOX (buttonbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_with_label("Test Answer");
	g_signal_connect (button, "clicked", G_CALLBACK(test_answer), NULL);
	gtk_box_pack_start (GTK_BOX (buttonbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
	g_signal_connect (button, "clicked", gtk_main_quit, NULL);
	gtk_box_pack_start (GTK_BOX (buttonbox), button, FALSE, FALSE, 0);

	srand(time(NULL));

	/* Enter the main loop */
	gtk_widget_show_all (win);
	gtk_main ();
	return 0;
}
static void
netselect_dlg_show()
{
    struct netselect_dlg * dlg;
    GtkWidget * main_vbox, * scrolled,
              * button_box, * manual_hbox,
              * hbox, * vbox, * frame, * settings_vbox;
    GtkTreeViewColumn * column;
    gchar * text;

    if(main_netselect_dlg) {
        /* dialog is shown already */
        gtk_window_present(GTK_WINDOW(dlg->dlg_w));
        return;
    }

    dlg = main_netselect_dlg = g_new(struct netselect_dlg, 1);
    dlg->detect_timeout_id = 0;

    dlg->dlg_w = gtk_dialog_new_with_buttons(
                     _("Network detection and configuration"), gui_get_main_window(), 0,
                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                     GTK_STOCK_OK, GTK_RESPONSE_OK,
                     NULL);
    g_signal_connect(G_OBJECT(dlg->dlg_w), "response",
                     G_CALLBACK(dlg_response), (gpointer)dlg);
    g_signal_connect(G_OBJECT(dlg->dlg_w), "delete-event", G_CALLBACK(gtk_true), NULL);

    /* upper vertical box for list and port range controls
     */
    main_vbox = gtk_vbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg->dlg_w)->vbox), main_vbox, TRUE, TRUE, 0);

    frame = gtk_frame_new(_("Detected networks"));
    gtk_container_set_border_width(GTK_CONTAINER(frame), 2);
    gtk_box_pack_start(GTK_BOX(main_vbox), frame, TRUE, TRUE, 0);

    dlg->list = gtk_list_store_new(
                    NETLISTCOL_NUM,
                    G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
                    G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN);

    dlg->tree_w = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dlg->list));
    g_signal_connect(G_OBJECT(dlg->tree_w), "row-activated",
                     G_CALLBACK(list_row_activated), (gpointer)dlg);
    g_signal_connect(G_OBJECT(dlg->tree_w), "cursor-changed",
                     G_CALLBACK(list_cursor_changed), (gpointer)dlg);

    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(dlg->tree_w), -1, prefs_description(PREFS_NET_TYPE),
        gtk_cell_renderer_text_new(), "text", NETLISTCOL_TYPE_STR, NULL);
    column = gtk_tree_view_get_column(GTK_TREE_VIEW(dlg->tree_w), 0);
    gtk_tree_view_column_set_resizable(column, TRUE);

    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(dlg->tree_w), -1, prefs_description(PREFS_NET_PORT),
        gtk_cell_renderer_text_new(), "text", NETLISTCOL_PORT_STR, NULL);
    column = gtk_tree_view_get_column(GTK_TREE_VIEW(dlg->tree_w), 1);
    gtk_tree_view_column_set_resizable(column, TRUE);

    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(dlg->tree_w), -1, prefs_description(PREFS_NET_USE_MULTICAST),
        gtk_cell_renderer_text_new(), "text", NETLISTCOL_USE_MULTICAST_STR, NULL);
    gtk_tree_view_column_set_resizable(column, TRUE);

    scrolled = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_size_request(scrolled, -1, LIST_MIN_HEIGHT);
    gtk_scrolled_window_set_policy(
        GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), dlg->tree_w);
    gtk_container_add(GTK_CONTAINER(frame), scrolled);

    /* Make hbox for lower control frames */
    manual_hbox = gtk_hbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(main_vbox), manual_hbox, FALSE, FALSE, 0);

    /*
     * "Automatic scan" frame
     */
    frame = gtk_frame_new(_("Automatic scan"));
    gtk_container_set_border_width(GTK_CONTAINER(frame), 2);
    gtk_box_pack_start(GTK_BOX(manual_hbox), frame, TRUE, TRUE, 0);

    /* vbox inside the frame */
    vbox = gtk_vbox_new(FALSE, 4);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
    gtk_container_add(GTK_CONTAINER(frame), vbox);

    /* progress bar
     */
    dlg->detect_progress = gtk_progress_bar_new();
    gtk_box_pack_start(GTK_BOX(vbox), dlg->detect_progress, FALSE, FALSE, 0);

    /* the 'reset' and 'refresh' buttons
     */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

    button_box = gtk_hbutton_box_new();
    gtk_box_pack_end(GTK_BOX(hbox), button_box, FALSE, FALSE, 0);

    dlg->detect_btn = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
    g_signal_connect(G_OBJECT(dlg->detect_btn), "clicked",
                     G_CALLBACK(detect_button_clicked), (gpointer)dlg);
    gtk_box_pack_start(GTK_BOX(button_box), dlg->detect_btn, FALSE, FALSE, 0);

    dlg->detect_stop_btn = gtk_button_new_from_stock(GTK_STOCK_STOP);
    g_signal_connect(G_OBJECT(dlg->detect_stop_btn), "clicked",
                     G_CALLBACK(detect_button_clicked), (gpointer)dlg);
    gtk_box_pack_start(GTK_BOX(button_box), dlg->detect_stop_btn, FALSE, FALSE, 0);

    /* settings vbox */
    settings_vbox = gtk_vbox_new(FALSE, 4);

    /* port range start spin
     */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(settings_vbox), hbox, FALSE, FALSE, 0);
    dlg->detect_begin_spin = gtk_spin_button_new_with_range(1024, 65535, 1);
    gtk_spin_button_set_value(
        GTK_SPIN_BUTTON(dlg->detect_begin_spin), DEFAULT_DETECT_RANGE_BEGIN);
    gtk_box_pack_end(GTK_BOX(hbox), dlg->detect_begin_spin, FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox), gtk_label_new(_("Scan UDP ports from")), FALSE, FALSE, 0);
    g_signal_connect(G_OBJECT(dlg->detect_begin_spin), "value-changed",
                     G_CALLBACK(detect_range_spin_value_changed), (gpointer)dlg);

    /* port range end spin
     */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(settings_vbox), hbox, FALSE, FALSE, 0);
    dlg->detect_end_spin = gtk_spin_button_new_with_range(1024, 65535, 1);
    gtk_spin_button_set_value(
        GTK_SPIN_BUTTON(dlg->detect_end_spin), DEFAULT_DETECT_RANGE_END);
    gtk_box_pack_end(GTK_BOX(hbox), dlg->detect_end_spin, FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox), gtk_label_new(_("to (including)")), FALSE, FALSE, 0);
    g_signal_connect(G_OBJECT(dlg->detect_end_spin), "value-changed",
                     G_CALLBACK(detect_range_spin_value_changed), (gpointer)dlg);

    /* broadcast mask */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(settings_vbox), hbox, FALSE, FALSE, 0);
    dlg->detect_broadcast_mask_w = gtk_entry_new();
    gtk_entry_set_text(
        GTK_ENTRY(dlg->detect_broadcast_mask_w),
        text = util_inet_ntoa(prefs_int(PREFS_NET_BROADCAST_MASK)));
    g_free(text);
    gtk_box_pack_end(GTK_BOX(hbox), dlg->detect_broadcast_mask_w, FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox),
                     gtk_label_new(prefs_description(PREFS_NET_BROADCAST_MASK)), FALSE, FALSE, 0);

    /* multicast mask */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(settings_vbox), hbox, FALSE, FALSE, 0);
    dlg->detect_multicast_addr_w = gtk_entry_new();
    gtk_entry_set_text(
        GTK_ENTRY(dlg->detect_multicast_addr_w),
        text = util_inet_ntoa(prefs_int(PREFS_NET_MULTICAST_ADDR)));
    g_free(text);
    gtk_box_pack_end(GTK_BOX(hbox), dlg->detect_multicast_addr_w, FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox),
                     gtk_label_new(prefs_description(PREFS_NET_MULTICAST_ADDR)), FALSE, FALSE, 0);

    /* pack settings vbox in to the window (through the expander widget) */
#if(HAVE_EXPANDER_WIDGET)
    dlg->detect_expander_w = gtk_expander_new_with_mnemonic(_("Detection settings"));
    gtk_container_add(GTK_CONTAINER(dlg->detect_expander_w), settings_vbox);
    gtk_box_pack_start(GTK_BOX(vbox), dlg->detect_expander_w, FALSE, FALSE, 0);
#else
    gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), settings_vbox, FALSE, FALSE, 0);
#endif

    /*
     * Manual port/network entry frame
     */
    frame = gtk_frame_new(_("Network settings"));
    gtk_container_set_border_width(GTK_CONTAINER(frame), 2);
    gtk_box_pack_start(GTK_BOX(manual_hbox), frame, TRUE, TRUE, 0);

    /* vbox inside the frame */
    vbox = gtk_vbox_new(FALSE, 4);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
    gtk_container_add(GTK_CONTAINER(frame), vbox);

    /* use multicast toggle */
    dlg->net_use_multicast_w = gtk_check_button_new_with_label(
                                   prefs_description(PREFS_NET_USE_MULTICAST));
    gtk_widget_set_sensitive(
        dlg->net_use_multicast_w, prefs_int(PREFS_NET_TYPE)==NET_TYPE_VYPRESS);
    gtk_toggle_button_set_active(
        GTK_TOGGLE_BUTTON(dlg->net_use_multicast_w),
        prefs_int(PREFS_NET_TYPE)==NET_TYPE_VYPRESS
        ? prefs_bool(PREFS_NET_USE_MULTICAST): FALSE);

    /* network type option */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

    dlg->net_type_option = util_net_type_option(
                               (util_option_changed_cb)dlg_net_type_option_changed, (gpointer)dlg);
    gtk_box_pack_end(GTK_BOX(hbox), dlg->net_type_option, FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox),
                     gtk_label_new(prefs_description(PREFS_NET_TYPE)), FALSE, FALSE, 0);
    gtk_option_menu_set_history(
        GTK_OPTION_MENU(dlg->net_type_option), prefs_int(PREFS_NET_TYPE));

    /* network port number */
    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

    dlg->net_port_spin = gtk_spin_button_new_with_range(1024, 65535, 1);
    gtk_box_pack_end(GTK_BOX(hbox), dlg->net_port_spin, FALSE, FALSE, 0);
    gtk_box_pack_end(GTK_BOX(hbox),
                     gtk_label_new(prefs_description(PREFS_NET_PORT)), FALSE, FALSE, 0);
    gtk_spin_button_set_value(
        GTK_SPIN_BUTTON(dlg->net_port_spin),
        prefs_int(PREFS_NET_PORT));

    /* append the multicast toggle */
    gtk_box_pack_start(GTK_BOX(vbox), dlg->net_use_multicast_w, FALSE, FALSE, 0);

    /* show dialog to the user */
    dlg_search_mode(dlg, FALSE);

    gtk_widget_show_all(dlg->dlg_w);
    gtk_window_present(GTK_WINDOW(dlg->dlg_w));
}
示例#21
0
GaimGtkXferDialog *
gaim_gtkxfer_dialog_new(void)
{
	GaimGtkXferDialog *dialog;
	GtkWidget *window;
	GtkWidget *vbox1, *vbox2;
	GtkWidget *bbox;
	GtkWidget *sw;
	GtkWidget *sep;
	GtkWidget *button;
	GtkWidget *disclosure;
	GtkWidget *table;
	GtkWidget *checkbox;

	dialog = g_new0(GaimGtkXferDialog, 1);
	dialog->keep_open =
		gaim_prefs_get_bool("/gaim/gtk/filetransfer/keep_open");
	dialog->auto_clear =
		gaim_prefs_get_bool("/gaim/gtk/filetransfer/clear_finished");

    dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_role(GTK_WINDOW(window), "file transfer");
	gtk_window_set_title(GTK_WINDOW(window), _("File Transfers"));
	gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(window), BOX_SPACING);

	g_signal_connect(G_OBJECT(window), "delete_event",
					 G_CALLBACK(delete_win_cb), dialog);

	/* Create the parent vbox for everything. */
	vbox1 = gtk_vbox_new(FALSE, BOX_SPACING);
    gtk_container_add(GTK_CONTAINER(window), vbox1);

	gtk_widget_show(vbox1);

	/* Create the main vbox for top half of the window. */
	vbox2 = gtk_vbox_new(FALSE, CONTAINER_BORDER_WIDTH);
	gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0);
	gtk_widget_show(vbox2);

	/* Setup the listbox */
	sw = setup_tree(dialog);
	gtk_box_pack_start(GTK_BOX(vbox2), sw, TRUE, TRUE, 0);
	gtk_widget_set_size_request(sw,-1, 140);

	/* "Keep the dialog open" */
	checkbox = gtk_check_button_new_with_mnemonic(
			_("_Keep the dialog open"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
								 dialog->keep_open);
	g_signal_connect(G_OBJECT(checkbox), "toggled",
					 G_CALLBACK(toggle_keep_open_cb), dialog);
	gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0);
	gtk_widget_show(checkbox);

	/* "Clear finished transfers" */
	checkbox = gtk_check_button_new_with_mnemonic(
			_("_Clear finished transfers"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
								 dialog->auto_clear);
	g_signal_connect(G_OBJECT(checkbox), "toggled",
					 G_CALLBACK(toggle_clear_finished_cb), dialog);
	gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0);
	gtk_widget_show(checkbox);

	/* "Download Details" arrow */
	disclosure = gaim_disclosure_new(_("Show transfer details"),
									 _("Hide transfer details"));
	dialog->disclosure = disclosure;
	gtk_box_pack_start(GTK_BOX(vbox2), disclosure, FALSE, FALSE, 0);
	gtk_widget_show(disclosure);

	gtk_widget_set_sensitive(disclosure, FALSE);

#if 0
	g_signal_connect(G_OBJECT(disclosure), "toggled",
					 G_CALLBACK(toggle_details_cb), dialog);
#endif

	/* Separator */
	sep = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(vbox2), sep, FALSE, FALSE, 0);
	gtk_widget_show(sep);

	/* The table of information. */
	table = make_info_table(dialog);
	gtk_box_pack_start(GTK_BOX(vbox2), table, TRUE, TRUE, 0);

	/* Setup the disclosure for the table. */
	gaim_disclosure_set_container(GAIM_DISCLOSURE(disclosure), table);

    /* Now the button box for the buttons */
    bbox = gtk_hbutton_box_new();
    gtk_box_set_spacing(GTK_BOX(bbox), CONTAINER_BORDER_WIDTH);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
    gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, TRUE, 0);
	gtk_widget_show(bbox);

	/* Open button */
	button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
	gtk_widget_set_sensitive(button, FALSE);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);
	dialog->open_button = button;

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(open_button_cb), dialog);
	/* Pause button */
	button = gtk_button_new_with_mnemonic(_("_Pause"));
#ifndef GAIM_SMALL_SCREEN
	gtk_widget_set_sensitive(button, FALSE);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);
#endif
	dialog->pause_button = button;

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(pause_button_cb), dialog);

	/* Resume button */
	button = gtk_button_new_with_mnemonic(_("_Resume"));
#ifndef GAIM_SMALL_SCREEN
    gtk_widget_set_sensitive(button, FALSE);
    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);
#endif
	dialog->resume_button = button;

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(resume_button_cb), dialog);

	/* Remove button */
	button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
#ifndef GAIM_SMALL_SCREEN
    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
    gtk_widget_hide(button);
#endif
	dialog->remove_button = button;

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(remove_button_cb), dialog);

	/* Stop button */
	button = gtk_button_new_from_stock(GTK_STOCK_STOP);
#ifndef GAIM_SMALL_SCREEN
    gtk_widget_set_sensitive(button, FALSE);
    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);
#endif
	dialog->stop_button = button;

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(stop_button_cb), dialog);

	/* Close button */
	button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);
	dialog->close_button = button;

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(close_button_cb), dialog);

	return dialog;
}
static void
create_gui (void)
{
  char *titles[] = {
    "Name", "Type", "Value", "Serial"
  };
  
  GtkWidget *scrolled_window;
  GtkWidget *dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  GtkWidget *vbox, *bbox, *separator, *table, *button;

  gtk_window_set_title (GTK_WINDOW (dialog), "Sample XSETTINGS Client");
  gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 300);

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

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (dialog), vbox);

  bbox = gtk_hbutton_box_new ();
  gtk_box_pack_end (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);

  gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
  gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
  
  separator = gtk_hseparator_new ();
  gtk_box_pack_end (GTK_BOX (vbox), separator, FALSE, FALSE, 0);

  table = gtk_table_new (3, 2, FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (table), 5);
  gtk_table_set_row_spacings (GTK_TABLE (table), 5);
  gtk_table_set_col_spacings (GTK_TABLE (table), 5);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  settings_clist = gtk_clist_new_with_titles (4, titles);
  gtk_container_add (GTK_CONTAINER (scrolled_window), settings_clist);
  gtk_clist_set_selection_mode (GTK_CLIST (settings_clist), GTK_SELECTION_BROWSE);
  gtk_clist_set_sort_column (GTK_CLIST (settings_clist), 1);
  gtk_clist_set_auto_sort (GTK_CLIST (settings_clist), TRUE);

  gtk_clist_set_column_width (GTK_CLIST (settings_clist), NAME, 200);
  gtk_clist_set_column_width (GTK_CLIST (settings_clist), TYPE, 50);
  gtk_clist_set_column_width (GTK_CLIST (settings_clist), VALUE, 100);
  gtk_clist_set_column_width (GTK_CLIST (settings_clist), SERIAL, 50);

  gtk_table_attach (GTK_TABLE (table), scrolled_window,
		    1, 2,                    1, 2,
		    GTK_EXPAND | GTK_FILL,   GTK_EXPAND | GTK_FILL,
		    0,                       0);
  
  gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);

  button = gtk_button_new_with_label ("Close");
  gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0);
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);

  gtk_signal_connect (GTK_OBJECT (button), "clicked",
		      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  gtk_widget_show_all (dialog);
}
示例#23
0
void appconfig_show(GtkWidget *main_window)
{
    GtkWidget *vbox;
    GtkWidget *table;
    GtkWidget *hbbox;
    GtkWidget *ok_button;
    GtkWidget *label;

    GtkWidget *notebook;

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_realize(window);
    gtk_window_set_modal(GTK_WINDOW(window), TRUE);
    gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(main_window));
    gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ON_PARENT);
    gdk_window_set_functions(gtk_widget_get_window(window), GDK_FUNC_MOVE);
    gtk_window_set_title( GTK_WINDOW(window), _("wavbreaker Preferences"));

    /* create the vbox for the first tab */
    vbox = gtk_vbox_new(FALSE, 10);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
    gtk_container_add( GTK_CONTAINER(window), vbox);

    notebook = gtk_notebook_new();
    gtk_container_add( GTK_CONTAINER(vbox), notebook);

    /* Selectable Output Directory */
    table = gtk_table_new(2, 3, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(table), 10);
    gtk_table_set_row_spacings( GTK_TABLE(table), 5);
    gtk_notebook_append_page( GTK_NOTEBOOK(notebook), table, gtk_label_new( _("General")));

    use_outputdir_toggle = gtk_check_button_new_with_label(_("Save output files in folder:"));
    gtk_table_attach(GTK_TABLE(table), use_outputdir_toggle,
        0, 2, 0, 1, GTK_FILL, 0, 5, 0);
    g_signal_connect(GTK_OBJECT(use_outputdir_toggle), "toggled",
        G_CALLBACK(use_outputdir_toggled), NULL);

    outputdir_entry = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(outputdir_entry), outputdir);
    gtk_entry_set_width_chars(GTK_ENTRY(outputdir_entry), 40);
    gtk_table_attach(GTK_TABLE(table), outputdir_entry,
        0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 5, 0);

    browse_button = gtk_button_new_with_label(_("Browse"));
    gtk_table_attach(GTK_TABLE(table), browse_button,
        1, 2, 1, 2, GTK_FILL, 0, 5, 0);
    g_signal_connect(G_OBJECT(browse_button), "clicked",
            (GCallback)browse_button_clicked, window);

    silence_spin_button = (GtkWidget*)gtk_spin_button_new_with_range( 1.0, 100.0, 1.0);
    gtk_spin_button_set_digits( GTK_SPIN_BUTTON(silence_spin_button), 0);
    gtk_spin_button_set_value( GTK_SPIN_BUTTON(silence_spin_button), appconfig_get_silence_percentage());
    
    label = gtk_label_new( _("Maximum volume considered silence (in percent):"));
    gtk_misc_set_alignment( GTK_MISC(label), 0.0, 0.5);

    gtk_table_attach( GTK_TABLE(table), label,
        0, 1, 2, 3, GTK_FILL, 0, 5, 0);
    gtk_table_attach( GTK_TABLE(table), silence_spin_button,
        1, 2, 2, 3, GTK_EXPAND, 0, 5, 0);

    /* Etree Filename Suffix */

    table = gtk_table_new(4, 10, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(table), 10);
    gtk_notebook_append_page( GTK_NOTEBOOK(notebook), table, gtk_label_new( _("File Naming")));

    radio1 = gtk_radio_button_new_with_label(NULL, _("Standard (##)"));
    gtk_table_attach(GTK_TABLE(table), radio1, 0, 3, 0, 1, GTK_FILL, 0, 5, 2);
    g_signal_connect(GTK_OBJECT(radio1), "toggled",
        G_CALLBACK(radio_buttons_toggled), NULL);

    label = gtk_label_new("   ");
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
    gtk_table_attach(GTK_TABLE(table), label,
            0, 1, 2, 3, GTK_FILL, 0, 5, 2);

    prepend_file_number_toggle = gtk_check_button_new_with_label(_("Prepend number before filename"));
    gtk_table_attach(GTK_TABLE(table), prepend_file_number_toggle,
            1, 3, 2, 3, GTK_FILL, 0, 5, 0);
    g_signal_connect(GTK_OBJECT(prepend_file_number_toggle), "toggled",
        G_CALLBACK(prepend_file_number_toggled), NULL);

    etree_filename_suffix_label = gtk_label_new(_("Separator:"));
    gtk_misc_set_alignment(GTK_MISC(etree_filename_suffix_label), 0, 0.5);
    gtk_table_attach(GTK_TABLE(table), etree_filename_suffix_label,
            1, 2, 1, 2, GTK_FILL, 0, 5, 2);

    etree_filename_suffix_entry = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(etree_filename_suffix_entry), etree_filename_suffix);
    gtk_entry_set_width_chars(GTK_ENTRY(etree_filename_suffix_entry), 10);
    gtk_table_attach(GTK_TABLE(table), etree_filename_suffix_entry,
            2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 5, 2);

    radio2 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio1),
            _("etree.org (d#t##)"));
    gtk_table_attach(GTK_TABLE(table), radio2, 0, 3, 3, 4, GTK_FILL, 0, 5, 2);

    etree_cd_length_label = gtk_label_new(_("CD Length:"));
    gtk_misc_set_alignment(GTK_MISC(etree_cd_length_label), 0, 0.5);
    gtk_table_attach(GTK_TABLE(table), etree_cd_length_label,
            1, 2, 5, 6, GTK_FILL, 0, 5, 2);

    etree_cd_length_entry = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(etree_cd_length_entry), etree_cd_length);
    gtk_entry_set_width_chars(GTK_ENTRY(etree_cd_length_entry), 10);
    gtk_table_attach(GTK_TABLE(table), etree_cd_length_entry,
            2, 3, 5, 6, GTK_EXPAND | GTK_FILL, 0, 5, 2);

    /* OK and Cancel Buttons */
    hbbox = gtk_hbutton_box_new();
    gtk_container_add(GTK_CONTAINER(vbox), hbbox);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
    gtk_box_set_spacing(GTK_BOX(hbbox), 10);

    ok_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
    gtk_box_pack_end(GTK_BOX(hbbox), ok_button, FALSE, FALSE, 5);
    g_signal_connect(G_OBJECT(ok_button), "clicked",
        (GCallback)ok_button_clicked, window);

    g_signal_connect(GTK_OBJECT(radio2), "toggled",
        G_CALLBACK(use_etree_filename_suffix_toggled), NULL);

    loading_ui = TRUE;

    gboolean use_output_dir = appconfig_get_use_outputdir() ? TRUE : FALSE;
    gtk_widget_set_sensitive(outputdir_entry, use_output_dir);
    gtk_widget_set_sensitive(browse_button, use_output_dir);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_outputdir_toggle), use_output_dir);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prepend_file_number_toggle),
            appconfig_get_prepend_file_number() ? TRUE : FALSE);

    gboolean use_etree = appconfig_get_use_etree_filename_suffix() ? TRUE : FALSE;
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio1), !use_etree);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio2), use_etree);

    loading_ui = FALSE;

    gtk_widget_show_all(window);
    set_audio_function_pointers();
    radio_buttons_toggled( NULL, NULL);
}
示例#24
0
void
create_main_window (ContactsData *data)
{
	GtkWidget *main_window;
	GtkWidget *vbox7;
	GtkWidget *main_menubar;
	GtkWidget *contacts_menu;
	GtkWidget *contacts_menu_menu;
	GtkWidget *new_menuitem;
	GtkWidget *edit_menuitem;
	GtkWidget *delete_menuitem;
	GtkWidget *contacts_import;
	GtkWidget *contacts_quit;
	GtkWidget *contact_menu;
	GtkWidget *contact_menu_menu;
	GtkWidget *contact_delete;
	GtkWidget *edit_groups;
	GtkWidget *contact_export;
	GtkWidget *contact_quit;
	GtkWidget *edit_menu;
	GtkWidget *menuitem5_menu;
	GtkWidget *cut;
	GtkWidget *copy;
	GtkWidget *paste;
	GtkWidget *help_menu;
	GtkWidget *menuitem7_menu;
	GtkWidget *about1;
	GtkWidget *main_notebook;
	GtkWidget *main_hpane;
	GtkWidget *contacts_vbox;
	GtkWidget *scrolledwindow2;
	GtkWidget *contacts_treeview;
	GtkWidget *search_hbox;
	GtkWidget *search_entry_hbox;
	GtkWidget *search_entry;
	GtkWidget *search_tab_hbox;
	GtkWidget *symbols_radiobutton;
	GSList *symbols_radiobutton_group = NULL;
	GtkWidget *atog_radiobutton;
	GtkWidget *hton_radiobutton;
	GtkWidget *otou_radiobutton;
	GtkWidget *vtoz_radiobutton;
	GtkWidget *vbox3;
	GtkWidget *summary_vbox;
	GtkWidget *preview_header_hbox;
	GtkWidget *preview_namegroup_vbox;
	GtkWidget *summary_name_label;
	GtkWidget *summary_group_label;
	GtkWidget *photo_image;
	GtkWidget *scrolledwindow3;
	GtkWidget *viewport1;
	GtkWidget *summary_table;
	GtkWidget *summary_hbuttonbox;
	GtkWidget *new_button;
	GtkWidget *edit_button;
	GtkWidget *delete_button;
	GtkWidget *vbox4;
	GtkWidget *scrolledwindow4;
	GtkWidget *viewport2;
	GtkWidget *edit_table;
	GtkWidget *hbuttonbox2;
	GtkWidget *add_field_button;
	GtkWidget *remove_field_button;
	GtkWidget *edit_done_button;
	GtkWidget *widget;
	GtkAccelGroup *accel_group;
	ContactsUI *ui = data->ui;
	GtkSizeGroup *size_group;

#ifdef HAVE_GCONF
	GConfClient *client;
	gchar *search;
	gint width, height;
#endif

	accel_group = gtk_accel_group_new ();

	main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (main_window), _("Contacts"));
	gtk_window_set_icon_name (GTK_WINDOW (main_window), "contacts");
	gtk_window_set_default_size (GTK_WINDOW (main_window), 320, 240);

	vbox7 = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (main_window), vbox7);

	main_menubar = gtk_menu_bar_new ();
	gtk_box_pack_start (GTK_BOX (vbox7), main_menubar, FALSE, FALSE, 0);

	contacts_menu = gtk_menu_item_new_with_mnemonic (_("C_ontacts"));
	gtk_container_add (GTK_CONTAINER (main_menubar), contacts_menu);

	contacts_menu_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (contacts_menu), contacts_menu_menu);

	new_menuitem = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
	gtk_container_add (GTK_CONTAINER (contacts_menu_menu), new_menuitem);

	edit_menuitem = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
	gtk_container_add (GTK_CONTAINER (contacts_menu_menu), edit_menuitem);
	gtk_widget_set_sensitive (edit_menuitem, FALSE);

	delete_menuitem = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
	gtk_container_add (GTK_CONTAINER (contacts_menu_menu), delete_menuitem);
	gtk_widget_set_sensitive (delete_menuitem, FALSE);

	contacts_import = gtk_menu_item_new_with_mnemonic (_("_Import..."));
	gtk_container_add (GTK_CONTAINER (contacts_menu_menu), contacts_import);

	widget = gtk_separator_menu_item_new ();
	gtk_container_add (GTK_CONTAINER (contacts_menu_menu), widget);
	gtk_widget_set_sensitive (widget, FALSE);

	contacts_quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
	gtk_container_add (GTK_CONTAINER (contacts_menu_menu), contacts_quit);

	contact_menu = gtk_menu_item_new_with_mnemonic (_("C_ontact"));
	gtk_container_add (GTK_CONTAINER (main_menubar), contact_menu);
	g_object_set (G_OBJECT (contact_menu), "no-show-all", TRUE, NULL);

	contact_menu_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (contact_menu), contact_menu_menu);

	contact_delete = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
	gtk_container_add (GTK_CONTAINER (contact_menu_menu), contact_delete);

	edit_groups = gtk_menu_item_new_with_mnemonic (_("_Groups"));
	gtk_container_add (GTK_CONTAINER (contact_menu_menu), edit_groups);

	contact_export = gtk_menu_item_new_with_mnemonic (_("_Export"));
	gtk_container_add (GTK_CONTAINER (contact_menu_menu), contact_export);

	widget = gtk_separator_menu_item_new ();
	gtk_container_add (GTK_CONTAINER (contact_menu_menu), widget);
	gtk_widget_set_sensitive (widget, FALSE);

	contact_quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
	gtk_container_add (GTK_CONTAINER (contact_menu_menu), contact_quit);

	edit_menu = gtk_menu_item_new_with_mnemonic (_("Ed_it"));
	gtk_container_add (GTK_CONTAINER (main_menubar), edit_menu);

	menuitem5_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (edit_menu), menuitem5_menu);

	cut = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem5_menu), cut);

	copy = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem5_menu), copy);

	paste = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem5_menu), paste);

	help_menu = gtk_menu_item_new_with_mnemonic (_("_Help"));
	gtk_container_add (GTK_CONTAINER (main_menubar), help_menu);

	menuitem7_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (help_menu), menuitem7_menu);

	about1 = gtk_image_menu_item_new_from_stock ("gtk-about", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem7_menu), about1);

	main_notebook = gtk_notebook_new ();
	gtk_box_pack_start (GTK_BOX (vbox7), main_notebook, TRUE, TRUE, 0);
	GTK_WIDGET_UNSET_FLAGS (main_notebook, GTK_CAN_FOCUS);
	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (main_notebook), FALSE);
	gtk_notebook_set_show_border (GTK_NOTEBOOK (main_notebook), FALSE);

	main_hpane = gtk_hpaned_new ();
	gtk_container_add (GTK_CONTAINER (main_notebook), main_hpane);

	contacts_vbox = gtk_vbox_new (FALSE, 6);
	gtk_paned_pack1 (GTK_PANED (main_hpane), contacts_vbox, FALSE, FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (contacts_vbox), 6);

	groups_combobox = gtk_combo_box_new ();
	GtkListStore *ls = gtk_list_store_new (1, G_TYPE_STRING);
	GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (groups_combobox),
	    groups_combo_seperator_func, NULL, NULL);
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (groups_combobox), renderer, TRUE);
	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (groups_combobox), renderer, "text", 0);
	gtk_combo_box_set_model (GTK_COMBO_BOX (groups_combobox), GTK_TREE_MODEL(ls));
	gtk_box_pack_start (GTK_BOX (contacts_vbox), groups_combobox, FALSE, TRUE, 0);
	gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (groups_combobox), FALSE);

	scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
	gtk_box_pack_start (GTK_BOX (contacts_vbox), scrolledwindow2, TRUE, TRUE, 0);
	GTK_WIDGET_UNSET_FLAGS (scrolledwindow2, GTK_CAN_FOCUS);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN);

	contacts_treeview = gtk_tree_view_new ();
	gtk_container_add (GTK_CONTAINER (scrolledwindow2), contacts_treeview);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (contacts_treeview), FALSE);
	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (contacts_treeview), FALSE);

	search_hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_end (GTK_BOX (contacts_vbox), search_hbox, FALSE, TRUE, 0);

	search_entry_hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (search_hbox), search_entry_hbox, TRUE, TRUE, 0);

	search_entry = gtk_entry_new ();
	gtk_box_pack_end (GTK_BOX (search_entry_hbox), search_entry, TRUE, TRUE, 0);
	gtk_entry_set_activates_default (GTK_ENTRY (search_entry), TRUE);

	widget = gtk_label_new_with_mnemonic (_("_Search:"));
	gtk_box_pack_start (GTK_BOX (search_entry_hbox), widget, FALSE, FALSE, 0);
	gtk_misc_set_padding (GTK_MISC (widget), 6, 0);
	gtk_label_set_mnemonic_widget (GTK_LABEL (widget), search_entry);

	search_tab_hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (search_hbox), search_tab_hbox, TRUE, TRUE, 0);
	g_object_set (G_OBJECT (search_tab_hbox), "no-show-all", TRUE, NULL);

	symbols_radiobutton = gtk_radio_button_new_with_mnemonic (NULL, _("0-9#"));
	gtk_box_pack_start (GTK_BOX (search_tab_hbox), symbols_radiobutton, TRUE, FALSE, 0);
	gtk_radio_button_set_group (GTK_RADIO_BUTTON (symbols_radiobutton), symbols_radiobutton_group);
	symbols_radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (symbols_radiobutton));

	atog_radiobutton = gtk_radio_button_new_with_mnemonic (NULL, _("A-G"));
	gtk_box_pack_start (GTK_BOX (search_tab_hbox), atog_radiobutton, TRUE, FALSE, 0);
	gtk_radio_button_set_group (GTK_RADIO_BUTTON (atog_radiobutton), symbols_radiobutton_group);
	symbols_radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (atog_radiobutton));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (atog_radiobutton), TRUE);

	hton_radiobutton = gtk_radio_button_new_with_mnemonic (NULL, _("H-N"));
	gtk_box_pack_start (GTK_BOX (search_tab_hbox), hton_radiobutton, TRUE, FALSE, 0);
	gtk_radio_button_set_group (GTK_RADIO_BUTTON (hton_radiobutton), symbols_radiobutton_group);
	symbols_radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (hton_radiobutton));

	otou_radiobutton = gtk_radio_button_new_with_mnemonic (NULL, _("O-U"));
	gtk_box_pack_start (GTK_BOX (search_tab_hbox), otou_radiobutton, TRUE, FALSE, 0);
	gtk_radio_button_set_group (GTK_RADIO_BUTTON (otou_radiobutton), symbols_radiobutton_group);
	symbols_radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (otou_radiobutton));

	vtoz_radiobutton = gtk_radio_button_new_with_mnemonic (NULL, _("V-Z"));
	gtk_box_pack_start (GTK_BOX (search_tab_hbox), vtoz_radiobutton, TRUE, FALSE, 0);
	gtk_radio_button_set_group (GTK_RADIO_BUTTON (vtoz_radiobutton), symbols_radiobutton_group);
	symbols_radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (vtoz_radiobutton));

	vbox3 = gtk_vbox_new (FALSE, 6);
	gtk_paned_pack2 (GTK_PANED (main_hpane), vbox3, TRUE, FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (vbox3), 6);

	summary_vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (vbox3), summary_vbox, TRUE, TRUE, 0);

	preview_header_hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (summary_vbox), preview_header_hbox, FALSE, TRUE, 0);

	preview_namegroup_vbox = gtk_vbox_new (FALSE, 0);

	summary_name_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (preview_namegroup_vbox), summary_name_label, TRUE, TRUE, 0);
	GTK_WIDGET_SET_FLAGS (summary_name_label, GTK_CAN_FOCUS);
	gtk_label_set_use_markup (GTK_LABEL (summary_name_label), TRUE);
	gtk_label_set_selectable (GTK_LABEL (summary_name_label), TRUE);
	gtk_misc_set_alignment (GTK_MISC (summary_name_label), 0, 0.5);
	gtk_misc_set_padding (GTK_MISC (summary_name_label), 6, 0);
	gtk_label_set_ellipsize (GTK_LABEL (summary_name_label), PANGO_ELLIPSIZE_END);

	summary_group_label = gtk_label_new (NULL);
	gtk_box_pack_start (GTK_BOX (preview_namegroup_vbox), summary_group_label, TRUE, TRUE, 0);
	GTK_WIDGET_SET_FLAGS (summary_group_label, GTK_CAN_FOCUS);
	gtk_label_set_use_markup (GTK_LABEL (summary_group_label), TRUE);
	gtk_label_set_selectable (GTK_LABEL (summary_group_label), TRUE);
	gtk_misc_set_alignment (GTK_MISC (summary_group_label), 0, 0.5);
	gtk_misc_set_padding (GTK_MISC (summary_group_label), 6, 0);
	gtk_label_set_ellipsize (GTK_LABEL (summary_group_label), PANGO_ELLIPSIZE_END);

	gtk_box_pack_start (GTK_BOX (preview_header_hbox), preview_namegroup_vbox, TRUE, TRUE, 0);


	/* load stock_person as the default icon so the image has the correct
	 * size before a contact is loaded */
	photo_image = gtk_image_new_from_icon_name ("stock_person", GTK_ICON_SIZE_DIALOG);
	gtk_box_pack_end (GTK_BOX (preview_header_hbox), photo_image, FALSE, TRUE, 6);
	gtk_misc_set_padding (GTK_MISC (photo_image), 1, 0);

	scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL);
	gtk_box_pack_start (GTK_BOX (summary_vbox), scrolledwindow3, TRUE, TRUE, 0);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	viewport1 = gtk_viewport_new (NULL, NULL);
	gtk_container_add (GTK_CONTAINER (scrolledwindow3), viewport1);

	summary_table = gtk_table_new (1, 2, FALSE);
	gtk_container_add (GTK_CONTAINER (viewport1), summary_table);
	gtk_table_set_row_spacings (GTK_TABLE (summary_table), 6);
	gtk_table_set_col_spacings (GTK_TABLE (summary_table), 6);

	summary_hbuttonbox = gtk_hbutton_box_new ();
	gtk_box_pack_end (GTK_BOX (vbox3), summary_hbuttonbox, FALSE, FALSE, 0);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (summary_hbuttonbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX (summary_hbuttonbox), 6);

	new_button = gtk_button_new_from_stock ("gtk-new");
	gtk_container_add (GTK_CONTAINER (summary_hbuttonbox), new_button);
	GTK_WIDGET_SET_FLAGS (new_button, GTK_CAN_DEFAULT);

	edit_button = gtk_button_new_from_stock ("gtk-edit");
	gtk_container_add (GTK_CONTAINER (summary_hbuttonbox), edit_button);
	gtk_widget_set_sensitive (edit_button, FALSE);
	GTK_WIDGET_SET_FLAGS (edit_button, GTK_CAN_DEFAULT);

	delete_button = gtk_button_new_from_stock ("gtk-delete");
	gtk_container_add (GTK_CONTAINER (summary_hbuttonbox), delete_button);
	gtk_widget_set_sensitive (delete_button, FALSE);
	GTK_WIDGET_SET_FLAGS (delete_button, GTK_CAN_DEFAULT);
	gtk_button_set_focus_on_click (GTK_BUTTON (delete_button), FALSE);

	vbox4 = gtk_vbox_new (FALSE, 6);
	gtk_container_add (GTK_CONTAINER (main_notebook), vbox4);
	gtk_container_set_border_width (GTK_CONTAINER (vbox4), 6);

	scrolledwindow4 = gtk_scrolled_window_new (NULL, NULL);
	gtk_box_pack_start (GTK_BOX (vbox4), scrolledwindow4, TRUE, TRUE, 0);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow4), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	viewport2 = gtk_viewport_new (NULL, NULL);
	gtk_container_add (GTK_CONTAINER (scrolledwindow4), viewport2);

	edit_table = gtk_table_new (1, 2, FALSE);
	gtk_container_add (GTK_CONTAINER (viewport2), edit_table);
	gtk_container_set_border_width (GTK_CONTAINER (edit_table), 6);
	gtk_table_set_row_spacings (GTK_TABLE (edit_table), 6);

	hbuttonbox2 = gtk_hbutton_box_new ();
	gtk_box_pack_start (GTK_BOX (vbox4), hbuttonbox2, FALSE, TRUE, 0);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox2), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX (hbuttonbox2), 6);

	add_field_button = gtk_button_new_with_mnemonic (_("_Add Field"));
	gtk_container_add (GTK_CONTAINER (hbuttonbox2), add_field_button);
	GTK_WIDGET_SET_FLAGS (add_field_button, GTK_CAN_DEFAULT);

	remove_field_button = gtk_button_new_with_mnemonic (_("_Remove Field"));
	gtk_container_add (GTK_CONTAINER (hbuttonbox2), remove_field_button);
	GTK_WIDGET_SET_FLAGS (remove_field_button, GTK_CAN_DEFAULT);
	gtk_button_set_focus_on_click (GTK_BUTTON (remove_field_button), FALSE);

	edit_done_button = gtk_button_new_from_stock ("gtk-close");
	gtk_container_add (GTK_CONTAINER (hbuttonbox2), edit_done_button);
	GTK_WIDGET_SET_FLAGS (edit_done_button, GTK_CAN_DEFAULT);


	gtk_widget_grab_focus (contacts_treeview);
	gtk_widget_grab_default (edit_button);
	gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group);

	/* Set up size group for bottom row of buttons and search */
	size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
	gtk_size_group_add_widget (size_group, search_hbox);
	gtk_size_group_add_widget (size_group, summary_hbuttonbox);
	g_object_unref (size_group);



	/* connect signals */
	g_signal_connect (G_OBJECT (main_window), "delete-event",
			G_CALLBACK (contacts_main_window_delete_event_cb), data);

	g_signal_connect ((gpointer) main_window, "destroy",
			G_CALLBACK (gtk_main_quit),
			NULL);
	g_signal_connect_swapped ((gpointer) main_window, "set_focus",
			G_CALLBACK (contacts_edit_set_focus_cb),
			GTK_OBJECT (remove_field_button));
	g_signal_connect ((gpointer) contacts_quit, "activate",
			G_CALLBACK (gtk_main_quit),
			NULL);
	g_signal_connect ((gpointer) contact_quit, "activate",
			G_CALLBACK (gtk_main_quit),
			NULL);
	g_signal_connect_swapped ((gpointer) cut, "activate",
			G_CALLBACK (contacts_cut_cb),
			GTK_OBJECT (main_window));
	g_signal_connect_swapped ((gpointer) copy, "activate",
			G_CALLBACK (contacts_copy_cb),
			GTK_OBJECT (main_window));
	g_signal_connect_swapped ((gpointer) paste, "activate",
			G_CALLBACK (contacts_paste_cb),
			GTK_OBJECT (main_window));
	g_signal_connect_swapped ((gpointer) about1, "activate",
			G_CALLBACK (contacts_about_cb),
			main_window);
	g_signal_connect_swapped ((gpointer) groups_combobox, "changed",
			G_CALLBACK (contacts_update_treeview),
			data);
	g_signal_connect_data ((gpointer) contacts_treeview, "key_press_event",
			G_CALLBACK (contacts_treeview_search_cb),
			GTK_OBJECT (search_entry),
			NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
	g_signal_connect ((gpointer) search_entry, "changed",
			G_CALLBACK (contacts_search_changed_cb),
			data);
	g_signal_connect ((gpointer) symbols_radiobutton, "clicked",
			G_CALLBACK (contacts_search_changed_cb),
			data);
	g_signal_connect ((gpointer) atog_radiobutton, "clicked",
			G_CALLBACK (contacts_search_changed_cb),
			data);
	g_signal_connect ((gpointer) hton_radiobutton, "clicked",
			G_CALLBACK (contacts_search_changed_cb),
			data);
	g_signal_connect ((gpointer) otou_radiobutton, "clicked",
			G_CALLBACK (contacts_search_changed_cb),
			data);
	g_signal_connect ((gpointer) vtoz_radiobutton, "clicked",
			G_CALLBACK (contacts_search_changed_cb),
			data);
	g_signal_connect ((gpointer) remove_field_button, "clicked",
			G_CALLBACK (contacts_remove_field_cb),
			NULL);
	g_signal_connect (G_OBJECT (new_button), "clicked",
			  G_CALLBACK (contacts_new_cb), data);
	g_signal_connect (G_OBJECT (new_menuitem), "activate",
			  G_CALLBACK (contacts_new_cb), data);
	g_signal_connect (G_OBJECT (edit_button), "clicked",
			  G_CALLBACK (contacts_edit_cb), data);
	g_signal_connect (G_OBJECT (contacts_treeview), "row_activated",
			  G_CALLBACK (contacts_treeview_edit_cb), data);
	g_signal_connect (G_OBJECT (edit_menuitem), "activate",
			  G_CALLBACK (contacts_edit_cb), data);
	g_signal_connect (G_OBJECT (delete_button), "clicked",
			  G_CALLBACK (contacts_delete_cb), data);
	g_signal_connect (G_OBJECT (delete_menuitem), "activate",
			  G_CALLBACK (contacts_delete_cb), data);
	g_signal_connect (G_OBJECT (contacts_import), "activate",
			  G_CALLBACK (contacts_import_cb), data);
	g_signal_connect (G_OBJECT (edit_menu), "activate",
			  G_CALLBACK (contacts_edit_menu_activate_cb), data);
	g_signal_connect (G_OBJECT (groups_combobox), "changed",
			  G_CALLBACK (groups_combobox_changed_cb), data);

	ui->contact_delete = contact_delete;
	ui->contact_export = contact_export;
	ui->contact_menu = contact_menu;

	ui->contacts_import = contacts_import;
	ui->contacts_menu = contacts_menu;
	ui->contacts_treeview = contacts_treeview;

	ui->new_menuitem = new_menuitem;
	ui->copy_menuitem = copy;
	ui->cut_menuitem = cut;
	ui->delete_menuitem = delete_menuitem;
	ui->delete_button = delete_button;
	ui->edit_menuitem = edit_menuitem;
	ui->edit_button = edit_button;
	ui->edit_done_button = edit_done_button;
	ui->edit_groups = edit_groups;
	ui->edit_menu = edit_menu;
	ui->edit_table = edit_table;
	ui->main_menubar = main_menubar;
	ui->main_notebook = main_notebook;
	ui->main_window = main_window;
	ui->new_button = new_button;
	ui->paste_menuitem = paste;
	ui->photo_image = photo_image;
	ui->preview_header_hbox = preview_header_hbox;

	ui->add_field_button = add_field_button;
	ui->remove_field_button = remove_field_button;

	ui->search_entry = search_entry;
	ui->search_entry_hbox = search_entry_hbox;
	ui->search_hbox = search_hbox;
	ui->search_tab_hbox = search_tab_hbox;
	//ui->groups_combobox = groups_combobox;

	ui->summary_hbuttonbox = summary_hbuttonbox;
	ui->summary_name_label = summary_name_label;
	ui->summary_group_label = summary_group_label;
	ui->summary_table = summary_table;
	ui->summary_vbox = summary_vbox;

#ifdef HAVE_GCONF
	client = gconf_client_get_default ();
	search = gconf_client_get_string (client, GCONF_KEY_SEARCH, NULL);
	if (!search) {
		gconf_client_set_string (
			client, GCONF_KEY_SEARCH, "entry", NULL);
	} else {
		if (strcmp (search, "alphatab") == 0) {
			gtk_widget_hide (search_entry_hbox);
			gtk_widget_show (search_tab_hbox);
		}
		g_free (search);
	}
	gconf_client_add_dir (client, GCONF_PATH, GCONF_CLIENT_PRELOAD_NONE,
		NULL);
	gconf_client_notify_add (client, GCONF_KEY_SEARCH,
		contacts_gconf_search_cb, data, NULL, NULL);

	width = gconf_client_get_int (client, GCONF_PATH "/width", NULL);
	height = gconf_client_get_int (client, GCONF_PATH "/height", NULL);
	gtk_window_set_default_size (GTK_WINDOW (main_window), width, height);
#endif

}
示例#25
0
文件: crash.c 项目: SpOOnman/claws
/*!
 *\brief	show crash dialog
 *
 *\param	text Description
 *\param	debug_output Output text by gdb
 *
 *\return	GtkWidget * Dialog widget
 */
static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output)
{
	GtkWidget *window1;
	GtkWidget *vbox1;
	GtkWidget *hbox1;
	GtkWidget *label1;
	GtkWidget *frame1;
	GtkWidget *scrolledwindow1;
	GtkWidget *text1;
	GtkWidget *hbuttonbox3;
	GtkWidget *hbuttonbox4;
	GtkWidget *button3;
	GtkWidget *button4;
	GtkWidget *button5;
	gchar	  *crash_report;
	GtkTextBuffer *buffer;
	GtkTextIter iter;

	window1 = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "crash");
	gtk_container_set_border_width(GTK_CONTAINER(window1), 5);
	gtk_window_set_title(GTK_WINDOW(window1), _("Claws Mail has crashed"));
	gtk_window_set_position(GTK_WINDOW(window1), GTK_WIN_POS_CENTER);
	gtk_window_set_modal(GTK_WINDOW(window1), TRUE);
	gtk_window_set_default_size(GTK_WINDOW(window1), 460, 272);


	vbox1 = gtk_vbox_new(FALSE, 2);
	gtk_widget_show(vbox1);
	gtk_container_add(GTK_CONTAINER(window1), vbox1);

	hbox1 = gtk_hbox_new(FALSE, 4);
	gtk_widget_show(hbox1);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(hbox1), 4);

	label1 = gtk_label_new
	    (g_strdup_printf(_("%s.\nPlease file a bug report and include the information below."), text));
	gtk_widget_show(label1);
	gtk_box_pack_start(GTK_BOX(hbox1), label1, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(label1), 7.45058e-09, 0.5);

	frame1 = gtk_frame_new(_("Debug log"));
	gtk_widget_show(frame1);
	gtk_box_pack_start(GTK_BOX(vbox1), frame1, TRUE, TRUE, 0);

	scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolledwindow1);
	gtk_container_add(GTK_CONTAINER(frame1), scrolledwindow1);
	gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow1), 3);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
				       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

	text1 = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text1), FALSE);
	gtk_widget_show(text1);
	gtk_container_add(GTK_CONTAINER(scrolledwindow1), text1);
	
	crash_report = g_strdup_printf(
		"Claws Mail version %s\n"
		"GTK+ version %d.%d.%d / GLib %d.%d.%d\n"
		"Locale: %s (charset: %s)\n"
		"Features:%s\n"
		"Operating system: %s\n"
		"C Library: %s\n--\n%s",
		VERSION,
		gtk_major_version, gtk_minor_version, gtk_micro_version,
		glib_major_version, glib_minor_version, glib_micro_version,
		conv_get_current_locale(), conv_get_locale_charset_str(),
		get_compiled_in_features(),
		get_operating_system(),
		get_lib_version(),
		debug_output);

	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text1));
	gtk_text_buffer_get_start_iter(buffer, &iter);
	gtk_text_buffer_insert(buffer, &iter, crash_report, -1);

	hbuttonbox3 = gtk_hbutton_box_new();
	gtk_widget_show(hbuttonbox3);
	gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox3, FALSE, FALSE, 0);

	hbuttonbox4 = gtk_hbutton_box_new();
	gtk_widget_show(hbuttonbox4);
	gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox4, FALSE, FALSE, 0);

	button3 = gtk_button_new_with_label(_("Close"));
	gtk_widget_show(button3);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), button3);
	gtkut_widget_set_can_default(button3, TRUE);

	button4 = gtk_button_new_with_label(_("Save..."));
	gtk_widget_show(button4);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), button4);
	gtkut_widget_set_can_default(button4, TRUE);

	button5 = gtk_button_new_with_label(_("Create bug report"));
	gtk_widget_show(button5);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), button5);
	gtkut_widget_set_can_default(button5, TRUE);
	
	g_signal_connect(G_OBJECT(window1), "delete_event",
			 G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(G_OBJECT(button3),   "clicked",
			 G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(G_OBJECT(button4), "clicked",
			 G_CALLBACK(crash_save_crash_log), crash_report);
	g_signal_connect(G_OBJECT(button5), "clicked",
			 G_CALLBACK(crash_create_bug_report), NULL);

	MANAGE_WINDOW_SIGNALS_CONNECT(window1);

	gtk_widget_show(window1);

	gtk_main();
	return window1;
}
示例#26
0
文件: front.c 项目: 5263/spacenav
static void layout(void)
{
	int i;
	GtkWidget *w;
	GtkWidget *vbox, *bbox, *tbl, *frm;

	vbox = create_vbox(win);

	frm = gtk_frame_new("invert axis");
	add_child(vbox, frm);

	tbl = gtk_table_new(3, 4, FALSE);
	add_child(frm, tbl);

	gtk_table_set_row_spacings(GTK_TABLE(tbl), 2);
	gtk_table_set_col_spacings(GTK_TABLE(tbl), 2);

	gtk_table_attach_defaults(GTK_TABLE(tbl), gtk_label_new("X"), 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(tbl), gtk_label_new("Y"), 2, 3, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(tbl), gtk_label_new("Z"), 3, 4, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(tbl), gtk_label_new("translation"), 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(tbl), gtk_label_new("rotation"), 0, 1, 2, 3);

	for(i=0; i<6; i++) {
		int x = i % 3 + 1;
		int y = i / 3 + 1;
		w = gtk_check_button_new();
		gtk_table_attach_defaults(GTK_TABLE(tbl), w, x, x + 1, y, y + 1);
		g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(chk_handler), (void*)i);
	}

	/*hbox = create_hbox(vbox);*/
	frm = gtk_frame_new("sensitivity");
	add_child(vbox, frm);

	w = gtk_hscale_new_with_range(0.0, 4.0, 0.1);
	gtk_range_set_update_policy(GTK_RANGE(w), GTK_UPDATE_DELAYED);
	gtk_range_set_value(GTK_RANGE(w), cfg.sensitivity);
	gtk_scale_set_value_pos(GTK_SCALE(w), GTK_POS_RIGHT);
	g_signal_connect(G_OBJECT(w), "value_changed", G_CALLBACK(slider_handler), 0);
	add_child(frm, w);

	frm = gtk_frame_new("X11 magellan API");
	add_child(vbox, frm);

	bbox = gtk_hbutton_box_new();
	add_child(frm, bbox);

	w = gtk_button_new_with_label("start");
	g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(bn_handler), (void*)0);
	add_child(bbox, w);

	w = gtk_button_new_with_label("stop");
	g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(bn_handler), (void*)1);
	add_child(bbox, w);

	w = gtk_button_new_with_label("check");
	g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(bn_handler), (void*)2);
	add_child(bbox, w);

	/*
	w = gtk_check_button_new_with_label("enable X11 magellan API");
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), query_x11());
	g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(chk_handler), (void*)10);
	add_child(frm, w);
	*/

	frm = gtk_frame_new("misc");
	add_child(vbox, frm);

	bbox = gtk_hbutton_box_new();
	add_child(frm, bbox);

	w = gtk_button_new_with_label("ping daemon");
	g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(bn_handler), (void*)3);
	add_child(bbox, w);

	bbox = gtk_hbutton_box_new();
	add_child(vbox, bbox);

	/*w = gtk_button_new_from_stock(GTK_STOCK_APPLY);
	g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(bn_handler), 0);
	add_child(bbox, w);*/

	w = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
	g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(gtk_main_quit), 0);
	add_child(bbox, w);
}
示例#27
0
static int PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
{
	GtkWidget *window;
	GtkWidget *vbox = nullptr;
	GtkWidget *hbox = nullptr;
	GtkWidget *bbox = nullptr;
	GtkWidget *widget;
	GtkWidget *tree;
	GtkWidget *check;
	GtkListStore *store;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;
	GtkTreeIter iter, defiter;
	int close_style = 0;
	int i;
	char caption[100];

	// Create the dialog window.
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	mysnprintf(caption, countof(caption), GAMESIG " %s: Select an IWAD to use", GetVersionString());
	gtk_window_set_title (GTK_WINDOW(window), caption);
	gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_gravity (GTK_WINDOW(window), GDK_GRAVITY_CENTER);
	gtk_container_set_border_width (GTK_CONTAINER(window), 10);
	g_signal_connect (window, "delete_event", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect (window, "key_press_event", G_CALLBACK(CheckEscape), NULL);

	// Create the vbox container.
	if (gtk_box_new) // Gtk3
		vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
	else if (gtk_vbox_new) // Gtk2
		vbox = gtk_vbox_new (FALSE, 10);

	gtk_container_add (GTK_CONTAINER(window), vbox);

	// Create the top label.
	widget = gtk_label_new (GAMENAME " found more than one IWAD\nSelect from the list below to determine which one to use:");
	gtk_box_pack_start (GTK_BOX(vbox), widget, false, false, 0);

	if (gtk_widget_set_halign && gtk_widget_set_valign) // Gtk3
	{
		gtk_widget_set_halign (widget, GTK_ALIGN_START);
		gtk_widget_set_valign (widget, GTK_ALIGN_START);
	}
	else if (gtk_misc_set_alignment && gtk_misc_get_type) // Gtk2
		gtk_misc_set_alignment (GTK_MISC(widget), 0, 0);

	// Create a list store with all the found IWADs.
	store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
	for (i = 0; i < numwads; ++i)
	{
		const char *filepart = strrchr (wads[i].Path, '/');
		if (filepart == NULL)
			filepart = wads[i].Path;
		else
			filepart++;
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
			0, filepart,
			1, wads[i].Name.GetChars(),
			2, i,
			-1);
		if (i == defaultiwad)
		{
			defiter = iter;
		}
	}

	// Create the tree view control to show the list.
	tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("IWAD", renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Game", renderer, "text", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(tree), true, true, 0);
	g_signal_connect(G_OBJECT(tree), "button_press_event", G_CALLBACK(DoubleClickChecker), &close_style);
	g_signal_connect(G_OBJECT(tree), "key_press_event", G_CALLBACK(AllowDefault), window);

	// Select the default IWAD.
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
	gtk_tree_selection_select_iter (selection, &defiter);

	// Create the hbox for the bottom row.
	if (gtk_box_new) // Gtk3
		hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	else if (gtk_hbox_new) // Gtk2
		hbox = gtk_hbox_new (FALSE, 0);

	gtk_box_pack_end (GTK_BOX(vbox), hbox, false, false, 0);

	// Create the "Don't ask" checkbox.
	check = gtk_check_button_new_with_label ("Don't ask me this again");
	gtk_box_pack_start (GTK_BOX(hbox), check, false, false, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check), !showwin);

	// Create the OK/Cancel button box.
	if (gtk_button_box_new) // Gtk3
		bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	else if (gtk_hbutton_box_new) // Gtk2
		bbox = gtk_hbutton_box_new ();

	gtk_button_box_set_layout (GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX(bbox), 10);
	gtk_box_pack_end (GTK_BOX(hbox), bbox, false, false, 0);

	// Create the OK button.
	widget = gtk_button_new_with_label ("OK");

	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);

	gtk_widget_set_can_default (widget, true);

	gtk_widget_grab_default (widget);
	g_signal_connect (widget, "clicked", G_CALLBACK(ClickedOK), &close_style);
	g_signal_connect (widget, "activate", G_CALLBACK(ClickedOK), &close_style);

	// Create the cancel button.
	widget = gtk_button_new_with_label ("Cancel");

	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);
	g_signal_connect (widget, "clicked", G_CALLBACK(gtk_main_quit), &window);

	// Finally we can show everything.
	gtk_widget_show_all (window);

	gtk_main ();

	if (close_style == 1)
	{
		GtkTreeModel *model;
		GValue value = { 0, { {0} } };

		// Find out which IWAD was selected.
		gtk_tree_selection_get_selected (selection, &model, &iter);
		gtk_tree_model_get_value (GTK_TREE_MODEL(model), &iter, 2, &value);
		i = g_value_get_int (&value);
		g_value_unset (&value);

		// Set state of queryiwad based on the checkbox.
		queryiwad = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check));
	}
	else
	{
		i = -1;
	}

	if (GTK_IS_WINDOW(window))
	{
		gtk_widget_destroy (window);
		// If we don't do this, then the X window might not actually disappear.
		while (g_main_context_iteration (NULL, FALSE)) {}
	}

	return i;
}
int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *panel;
  GtkWidget *label1;
  GtkWidget *label1aligned;
  GtkWidget *label2;
  GtkWidget *label2aligned;
  GtkWidget *button;
  GtkWidget *buttonbar;

  /* Initializations.  */

  gnome_init (PACKAGE, VERSION, argc, argv);
  textdomain ("hello-c-gnome");
  bindtextdomain ("hello-c-gnome", LOCALEDIR);

  /* Create the GUI elements.  */

  window = gnome_app_new ("hello-c-gnome", "Hello example");
  gtk_widget_realize (window);
  gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                      GTK_SIGNAL_FUNC (quit_callback), NULL);

  label1 = gtk_label_new (_("Hello, world!"));

  label1aligned = gtk_alignment_new (0.0, 0.5, 0, 0);
  gtk_container_add (GTK_CONTAINER (label1aligned), label1);

  label2 = gtk_label_new (g_strdup_printf (_("This program is running as process number %d."), getpid ()));

  label2aligned = gtk_alignment_new (0.0, 0.5, 0, 0);
  gtk_container_add (GTK_CONTAINER (label2aligned), label2);

  button = gtk_button_new_with_label ("OK");
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
                      GTK_SIGNAL_FUNC (quit_callback), NULL);

  buttonbar = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbar), GTK_BUTTONBOX_END);
  gtk_box_pack_start_defaults (GTK_BOX (buttonbar), button);

  panel = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
  gtk_box_pack_start_defaults (GTK_BOX (panel), label1aligned);
  gtk_box_pack_start_defaults (GTK_BOX (panel), label2aligned);
  gtk_box_pack_start_defaults (GTK_BOX (panel), buttonbar);

  gnome_app_set_contents (GNOME_APP (window), panel);

  /* Make the GUI elements visible.  */

  gtk_widget_show (label1);
  gtk_widget_show (label1aligned);
  gtk_widget_show (label2);
  gtk_widget_show (label2aligned);
  gtk_widget_show (button);
  gtk_widget_show (buttonbar);
  gtk_widget_show (panel);
  gtk_widget_show (window);

  /* Start the event loop.  */

  gtk_main ();

  return 0;
}
示例#29
0
文件: devicebox.c 项目: Aced14/pcsx2
void DeviceBoxDisplay()
{
	GtkWidget *item;
	GtkWidget *hbox1;
	GtkWidget *vbox1;
	int nameptr;

	devicebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(devicebox.window), 5);
	gtk_window_set_title(GTK_WINDOW(devicebox.window), "CDVDisoEFP ISO Creation");
	gtk_window_set_position(GTK_WINDOW(devicebox.window), GTK_WIN_POS_CENTER);

	g_signal_connect(G_OBJECT(devicebox.window), "delete_event",
	                 G_CALLBACK(DeviceBoxCancelEvent), NULL);

	vbox1 = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(devicebox.window), vbox1);
	gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
	gtk_widget_show(vbox1);

	hbox1 = gtk_hbox_new(FALSE, 10);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
	gtk_widget_show(hbox1);

	item = gtk_label_new("Source CD/DVD Device:");
	gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
	gtk_widget_show(item);
	item = NULL;

	devicebox.device = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.device, TRUE, TRUE, 0);
	gtk_widget_show(devicebox.device);
	g_signal_connect(G_OBJECT(devicebox.device), "changed",
	                 G_CALLBACK(DeviceBoxDeviceEvent), NULL);
	hbox1 = NULL;

	devicebox.devicedesc = gtk_label_new("Device Type: ---");
	gtk_box_pack_start(GTK_BOX(vbox1), devicebox.devicedesc, FALSE, FALSE, 0);
	gtk_widget_show(devicebox.devicedesc);

	item = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
	gtk_widget_show(item);
	item = NULL;

	hbox1 = gtk_hbox_new(FALSE, 10);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
	gtk_widget_show(hbox1);

	item = gtk_label_new("Iso File:");
	gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
	gtk_widget_show(item);
	item = NULL;

	devicebox.file = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.file, TRUE, TRUE, 0);
	gtk_widget_show(devicebox.file);
	g_signal_connect(G_OBJECT(devicebox.file), "changed",
	                 G_CALLBACK(DeviceBoxFileEvent), NULL);

	devicebox.selectbutton = gtk_button_new_with_label("Browse");
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.selectbutton, FALSE, FALSE, 0);
	gtk_widget_show(devicebox.selectbutton);
	g_signal_connect(G_OBJECT(devicebox.selectbutton), "clicked",
	                 G_CALLBACK(DeviceBoxBrowseEvent), NULL);
	hbox1 = NULL;

	devicebox.filedesc = gtk_label_new("File Type: ---");
	gtk_box_pack_start(GTK_BOX(vbox1), devicebox.filedesc, FALSE, FALSE, 0);
	gtk_widget_show(devicebox.filedesc);

	hbox1 = gtk_hbox_new(FALSE, 10);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
	gtk_widget_show(hbox1);

	item = gtk_label_new("New File Compression:");
	gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
	gtk_widget_show(item);
	item = NULL;

	devicebox.compress = gtk_combo_box_new_text();
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.compress, FALSE, FALSE, 0);
	nameptr = 0;
	while (compressnames[nameptr] != NULL)
	{
		gtk_combo_box_append_text(GTK_COMBO_BOX(devicebox.compress),
		                          compressnames[nameptr]);
		nameptr++;
	} // ENDWHILE- loading compression types into combo box
	gtk_combo_box_set_active(GTK_COMBO_BOX(devicebox.compress), 0); // Temp Line
	gtk_widget_show(devicebox.compress);
	hbox1 = NULL;

	hbox1 = gtk_hbox_new(FALSE, 10);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
	gtk_widget_show(hbox1);

	item = gtk_label_new("Multiple Files (all under 2 GB):");
	gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
	gtk_widget_show(item);
	item = NULL;

	devicebox.multi = gtk_check_button_new();
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.multi, FALSE, FALSE, 0);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(devicebox.multi), FALSE);
	gtk_widget_show(devicebox.multi);
	hbox1 = NULL;

	hbox1 = gtk_hbutton_box_new();
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
	gtk_widget_show(hbox1);

	devicebox.okbutton = gtk_button_new_with_label("Make File");
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.okbutton, TRUE, TRUE, 0);
	gtk_widget_show(devicebox.okbutton);
	g_signal_connect(G_OBJECT(devicebox.okbutton), "clicked",
	                 G_CALLBACK(DeviceBoxOKEvent), NULL);

	devicebox.cancelbutton = gtk_button_new_with_label("Cancel");
	gtk_box_pack_start(GTK_BOX(hbox1), devicebox.cancelbutton, TRUE, TRUE, 0);
	gtk_widget_show(devicebox.cancelbutton);
	g_signal_connect(G_OBJECT(devicebox.cancelbutton), "clicked",
	                 G_CALLBACK(DeviceBoxCancelEvent), NULL);
	hbox1 = NULL;
	vbox1 = NULL;

	// Device text not set until now to get the correct description.
	gtk_entry_set_text(GTK_ENTRY(devicebox.device), conf.devicename);

	DeviceInit(); // Initialize device access
} // END DeviceBoxDisplay()
void FenTrans_init( FenTrans* ft, Scene* scene )
{
    int i = 0;
    ft->unGroupeEstSelectionner = FALSE;

    ft->fenetre = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    ft->scene = scene;

    gtk_window_set_position( GTK_WINDOW( ft->fenetre ), GTK_WIN_POS_CENTER );
    gtk_window_set_modal( GTK_WINDOW( ft->fenetre ), TRUE );
    gtk_window_set_title( GTK_WINDOW( ft->fenetre ), "Fenetre Trasnformation" );


    for( i = 0; i < scene->nbGroupe; i++ )
    {
        Groupe* groupe = g_array_index( scene->tGroupe, Groupe*, i );

        if( gtk_tree_selection_iter_is_selected( scene->treeSelection, groupe->iter ) )
        {
            ft->unGroupeEstSelectionner = TRUE;
            ft->groupeSelectionne = groupe;
        }
    }

    GtkWidget* hbox = gtk_hbutton_box_new( );
    gtk_button_box_set_layout( GTK_BUTTON_BOX( hbox ), GTK_BUTTONBOX_END );

    ft->radio1 = gtk_radio_button_new_with_label( NULL, "Rotation" );
    ft->radio2 = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON( ft->radio1 ), "Translation" );

    gtk_container_add( GTK_CONTAINER( hbox ), ft->radio1 );
    gtk_container_add( GTK_CONTAINER( hbox ), ft->radio2 );

    if( !ft->unGroupeEstSelectionner )
    {
        ft->radio3 = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON( ft->radio1 ), "Homothétie" );
        gtk_container_add( GTK_CONTAINER( hbox ), ft->radio3 );
    }
    else
    {
        ft->radio4 = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON( ft->radio1 ), "Translation sur objet fils" );
        gtk_container_add( GTK_CONTAINER( hbox ), ft->radio4 );
        ft->radio5 = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON( ft->radio1 ), "Rotation sur objet fils" );
        gtk_container_add( GTK_CONTAINER( hbox ), ft->radio5 );
    }

    GtkWidget* barreParam = gtk_hbutton_box_new( );
    gtk_button_box_set_layout( GTK_BUTTON_BOX( barreParam ), GTK_BUTTONBOX_END );

    ft->entry1 = gtk_entry_new();
    ft->entry2 = gtk_entry_new();
    ft->entry3 = gtk_entry_new();

    GtkWidget* text1 = gtk_label_new("X : ");
    GtkWidget* text2 = gtk_label_new("Y : ");
    GtkWidget* text3 = gtk_label_new("Z : ");

    gtk_container_add( GTK_CONTAINER( barreParam ), text1 );
    gtk_container_add( GTK_CONTAINER( barreParam ), ft->entry1 );
    gtk_container_add( GTK_CONTAINER( barreParam ), text2 );
    gtk_container_add( GTK_CONTAINER( barreParam ), ft->entry2 );
    gtk_container_add( GTK_CONTAINER( barreParam ), text3 );
    gtk_container_add( GTK_CONTAINER( barreParam ), ft->entry3 );

    GtkWidget* layout = gtk_vbox_new( 5, TRUE );
//*************************************************************
    GtkWidget* boutonOk = gtk_button_new_with_label("OK");
    GtkWidget* boutonAnnuler = gtk_button_new_with_label("Annuler");

    GtkWidget* barreBouton = gtk_hbutton_box_new();
    gtk_button_box_set_layout( GTK_BUTTON_BOX( barreBouton ), GTK_BUTTONBOX_END );

    gtk_container_add( GTK_CONTAINER( barreBouton ), boutonOk );
    gtk_container_add( GTK_CONTAINER( barreBouton ), boutonAnnuler );
//************************************************************

    gtk_container_add( GTK_CONTAINER( layout ), hbox );
    gtk_container_add( GTK_CONTAINER( layout ), barreParam );
    gtk_container_add( GTK_CONTAINER( layout ), barreBouton );
    gtk_container_add( GTK_CONTAINER( ft->fenetre ), layout );

    gtk_widget_show_all( ft->fenetre );

    g_signal_connect_object( G_OBJECT( boutonAnnuler ), "clicked", G_CALLBACK( gtk_widget_destroy ), ft->fenetre, G_CONNECT_SWAPPED );
    g_signal_connect( G_OBJECT( boutonOk ), "clicked", G_CALLBACK( FenTrans_validation ), ft );
}