PpOptionsDialog *
pp_options_dialog_new (GtkWindow            *parent,
                       UserResponseCallback  user_callback,
                       gpointer              user_data,
                       gchar                *printer_name,
                       gboolean              sensitive)
{
  PpOptionsDialog *dialog;
  GError          *error = NULL;
  gchar           *objects[] = { "options-dialog", NULL };
  guint            builder_result;

  dialog = g_new0 (PpOptionsDialog, 1);

  dialog->builder = gtk_builder_new ();
  dialog->parent = GTK_WIDGET (parent);

  builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
                                                          "/org/gnome/control-center/printers/options-dialog.ui",
                                                          objects, &error);

  if (builder_result == 0)
    {
      g_warning ("Could not load ui: %s", error->message);
      g_error_free (error);
      return NULL;
    }

  dialog->dialog = (GtkWidget *) gtk_builder_get_object (dialog->builder, "options-dialog");
  gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (parent));

  dialog->user_callback = user_callback;
  dialog->user_data = user_data;

  dialog->printer_name = g_strdup (printer_name);

  dialog->ppd_filename = NULL;
  dialog->ppd_filename_set = FALSE;

  dialog->destination = NULL;
  dialog->destination_set = FALSE;

  dialog->ipp_attributes = NULL;
  dialog->ipp_attributes_set = FALSE;

  dialog->response = GTK_RESPONSE_NONE;

  dialog->sensitive = sensitive;

  /* connect signals */
  g_signal_connect (dialog->dialog, "response", G_CALLBACK (options_dialog_response_cb), dialog);
  g_signal_connect (dialog->dialog, "size-allocate", G_CALLBACK (update_alignment_padding), dialog);

  gtk_window_set_title (GTK_WINDOW (dialog->dialog), printer_name);

  gtk_widget_show_all (GTK_WIDGET (dialog->dialog));

  dialog->populating_dialog = TRUE;
  populate_options (dialog);

  return dialog;
}
예제 #2
0
LRESULT CALLBACK options_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	static HWND grippy=0;
	switch(msg)
	{
	case WM_INITDIALOG:
		grippy=create_grippy(hwnd);
		init_options_win_anchor(hwnd);
		restore_options_rel_pos(hwnd);
		SendDlgItemMessage(hwnd,IDC_MATCH_PREFIX_LEN,EM_LIMITTEXT,4,0);
		populate_options(hwnd);
		return 0;
	case WM_DESTROY:
		save_options_rel_pos(hwnd);
		break;
	case WM_SIZE:
		grippy_move(hwnd,grippy);
		resize_options(hwnd);
		InvalidateRect(hwnd,NULL,TRUE);
		break;
	case WM_DRAWITEM:
		break;
	case WM_HELP:
		show_options_help(hwnd);
		return TRUE;
		break;
	case WM_COMMAND:
		switch(LOWORD(wparam)){
		case IDC_SELECT_OPEN:
			if(HIWORD(wparam)==CBN_SELENDOK)
				populate_caption_open(hwnd);
			break;
		case IDC_COMBO_FONT:
			if(HIWORD(wparam)==CBN_SELENDOK){
				int font;
				char str[80]={0};
				GetDlgItemText(hwnd,IDC_COMBO_FONT,str,sizeof(str));
				font=fontname_to_int(str);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_SEARCH,WM_SETFONT,GetStockObject(font),0);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_REPLACE,WM_SETFONT,GetStockObject(font),0);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_PATH,WM_SETFONT,GetStockObject(font),0);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_MASK,WM_SETFONT,GetStockObject(font),0);
			}
			break;
		case IDC_LISTBOX_FONT:
			if(HIWORD(wparam)==CBN_SELENDOK){
				int font;
				char str[80]={0};
				GetDlgItemText(hwnd,IDC_LISTBOX_FONT,str,sizeof(str));
				font=fontname_to_int(str);
				SendDlgItemMessage(GetParent(hwnd),IDC_LIST1,WM_SETFONT,GetStockObject(font),0);
				reset_line_width();
				InvalidateRect(GetDlgItem(GetParent(hwnd),IDC_LIST1),NULL,TRUE);
			}
			break;
		case IDC_OPEN_INI:
			open_ini(hwnd,GetKeyState(VK_CONTROL)&0x8000);
			break;
		case IDC_APPLY:
			save_options(hwnd);
			break;
		case IDOK:
			save_options(hwnd);
			EndDialog(hwnd,TRUE);
			return 0;
		case IDCANCEL:
			save_select_open(hwnd);
			EndDialog(hwnd,0);
			return 0;
		}
		break;
	}
	return 0;
}