示例#1
0
void
cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical)
{
  CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);

  priv->vertical = vertical;
  if (!priv->vertical && priv->n_items)
    gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
  else
    gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), 1);

  gtk_widget_set_hexpand (GTK_WIDGET (thumb_view), !vertical);
  gtk_widget_set_vexpand (GTK_WIDGET (thumb_view), vertical);
}
static void
gd_thumb_nav_constructed (GObject *object)
{
    GdThumbNav *self = GD_THUMB_NAV (object);
    GdThumbNavPrivate *priv = self->priv;

    G_OBJECT_CLASS (gd_thumb_nav_parent_class)->constructed (object);

    if (priv->thumbview != NULL) {
        gtk_container_add (GTK_CONTAINER (priv->sw), priv->thumbview);
        gtk_widget_show_all (priv->sw);

        gtk_icon_view_set_columns (GTK_ICON_VIEW (priv->thumbview),
                                   G_MAXINT);

        gtk_widget_set_size_request (priv->thumbview, -1, -1);
        gd_sidebar_thumbnails_set_item_height (GD_SIDEBAR_THUMBNAILS (priv->thumbview),
                                               115);

        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_NEVER);
    }

    gd_thumb_nav_set_show_buttons (self, priv->show_buttons);
}
static void
hcp_app_view_set_n_columns  (GtkWidget      *widget,
                             gpointer        data)
{
    gint n_columns;
/* 4px is the HCP_GRID_X_PADDING */
#define PORTRAIT_WIDTH   480      - 3 * HILDON_MARGIN_DOUBLE
#define LANDSCAPE_WIDTH (800 / 2) - 2 * HILDON_MARGIN_DOUBLE

    if (! HCP_IS_GRID (widget))
        return;

    n_columns = GPOINTER_TO_INT (data);

/*
 * g_debug ("WIDTH = %d", (n_columns == 1) ? PORTRAIT_WIDTH : LANDSCAPE_WIDTH);
 */

    /* grid view, set proper no. of colunms */
    gtk_icon_view_set_columns (GTK_ICON_VIEW (widget), n_columns);
    gtk_icon_view_set_item_width (GTK_ICON_VIEW (widget),
                                  (n_columns == 1) ? 
                                   PORTRAIT_WIDTH : 
                                   LANDSCAPE_WIDTH);
    hcp_grid_refresh_icons (HCP_GRID (widget));
}
示例#4
0
static void
cheese_thumb_view_constructed (GObject *object)
{
  CheeseThumbView *thumb_view = CHEESE_THUMB_VIEW (object);
  CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);
  
  G_OBJECT_CLASS (cheese_thumb_view_parent_class)->constructed (object);

  gtk_icon_view_set_model (GTK_ICON_VIEW (thumb_view), GTK_TREE_MODEL (priv->store));

  gtk_widget_set_size_request (GTK_WIDGET (thumb_view),
                               THUMB_VIEW_MINIMUM_WIDTH,
                               THUMB_VIEW_MINIMUM_HEIGHT);

  gtk_icon_view_set_margin (GTK_ICON_VIEW (thumb_view), 0);
  gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (thumb_view), 0);
  gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (thumb_view), 0);

  gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (thumb_view), 0);

  gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), -1);

  gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (thumb_view), GDK_BUTTON1_MASK,
                                          target_table, G_N_ELEMENTS (target_table),
                                          GDK_ACTION_COPY);
  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (thumb_view), GTK_SELECTION_MULTIPLE);

  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->store),
                                        THUMBNAIL_BASENAME_URL_COLUMN, GTK_SORT_ASCENDING);
                                        
  cheese_thumb_view_fill (thumb_view);
  cheese_thumb_view_set_vertical (thumb_view, FALSE);
}
示例#5
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkIconView_gtk_1icon_1view_1set_1columns
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jint _columns
)
{
	GtkIconView* self;
	gint columns;

	// convert parameter self
	self = (GtkIconView*) _self;

	// convert parameter columns
	columns = (gint) _columns;

	// call function
	gtk_icon_view_set_columns(self, columns);

	// cleanup parameter self

	// cleanup parameter columns
}
示例#6
0
static void
gwy_app_file_chooser_add_preview(GwyAppFileChooser *chooser)
{
    GtkListStore *store;
    GtkIconView *preview;
    GtkCellLayout *layout;
    GtkCellRenderer *renderer;
    GtkWidget *scwin;
    gint w;

    if (gtk_check_version(2, 8, 0)) {
        g_warning("File previews require Gtk+ 2.8");
        return;
    }

    scwin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scwin),
                                   GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    store = gtk_list_store_new(2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
    chooser->preview = gtk_icon_view_new_with_model(GTK_TREE_MODEL(store));
    g_object_unref(store);
    preview = GTK_ICON_VIEW(chooser->preview);
    layout = GTK_CELL_LAYOUT(preview);
    gtk_icon_view_set_columns(preview, 1);

    renderer = gtk_cell_renderer_pixbuf_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(preview), renderer, FALSE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(preview), renderer,
                                  "pixbuf", COLUMN_PIXBUF);

    renderer = gtk_cell_renderer_text_new();
    g_object_set(renderer,
                 "wrap-mode", PANGO_WRAP_WORD_CHAR,
                 "ellipsize", PANGO_ELLIPSIZE_END,
                 "ellipsize-set", TRUE,
                 NULL);
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(preview), renderer, FALSE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(preview), renderer,
                                  "markup", COLUMN_FILEINFO);
    chooser->renderer_fileinfo = G_OBJECT(renderer);

    gtk_icon_view_set_selection_mode(preview, GTK_SELECTION_NONE);
    gtk_icon_view_set_item_width(preview, TMS_NORMAL_THUMB_SIZE);
    w = TMS_NORMAL_THUMB_SIZE + 2*gtk_icon_view_get_margin(preview);
    gtk_widget_set_size_request(chooser->preview, w, -1);
    gtk_container_add(GTK_CONTAINER(scwin), chooser->preview);
    gtk_widget_show(chooser->preview);
    gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(chooser), scwin);
    g_signal_connect(chooser, "update-preview",
                     G_CALLBACK(gwy_app_file_chooser_update_preview), NULL);
}
示例#7
0
static void
cheese_thumb_view_row_inserted_cb (GtkTreeModel    *tree_model,
                                   GtkTreePath     *path,
                                   GtkTreeIter     *iter,
                                   CheeseThumbView *thumb_view)
{
  CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);

  priv->n_items++;
  if (!priv->vertical)
    gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), priv->n_items);
  else
    gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
}
示例#8
0
static void
cheese_thumb_view_row_deleted_cb (GtkTreeModel    *tree_model,
                                  GtkTreePath     *path,
                                  CheeseThumbView *thumb_view)
{
  CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view);

  priv->n_items--;
  if (priv->n_items == 0)
    gtk_widget_set_size_request (GTK_WIDGET (thumb_view),
                                 THUMB_VIEW_MINIMUM_WIDTH,
                                 THUMB_VIEW_MINIMUM_HEIGHT);
  else if (!priv->vertical)
    gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), priv->n_items);
}
示例#9
0
static void
gwy_app_file_chooser_add_preview(GwyAppFileChooser *chooser)
{
    GwyContainer *settings;
    GtkListStore *store;
    GtkIconView *preview;
    GtkCellLayout *layout;
    GtkCellRenderer *renderer;
    GtkTooltips *tips;
    GtkWidget *scwin, *vbox, *button, *toolbar;
    gboolean setting;
    gint w;

    scwin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scwin),
                                   GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    store = gtk_list_store_new(2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
    chooser->preview = gtk_icon_view_new_with_model(GTK_TREE_MODEL(store));
    g_object_unref(store);
    preview = GTK_ICON_VIEW(chooser->preview);
    layout = GTK_CELL_LAYOUT(preview);
    gtk_icon_view_set_columns(preview, 1);

    renderer = gtk_cell_renderer_pixbuf_new();
    gtk_cell_layout_pack_start(layout, renderer, FALSE);
    gtk_cell_layout_add_attribute(layout, renderer, "pixbuf", COLUMN_PIXBUF);

    renderer = gtk_cell_renderer_text_new();
    g_object_set(renderer,
                 "wrap-mode", PANGO_WRAP_WORD_CHAR,
                 "ellipsize", PANGO_ELLIPSIZE_END,
                 "ellipsize-set", TRUE,
                 NULL);
    gtk_cell_layout_pack_start(layout, renderer, FALSE);
    gtk_cell_layout_add_attribute(layout, renderer, "markup", COLUMN_FILEINFO);
    chooser->renderer_fileinfo = G_OBJECT(renderer);

    gtk_icon_view_set_selection_mode(preview, GTK_SELECTION_NONE);
    /* In Gtk+ 2.14 and older, things work.  2.16 adds some padding that
     * breaks everything.  And this padding together with the usual margin
     * meaks too much white space so we have to get rid of the margin in 2.16+.
     */
    if (gtk_major_version == 2 && gtk_minor_version <= 14) {
        gtk_icon_view_set_item_width(preview, TMS_NORMAL_THUMB_SIZE);
        w = TMS_NORMAL_THUMB_SIZE + 2*gtk_icon_view_get_margin(preview);
    }
    else {
        gtk_icon_view_set_margin(preview, 0);
        gtk_icon_view_set_item_width(preview, PADDED_THUMBNAIL_SIZE);
        w = PADDED_THUMBNAIL_SIZE;
    }
    gtk_widget_set_size_request(chooser->preview, w, -1);
    gtk_container_add(GTK_CONTAINER(scwin), chooser->preview);

    vbox = gtk_vbox_new(FALSE, 2);

    chooser->preview_filename = gtk_label_new(NULL);
    gtk_misc_set_alignment(GTK_MISC(chooser->preview_filename), 0.0, 0.5);
    gtk_label_set_single_line_mode(GTK_LABEL(chooser->preview_filename), TRUE);
    gtk_label_set_ellipsize(GTK_LABEL(chooser->preview_filename),
                            PANGO_ELLIPSIZE_END);
    gtk_box_pack_start(GTK_BOX(vbox), chooser->preview_filename,
                       FALSE, FALSE, 0);

    chooser->preview_type = gtk_label_new(NULL);
    gtk_misc_set_alignment(GTK_MISC(chooser->preview_type), 0.0, 0.5);
    gtk_label_set_single_line_mode(GTK_LABEL(chooser->preview_type), TRUE);
    gtk_label_set_ellipsize(GTK_LABEL(chooser->preview_type),
                            PANGO_ELLIPSIZE_END);
    gtk_box_pack_start(GTK_BOX(vbox), chooser->preview_type,
                       FALSE, FALSE, 0);

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

    toolbar = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);

    settings = gwy_app_settings_get();
    tips = gwy_app_get_tooltips();

    setting = FALSE;
    gwy_container_gis_boolean_by_name(settings, "/app/file/preview/plane-level",
                                      &setting);
    button = gtk_toggle_button_new();
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), setting);
    GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    gtk_tooltips_set_tip(tips, button,
                         _("Plane-level previewed data"), NULL);
    gtk_container_add(GTK_CONTAINER(button),
                      gtk_image_new_from_stock(GWY_STOCK_LEVEL,
                              GTK_ICON_SIZE_SMALL_TOOLBAR));
    gtk_box_pack_start(GTK_BOX(toolbar), button, FALSE, FALSE, 0);
    g_signal_connect_swapped(button, "toggled",
                             G_CALLBACK(plane_level_changed), chooser);

    setting = FALSE;
    gwy_container_gis_boolean_by_name(settings, "/app/file/preview/row-level",
                                      &setting);
    button = gtk_toggle_button_new();
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), setting);
    GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    gtk_tooltips_set_tip(tips, button,
                         _("Row-level previewed data"), NULL);
    gtk_container_add(GTK_CONTAINER(button),
                      gtk_image_new_from_stock(GWY_STOCK_LINE_LEVEL,
                              GTK_ICON_SIZE_SMALL_TOOLBAR));
    gtk_box_pack_start(GTK_BOX(toolbar), button, FALSE, FALSE, 0);
    g_signal_connect_swapped(button, "toggled",
                             G_CALLBACK(row_level_changed), chooser);

    gtk_widget_show_all(vbox);

    gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(chooser), vbox);
    gtk_file_chooser_set_use_preview_label(GTK_FILE_CHOOSER(chooser), FALSE);
    g_signal_connect(chooser, "update-preview",
                     G_CALLBACK(gwy_app_file_chooser_update_preview), NULL);

    toolbar = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
}
示例#10
0
文件: iconview_edit.c 项目: 3v1n0/gtk
GtkWidget *
do_iconview_edit (GtkWidget *do_widget)
{
  if (!window)
    {
      GtkWidget *icon_view;
      GtkListStore *store;
      GtkCellRenderer *renderer;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Editing and Drag-and-Drop");

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      store = create_store ();
      fill_store (store);

      icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
      g_object_unref (store);

      gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
                                        GTK_SELECTION_SINGLE);
      gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (icon_view),
                                          GTK_ORIENTATION_HORIZONTAL);
      gtk_icon_view_set_columns (GTK_ICON_VIEW (icon_view), 2);
      gtk_icon_view_set_reorderable (GTK_ICON_VIEW (icon_view), TRUE);

      renderer = gtk_cell_renderer_pixbuf_new ();
      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view),
                                  renderer, TRUE);
      gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (icon_view),
                                          renderer,
                                          set_cell_color,
                                          NULL, NULL);

      renderer = gtk_cell_renderer_text_new ();
      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view),
                                  renderer, TRUE);
      g_object_set (renderer, "editable", TRUE, NULL);
      g_signal_connect (renderer, "edited", G_CALLBACK (edited), icon_view);
      gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view),
                                      renderer,
                                      "text", COL_TEXT,
                                      NULL);

      gtk_container_add (GTK_CONTAINER (window), icon_view);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
示例#11
0
static gboolean
remap_dialog (gint32  image_ID,
              guchar *map)
{
  GtkWidget       *dialog;
  GtkWidget       *vbox;
  GtkWidget       *box;
  GtkWidget       *iconview;
  GtkListStore    *store;
  GtkCellRenderer *renderer;
  GtkTreeIter      iter;
  guchar          *cmap;
  gint             ncols, i;
  gboolean         valid;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Rearrange Colormap"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC_REMAP,

                            GIMP_STOCK_RESET, RESPONSE_RESET,
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           RESPONSE_RESET,
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      vbox, TRUE, TRUE, 0);

  cmap = gimp_image_get_colormap (image_ID, &ncols);

  g_return_val_if_fail ((ncols > 0) && (ncols <= 256), FALSE);

  store = gtk_list_store_new (NUM_COLS,
                              G_TYPE_INT, G_TYPE_STRING, GIMP_TYPE_RGB,
                              G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE);

  for (i = 0; i < ncols; i++)
    {
      GimpRGB  rgb;
      GimpHSV  hsv;
      gint     index = map[i];
      gchar   *text  = g_strdup_printf ("%d", index);

      gimp_rgb_set_uchar (&rgb,
                          cmap[index * 3],
                          cmap[index * 3 + 1],
                          cmap[index * 3 + 2]);
      gimp_rgb_to_hsv (&rgb, &hsv);

      reverse_order[i] = ncols - i - 1;

      gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter,
                          COLOR_INDEX,      index,
                          COLOR_INDEX_TEXT, text,
                          COLOR_RGB,        &rgb,
                          COLOR_H,          hsv.h,
                          COLOR_S,          hsv.s,
                          COLOR_V,          hsv.v,
                          -1);
      g_free (text);
    }

  g_free (cmap);

  remap_ui = remap_ui_manager_new (dialog, store);

  iconview = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
  g_object_unref (store);

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

  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (iconview),
                                    GTK_SELECTION_SINGLE);
  gtk_icon_view_set_orientation (GTK_ICON_VIEW (iconview),
                                 GTK_ORIENTATION_VERTICAL);
  gtk_icon_view_set_columns (GTK_ICON_VIEW (iconview), 16);
  gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (iconview), 0);
  gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (iconview), 0);
  gtk_icon_view_set_reorderable (GTK_ICON_VIEW (iconview), TRUE);

  renderer = gimp_cell_renderer_color_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (iconview), renderer,
                                  "color", COLOR_RGB,
                                  NULL);
  g_object_set (renderer,
                "width", 24,
                NULL);

  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (iconview), renderer,
                                  "text", COLOR_INDEX_TEXT,
                                  NULL);
  g_object_set (renderer,
                "size-points", 6.0,
                "xalign",      0.5,
                "ypad",        0,
                NULL);

  g_signal_connect (iconview, "popup-menu",
                    G_CALLBACK (remap_popup_menu),
                    NULL);

  g_signal_connect (iconview, "button-press-event",
                    G_CALLBACK (remap_button_press),
                    NULL);

  box = gimp_hint_box_new (_("Drag and drop colors to rearrange the colormap.  "
                             "The numbers shown are the original indices.  "
                             "Right-click for a menu with sort options."));

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

  g_signal_connect (dialog, "response",
                    G_CALLBACK (remap_response),
                    store);

  gtk_widget_show_all (dialog);

  gtk_main ();

  i = 0;

  for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
       valid;
       valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter))
    {
      gint index;

      gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
                          COLOR_INDEX, &index,
                          -1);
      map[i++] = index;
    }

  gtk_widget_destroy (dialog);

  return remap_run;
}
示例#12
0
int main(int argc, char** argv) {
    
    //gtk wdiget init start...
    GtkWidget *window, *icon_view, *notebook;
    GtkWidget *current_user_name, *current_time, *network_speed;
    GtkWidget *home_button, *access_token_entry, *access_token_ok_button;
    GtkWidget *access_token_cancel_button;
    GtkWidget *get_access_token_button, *post_blog_title_entry;
    GtkWidget *post_blog_content_text_view, *post_blog_content_text_buffer;
    GtkWidget *post_blog_ok_button, *post_blog_cancel_button;
    GtkWidget *blog_access_permission, *blog_password;
    GList *post_blog_page = NULL;
    GtkBuilder *builder;
    GError *error = NULL;
    
    //widget init
    gtk_init(&argc, &argv);
    builder = gtk_builder_new();
    if(!gtk_builder_add_from_file(builder, "./sources/glade.glade", &error))
    {
        g_print("Error occured while loading UI files\n");
        g_print("Message: %s\n", error->message);
        g_free(error);
        return 1;
    }
    
    //widget get from builder(glade files)
    window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
    notebook = GTK_WIDGET(gtk_builder_get_object(builder, "notebook1"));
    icon_view = GTK_WIDGET(gtk_builder_get_object(builder, "iconview1"));
    current_user_name = GTK_WIDGET(gtk_builder_get_object(builder,"label4"));
    current_time = GTK_WIDGET(gtk_builder_get_object(builder, "label5"));
    network_speed = GTK_WIDGET(gtk_builder_get_object(builder, "label6"));
    access_token_ok_button = GTK_WIDGET(gtk_builder_get_object(builder, "button3"));
    access_token_cancel_button = GTK_WIDGET(gtk_builder_get_object(builder, "button6"));
    get_access_token_button = GTK_WIDGET(gtk_builder_get_object(builder, "button2"));
    home_button = GTK_WIDGET(gtk_builder_get_object(builder, "button1"));
    access_token_entry = GTK_WIDGET(gtk_builder_get_object(builder, "entry1"));
    post_blog_content_text_view= GTK_WIDGET(gtk_builder_get_object(builder, "textview1"));
    post_blog_ok_button = GTK_WIDGET(gtk_builder_get_object(builder, "button4"));
    post_blog_title_entry = GTK_WIDGET(gtk_builder_get_object(builder, "entry2"));
    blog_access_permission = GTK_WIDGET(gtk_builder_get_object(builder, "comboboxtext1"));
    blog_password = GTK_WIDGET(gtk_builder_get_object(builder, "entry4"));
    
    
    //set object attributes
    gtk_window_set_title(GTK_WINDOW(window), "Xiao nei Gtk App");
    gtk_window_set_default_size(GTK_WINDOW(window), 800, 400);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_icon_view_set_model(GTK_ICON_VIEW(icon_view), create_model());
    gtk_icon_view_set_text_column(GTK_ICON_VIEW(icon_view), COL_DISPLAY_NAME);
    gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(icon_view), COL_PIXBUF);
    gtk_icon_view_set_columns(GTK_ICON_VIEW(icon_view), 4);
    gtk_label_set_text(GTK_LABEL(current_user_name), "Current user:fengtianba");
    g_timeout_add_seconds(1, (GSourceFunc)set_label_time, current_time);
    gtk_label_set_text(GTK_LABEL(network_speed), "Network Speed:100M");
    gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
    int n = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), icon_view);
    //gtk_combo_box_set_model(GTK_COMBO_BOX(blog_access_permission), create_combo_box_tree_model());
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "private", "PRIVATE");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "public", "PUBLIC");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "password", "PASSWORD");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "friend", "FRIEND");
    printf("n is %d\n", n);
    struct tm *time_ptr;
    time_t the_time;
    char *time_malloc;
    (void)time(&the_time);
    time_ptr = localtime(&the_time);
    time_malloc = malloc(sizeof(struct tm));
    memset(time_malloc, 0, sizeof(struct tm));
    sprintf(time_malloc, "%d/%d/%d/%d:%d:%d", 1900 + time_ptr->tm_year, time_ptr->tm_mon, time_ptr->tm_mday,
            time_ptr->tm_hour, time_ptr->tm_min, time_ptr->tm_sec);
    gtk_label_set_text(GTK_LABEL(current_time), time_malloc);
    post_blog_page = g_list_append(post_blog_page, post_blog_title_entry);
    post_blog_page = g_list_append(post_blog_page, post_blog_content_text_view);
    post_blog_page = g_list_append(post_blog_page, blog_access_permission);
    post_blog_page = g_list_append(post_blog_page, blog_password);
    
    //signal to connect to widget
    g_signal_connect(window, "delete-event", gtk_main_quit, NULL);
    g_signal_connect(GTK_BUTTON(get_access_token_button), "clicked", G_CALLBACK(get_access_token_button_clicked), NULL);
    g_signal_connect(GTK_ICON_VIEW(icon_view), "item-activated", G_CALLBACK(icon_view_item_select), notebook);
    g_signal_connect(GTK_BUTTON(home_button), "clicked", G_CALLBACK(home_button_clicked), notebook);
    g_signal_connect(GTK_BUTTON(access_token_ok_button), "clicked", G_CALLBACK(access_token_ok_button_clicked), access_token_entry);
    g_signal_connect(GTK_BUTTON(post_blog_ok_button), "clicked", G_CALLBACK(post_blog_ok_button_clicked), post_blog_page);
    //object unref
    g_object_unref(G_OBJECT(builder));    
    
    //show widget 
    gtk_widget_show_all(window);
  
    gtk_main();   
    
   
    
    
    
    int i = 100;
    char *decode_string;
    
    /*CURL *curl;
    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    decode_string = curl_easy_unescape(curl, ACCESS_TOKEN, 0, &i);
    printf("origin url: %s\n", ACCESS_TOKEN);
    printf("new    url: %s\n", decode_string);
    curl_easy_cleanup(curl);*/

    //puts("enter access token\n");
    //scanf("%s", accesstoken);
    //调用自己写的SDK
    xiaonei_gtk_get_blog_list(accesstoken);
    xiaonei_gtk_get_one_blog(accesstoken);
    






    

    return (EXIT_SUCCESS);
}