Ignore:
Timestamp:
Nov 25, 2006, 11:06:46 PM (19 years ago)
Author:
cinc
Message:

Very preliminary icon support. Started with folder views.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/desktop/class_c/wpfolder.c

    r106 r111  
    5959#include "wpfolder.ih"
    6060#include "wpdatafile.h"
     61#include "desktop.h"
     62#include "helper.h"
    6163
    6264/* Enum for the folder store */
     
    8385}
    8486
     87static void
     88itemActivated (GtkIconView *icon_view,
     89                GtkTreePath *tree_path,
     90                gpointer     user_data)
     91{
     92  DosBeep(1500, 100);
     93}
     94
     95static gboolean
     96fldr_handleButtonEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
     97{
     98#if 0
     99  if(fldr_checkContextButton(event))
     100    {
     101      WPObject *wpObject=(WPObject*)user_data;
     102     
     103      if(!somIsObj(wpObject))
     104        return TRUE;
     105
     106      /* ptlPopupPt is NULLHANDLE because GTK automatically pick a useful position for the popup
     107         menu. */
     108      _wpDisplayMenu(wpObject, NULLHANDLE, (HWND) widget, NULLHANDLE, 0, (ULONG) 0);
     109      return TRUE;
     110    }
     111#endif
     112  return FALSE;
     113}
     114
     115/*
     116  This function creates the folder window it doesn't queries any files or creates
     117  models and stuff.
     118*/
     119GtkWidget* fldr_createFolderWindow(WPFolder *nomSelf, const gchar* gcPath)
     120{
     121  GtkWidget* window;
     122  GtkWidget *vbox;
     123  GtkWidget *sw;
     124  GtkWidget *icon_view;
     125  GtkWidget *tool_bar;
     126  GtkToolItem *up_button;
     127  PPRIVFOLDERDATA priv;
     128
     129  WPFolderData *nomThis = WPFolderGetData(nomSelf);
     130
     131  /* Folder toplevel window. */
     132  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
     133  /* Set title */
     134  gtk_window_set_title (GTK_WINDOW (window), gcPath);
     135  /* FIXME: Set default size of folder frame. Will later use a stored value */
     136  gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
     137
     138  vbox = gtk_vbox_new (FALSE, 0);
     139  gtk_container_add (GTK_CONTAINER (window), vbox);
     140
     141  /* Create and pack the toolbar */
     142  tool_bar = gtk_toolbar_new ();
     143  gtk_box_pack_start (GTK_BOX (vbox), tool_bar, FALSE, FALSE, 0); /* Don't expand the toolbar vertically if sized */
     144 
     145  /* Parent button */
     146  up_button = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
     147  gtk_tool_item_set_is_important (up_button, TRUE);
     148  /* Disable button */
     149  gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
     150  /* Put it into the toolbar */
     151  gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
     152 
     153  sw = gtk_scrolled_window_new (NULL, NULL);
     154  /* Drawing style */
     155  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
     156                                       GTK_SHADOW_ETCHED_IN);
     157  /* Show scrollbars only if necessary */
     158  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
     159                                  GTK_POLICY_AUTOMATIC,
     160                                  GTK_POLICY_AUTOMATIC);
     161  /* Pack it into the vbox with size adjusting to the vbox */
     162  gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
     163  /* Create an icon view without model */
     164  icon_view = gtk_icon_view_new ();
     165  /* Allow multiple selection in icon view */
     166  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
     167                                    GTK_SELECTION_MULTIPLE);
     168  /* Connect to the "item_activated" signal */
     169  g_signal_connect (icon_view, "item-activated",
     170                    G_CALLBACK (itemActivated), nomSelf);
     171  /* This is for kb binding only */
     172#if 0
     173  g_signal_connect (GTK_WIDGET(icon_view), "popup-menu",
     174                    G_CALLBACK (fldr_cbPopupMenu), nomSelf);
     175#endif
     176  /* Handle mouse buttons */
     177  g_signal_connect (GTK_WIDGET(icon_view), "button-press-event",
     178                    G_CALLBACK (fldr_handleButtonEvent), nomSelf);
     179  g_signal_connect (GTK_WIDGET(icon_view), "button-release-event",
     180                    G_CALLBACK (fldr_handleButtonEvent), nomSelf);
     181
     182#if 0
     183  /* Connect to the "clicked" signal of the "Up" tool button */
     184  g_signal_connect (up_button, "clicked",
     185                    G_CALLBACK (up_clicked), store);
     186#endif
     187  /* Add icon view as child to the scroll window created earlier */
     188  gtk_container_add (GTK_CONTAINER (sw), icon_view);
     189  priv=(PPRIVFOLDERDATA)_privFolderData;
     190  priv->gtkIconView=icon_view;
     191
     192  gtk_widget_grab_focus (icon_view);
     193
     194  gtk_widget_show_all (window);
     195 
     196  return window;
     197}
     198
    85199static BOOL
    86200fldr_fillStore (GtkListStore *store, const gchar* gchrPath)
     
    140254                {
    141255                  gtk_list_store_append (store, &iter);
    142 #if 0
     256
     257#warning !!!! some problems with icon handling here !!!!
     258                  nomPrintf("Icon ptr: %x\n", _wpQueryIcon(wpDataFile, NULLHANDLE));
    143259                  gtk_list_store_set (store, &iter,
    144260                                      COL_PATH, path,
    145261                                      COL_DISPLAY_NAME, display_name,
    146262                                      COL_IS_DIRECTORY, is_dir,
    147                                       COL_PIXBUF, _wpQueryIcon(wpDataFile), //file_pixbuf,
     263                                      COL_PIXBUF, _wpQueryIcon(wpDataFile, NULLHANDLE), //file_pixbuf,
    148264                                      -1);
    149 #endif
    150265                }
    151266            }
     
    172287  g_return_val_if_fail(_privFolderData!=NULLHANDLE, FALSE);      /* Huh! What happened in wpInitData()? */
    173288  g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s\n", __FUNCTION__, pszPath);
     289
     290#warning !!!!! Window creation must be done elsewhere !!!!!
     291  fldr_createFolderWindow(nomSelf, pszPath);
    174292
    175293#if 0
     
    195313  fldr_fillStore(gStore, pszPath);
    196314
    197 #if 0
     315
    198316  gtk_icon_view_set_model(GTK_ICON_VIEW (priv->gtkIconView), GTK_TREE_MODEL (priv->gstoreFldContents));
     317
     318
    199319  /* We now set which model columns that correspont to the text
    200320   * and pixbuf of each item
     
    206326
    207327  g_object_unref (gStore);
    208 #endif
     328
    209329  return FALSE;
    210330}
     
    234354}
    235355
    236 
    237 
    238 
    239 
    240 
     356NOM_Scope void NOMLINK impl_WPFolder_wpQueryIcon(WPFolder* nomSelf, CORBA_Environment *ev)
     357{
     358  static const gchar *gchrIconName=NULLHANDLE;
     359  static gpointer ptrIcon=NULLHANDLE;
     360  GError *error=NULL;
     361
     362/* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
     363
     364  /* Load default wpObject icon */
     365  if(!gchrIconName){
     366    gchrIconName=g_build_filename(priv_getIconDir(), WPFOLDER_ICON_FILE, NULL);
     367   
     368    g_return_val_if_fail(g_file_test (gchrIconName, G_FILE_TEST_EXISTS), NULLHANDLE);
     369    nomPrintf("IconFile: %s\n", gchrIconName); 
     370    //  _hPointerCls = (HPOINTER)gdk_pixbuf_new_from_file (gchrIconName, &error);
     371    ptrIcon=gdk_pixbuf_new_from_file (gchrIconName, &error);
     372  }
     373  return ptrIcon;
     374
     375  /*  WPFolder_wpQueryIcon_parent(nomSelf,  ev); */
     376}
     377
     378
     379
     380
     381
Note: See TracChangeset for help on using the changeset viewer.